Do you own a Debenu Quick PDF Library version 7, 8, 9, 10, 11, 12, 13 or iSEDQuickPDF license? Upgrade to Debenu Quick PDF Library 14 today!

Debenu Quick PDF Library - PDF SDK Community Forum Homepage
Forum Home Forum Home > For Users of the Library > I need help - I can help
  New Posts New Posts RSS Feed - Same Image Drawn on PDF at Different Sizes
  FAQ FAQ  Forum Search   Register Register  Login Login

Same Image Drawn on PDF at Different Sizes

 Post Reply Post Reply
Author
Message
pshay543 View Drop Down
Beginner
Beginner


Joined: 07 Oct 11
Status: Offline
Points: 9
Post Options Post Options   Thanks (0) Thanks(0)   Quote pshay543 Quote  Post ReplyReply Direct Link To This Post Topic: Same Image Drawn on PDF at Different Sizes
    Posted: 10 Oct 11 at 6:25PM
I'm having experiencing a strange behavior and it may just be how I am coding it or my lack of understanding of the component / PDF. 
 
I have a 64 x 64 pixel image that I add to a PDF and then Draw it 3 times on the same page. The first time it is drawn it is drawn large and the second and third time it is drawn with the correct size.   Below is my code: 
 
PDFLibrary.SetPageSize('Letter');
PDFLibrary.SetMeasurementUnits(0);     // Set to Millimeters
 
// Select the 64x64 Image
PDFLibrary.CompressImages(1);
pdfLibrary.SelectImage(iImageID);

PDFLibrary.SetOrigin(1);

PixelsPerMM(MyIMGScrollBox.Graphic.Canvas,xMili,yMili);   // get Pixels per Millimeter

iWidthDPI := PDFLibrary.PageWIdth;
iHeightDPI := PDFLibrary.PageHeight;
 
// Draw the Image at 0,0 and it is Larger than the next two images
PDFLibrary.DrawImage(0,0,(MyIMGScrollBox.Graphic.Width / xMilli),(MyScrollBox.Graphic.Height / yMilli));
 
// Still the same image selected and these are drawn with the proper size.
PDFLibrary.DrawImage(200,200,(MyIMGScrollBox.Graphic.Width / xMilli),(MyScrollBox.Graphic.Height / yMilli));
PDFLibrary.DrawImage(400,400,(MyIMGScrollBox.Graphic.Width / xMilli),(MyScrollBox.Graphic.Height / yMilli));
 
Is there something special about drawing at 0,0 ? or is this a bug when an image is drawn at that location?   The Image is a BMP.  
 
Any Help would be appreciated.  
 
Thank you,
Paul
 
Back to Top
pshay543 View Drop Down
Beginner
Beginner


Joined: 07 Oct 11
Status: Offline
Points: 9
Post Options Post Options   Thanks (0) Thanks(0)   Quote pshay543 Quote  Post ReplyReply Direct Link To This Post Posted: 10 Oct 11 at 6:39PM
I think I figured out the issue (Sort of).    As soon as I use the AddImageFromStream it draws the image on the current PDF page even prior to calling the draw command from the quickpdf library. This is over lapping the actual image drawing at 0,0. 
 
According to the reference guide: The addImageFromStream adds the Image to the document and then it can be drawn anywhere.  However, the addImageFromStream is adding it directly to the page I'm working with. 
 
How can I prevent this from adding to the page?   See my full Code below:
 
            MyScrollBox.Clear;
            MyScrollBox.LoadFromFile(sImageFiles[iImageFileCount], i);
            MyScrollBox.SaveToStream(ms, 'BMP');
            ms.Position := 0;
 
            if bFirstTime then
              bFirstTime := False
            else
                iImageCOunter := pdflibrary.NewPage;

            pdflibrary.SelectPage(iImageCounter);
 
// This command is drawing the image on the current page.
            iImageID := pdflibrary.AddImageFromStream(MS, 0);
 
 
            iWidth := PDFLibrary.ImageWidth;
            IHeight:= PDFLibrary.ImageHeight;
                          // Set the paper size
            PDFLibrary.SetPageSize('Letter');
            PDFLibrary.SetMeasurementUnits(0);     // Set to Millimeters

            PDFLibrary.CompressImages(1);
            pdfLibrary.SelectImage(iImageID);

            PDFLibrary.SetOrigin(1);

            PixelsPerMM(MyScrollBox.Graphic.Canvas,xMili,yMili);

            dScale := Math.Max(xMili / PDFLibrary.PageWidth, yMili / PDFLibrary.PageHeight);

 //           PDFLibrary.DrawImage(100,100,(MyScrollBox.Graphic.Width / xMili),(MyScrollBox.Graphic.Height / yMili));
 //           PDFLibrary.DrawImage(200,200,(MyScrollBox.Graphic.Width / xMili),(MyScrollBox.Graphic.Height / yMili));
 //           PDFLibrary.DrawImage(400,400,(MyScrollBox.Graphic.Width / xMili),(MyScrollBox.Graphic.Height / yMili));
 
 
