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!
![]() |
Add 300dpi image to PDF |
Post Reply ![]() |
Author | |
byron ![]() Beginner ![]() Joined: 15 Jun 12 Status: Offline Points: 4 |
![]() ![]() ![]() ![]() ![]() Posted: 13 Mar 13 at 1:04PM |
Hello.
I want to add a jpg image to a PDF with AddImageFromFile. This image is about 1400x1200 px but with 300dpi. When I print this image is about 10x10 cm long, but If I add this image to pdf it takes all the page. The problem is how I say the resolution of image when adding it to pdf. I try with FitImage and SetImageResolution, but I cann't do it. Some help? thanks.
|
|
![]() |
|
AndrewC ![]() Moderator Group ![]() ![]() Joined: 08 Dec 10 Location: Geelong, Aust Status: Offline Points: 841 |
![]() ![]() ![]() ![]() ![]() |
Some sample code would be helpful.
Here is a link that shows the correct way to add an image to a PDF and size it correctly based on the imageWidth/Height and DPI. http://www.quickpdf.org/forum/creating-a-multi-page-pdf-from-a-multipage-tiff_topic2125.html The trick is to call int dpix = QP.ImageHorizontalResolution(); and int dpiy = QP.ImageVerticalResolution(); as QP.ImageWidth and QP.ImageHeight return values in pixels whereas QP.DrawImage requires values in points by default (72 points = 1 inch) Andrew.
|
|
![]() |
|
byron ![]() Beginner ![]() Joined: 15 Jun 12 Status: Offline Points: 4 |
![]() ![]() ![]() ![]() ![]() |
Thanks for your answer. Here is the procedure I use:
- An example of image is a jpg: 1013x1500 px with 300 dpi and 24 bits color. - If I print this image directly from windows, it's about 85mm x 125mm. - I have a PDF with only one A4 page. - I want to add this image to the page, but I must fit the real dimension when printed, that is, 85x123mm. I use the next Delphi code: PDFLibrary.LoadFromFile('c:\tmp\mypdf.pdf',''); idx:=PDFLibrary.AddImageFromFile('c:\tmp\myimage.jpg',0); PDFLibrary.SelectImage(idx); PDFLibrary.SetImageResolution(300,300,2); hr:=((jpg.width*2.54)/10); vr:=((jpg.Height*2.54)/10); PDFLibrary.FitImage(0, PDFLibrary.PageHeight, hr, vr, 1, 1, 0); PDFLibrary.SaveToFile(filename); I'll try with PDFLibrary.DrawImage(0, PDFLibrary.PageHeight, hr, vr); too. The image is added and render good and I open pdf and see its size is correctly on A4 page. But the problem is If I print the image with full quality and see difference from printing the jpg image directly to printer. I think the problem is FitImage or Draw image reduce dpi resolution when draw. Or pheraps I have a mistake. Any help? |
|
![]() |
Post Reply ![]() |
|
Tweet
|
Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |
Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. About — Contact — Blog — Support — Online Store