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!
![]() |
PPI of PDF generated from an image |
Post Reply
|
| Author | |
victordscott
Beginner
Joined: 09 Dec 09 Status: Offline Points: 3 |
Post Options
Thanks(0)
Quote Reply
Topic: PPI of PDF generated from an imagePosted: 09 Dec 09 at 4:59PM |
|
I will explain what I need through this scenario: When I open a JPG file in Photoshop that is 180 PPI and then save from within Photoshop to a PDF, the resulting PDF has the same width and height because the PPI is maintained. I need the same thing to happen when I use the QuickPDF API. I want the PPI to be maintained and therefore the dimensions (width and height) will be maintained. I implemented an example using the API (using AddImageFromFile, DrawImage, SaveToFile, etc.) with an image in 180 PPI and it resulted in a PDF in 72 PPI. Therefore the width and height was much larger in the resulting PDF than the original image width and height. How do I get the same result that Photoshop's save to PDF gives? Any help will be greatly appreciated.
Regards,
Victor Scott |
|
![]() |
|
Ingo
Moderator Group
Joined: 29 Oct 05 Status: Offline Points: 3530 |
Post Options
Thanks(0)
Quote Reply
Posted: 12 Dec 09 at 9:36AM |
|
Hi Victor!
Perhaps you can post your code(-snippet) here ... so we can say where's the point to modificate anything to get the result you like. With QuickPDF you can change dimensions and you can change the dpi-value ... so basically what you want should be possible. Here you can find all you need for the first steps with QuickPDF: http://www.quickpdf.org/forum/quickpdf-the-first-steps_topic1242.html Cheers and welcome here, Ingo |
|
![]() |
|
victordscott
Beginner
Joined: 09 Dec 09 Status: Offline Points: 3 |
Post Options
Thanks(0)
Quote Reply
Posted: 12 Dec 09 at 9:59PM |
|
Here is the code snippet:
string sImageFileName = "c:\\PhotosForSites\\Houses\\iStock_000000392096Small.jpg";
qp.NewDocument();
if (qp.AddImageFromFile(sImageFileName, 1) == 0)
{
MessageBox.Show("Quick PDF Library was unable to load image");
return;
} // Get width, height of image int lWidth = qp.ImageWidth(); int lHeight = qp.ImageHeight(); if (qp.SetPageDimensions(lWidth, lHeight) == 0){ MessageBox.Show("Quick PDF Library was unable to process the page dimensions for " + sImageFileName); return;} // Draw the image onto the document using the specified width/height if (qp.DrawImage(0, lHeight, lWidth, lHeight) == 0){ MessageBox.Show("Quick PDF Library was unable to redraw the image as a PDF file."); return;} // Then do so using a .PDF extension instead of the image filename // in the output folder... string sPDFFileName = "c:\\temp\\" + Path.GetFileNameWithoutExtension(sImageFileName) + ".pdf"; if (qp.SaveToFile(sPDFFileName) == 0){ MessageBox.Show("Quick PDF Library could not save the image " + sImageFileName + " as a PDF file."); return;} |
|
![]() |
|
victordscott
Beginner
Joined: 09 Dec 09 Status: Offline Points: 3 |
Post Options
Thanks(0)
Quote Reply
Posted: 14 Dec 09 at 7:55PM |
|
I figured it out myself. I changed the following lines:
int lWidth = qp.ImageWidth(); int lHeight = qp.ImageHeight(); to:
double sizeFactor = 72d / (double)qp.ImageHorizontalResolution();
double lWidth = (double)qp.ImageWidth() * sizeFactor;
double lHeight = (double)qp.ImageHeight() * sizeFactor;
Thanks |
|
![]() |
|
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