Notice how I have the draw image commands commented out but yet the PDF shows the image in the upper left corner when saved.
 
That is why In my previous post of drawing at 0,0 I thought that the image was larger.  It wasn't the image from the drawimage but the image placed on the page from the addImageFromStream.
 
Any suggestions?
 
Thank you,
Paul
 
 
Back to Top
tfrost View Drop Down
Senior Member
Senior Member


Joined: 06 Sep 10
Location: UK
Status: Offline
Points: 437
Post Options Post Options   Thanks (0) Thanks(0)   Quote tfrost Quote  Post ReplyReply Direct Link To This Post Posted: 11 Oct 11 at 12:47PM
I use AddImageFromStream and do not see this problem (in 7.24).  However in checking my code, I see that I use a second parameter of 3, not 0.  This seems to have happened because at one time the stream contained a PNG file, and when it was changed to use a BMP instead, I forgot to change the parameter.  We changed the image format because using a PNG resulted in a huge PDF file.  Worth a shot, maybe (but still an issue needing to be resolved)?
Back to Top
pshay543 View Drop Down
Beginner
Beginner


Joined: 07 Oct 11
Status: Offline
Points: 9
Post Options Post Options   Thanks (0) Thanks(0)   Quote pshay543 Quote  Post ReplyReply Direct Link To This Post Posted: 11 Oct 11 at 12:58PM
Thanks,   I tried placing a 3 as the parameter for the AddImageFromStream but I get the same result.  This is version 7.26.  
 
Thank you,
Paul
 
Back to Top
pshay543 View Drop Down
Beginner
Beginner


Joined: 07 Oct 11
Status: Offline
Points: 9
Post Options Post Options   Thanks (0) Thanks(0)   Quote pshay543 Quote  Post ReplyReply Direct Link To This Post Posted: 11 Oct 11 at 6:48PM
The same code as above produces the same results in 8.11.   Either my understanding of how the assignImagefromStream works and my coding is wrong or a bug must have been introduced sometime after 7.24.
 
Thanks,
Paul
 
Back to Top
tfrost View Drop Down
Senior Member
Senior Member


Joined: 06 Sep 10
Location: UK
Status: Offline
Points: 437
Post Options Post Options   Thanks (0) Thanks(0)   Quote tfrost Quote  Post ReplyReply Direct Link To This Post Posted: 12 Oct 11 at 12:12AM
I should have written 7.26 in my earlier message.  I have not had the problem you describe with any of 7.24 to 8.11.
Back to Top
pshay543 View Drop Down
Beginner
Beginner


Joined: 07 Oct 11
Status: Offline
Points: 9
Post Options Post Options   Thanks (0) Thanks(0)   Quote pshay543 Quote  Post ReplyReply Direct Link To This Post Posted: 12 Oct 11 at 1:11AM
I'm really confused now :). 
 
I have tried with Delphi Version 6 and Version 7.    I just rebuilt my machine and will have to load Delphi 2005 up to see if it is possibly delphi version related.
 
Do you mind me asking you what version of Delphi you are using?
 
Thank you,
Paul
 
Back to Top
tfrost View Drop Down
Senior Member
Senior Member


Joined: 06 Sep 10
Location: UK
Status: Offline
Points: 437
Post Options Post Options   Thanks (0) Thanks(0)   Quote tfrost Quote  Post ReplyReply Direct Link To This Post Posted: 12 Oct 11 at 11:00AM
I use DXE (and formerly D2010) for QuickPDF v7 and tested with DXE2 and QuickPDF v8.  My suggestion would be to open a support case as I don't see how the Delphi version could affect this.
Back to Top
AndrewC View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 08 Dec 10
Location: Geelong, Aust
Status: Offline
Points: 841
Post Options Post Options   Thanks (0) Thanks(0)   Quote AndrewC Quote  Post ReplyReply Direct Link To This Post Posted: 13 Oct 11 at 2:34PM
I have reviewed the QPL source code and there is no way that AddImageFromFile also draws the image onto the PDF.  The AddImageFromFile and DrawImage commands are totally separate.

Andrew.
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.01
Copyright ©2001-2014 Web Wiz Ltd.

Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. AboutContactBlogSupportOnline Store