Frequently Asked Question:
How do I convert an image file to PDF?
Question
How do I convert an image file to PDF?
Answer
Converting an image to a PDF is simple using Quick PDF Library. The steps below outline how this can be done. The sample is done in C# and uses the ActiveX edition but the syntax for using Quick PDF Library is very similar no matter what language you use.
Step 1. Create a document in memory
// A document is created automatically upon creation
QuickPDFAX0717.PDFLibrary qp = new QuickPDFAX0717.PDFLibrary();
// Setup your local variables
string sImageFileName = "myimage.jpg";
string sPDFFileName = "mypdf.pdf";
// Unlock the library
qp.UnlockKey("YOURKEY");
Step 2. Load and select your image
// Load your image into memory
qp.AddImageFromFile(sImageFileName, 1);
// Get width, height of the image
int lWidth = qp.ImageWidth();
int lHeight = qp.ImageHeight();
Step 3. Resize the page and draw the image
// Reformat the size of the page in the selected document
qp.SetPageDimensions(lWidth, lHeight);
// Draw the image onto the page using the specified width/height
qp.DrawImage(0, lHeight, lWidth, lHeight);
// Store the updated PDF where you like
qp.SaveToFile(sPDFFileName);