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 - PPI of PDF generated from an image
  FAQ FAQ  Forum Search   Register Register  Login Login

PPI of PDF generated from an image

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


Joined: 09 Dec 09
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote victordscott Quote  Post ReplyReply Direct Link To This Post Topic: PPI of PDF generated from an image
    Posted: 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
Back to Top
Ingo View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 29 Oct 05
Status: Offline
Points: 3530
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ingo Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
victordscott View Drop Down
Beginner
Beginner


Joined: 09 Dec 09
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote victordscott Quote  Post ReplyReply Direct Link To This Post 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;

}

Back to Top
victordscott View Drop Down
Beginner
Beginner


Joined: 09 Dec 09
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote victordscott Quote  Post ReplyReply Direct Link To This Post 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
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