Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generate PDF from set of JPEGs

I have a set of JPEG's on my server all the same size. Can I convert this into a PDF file server side?

like image 567
Tom Gullen Avatar asked Mar 14 '11 15:03

Tom Gullen


People also ask

How do I make a group of jpegs into a PDF?

Simply visit the Acrobat Online website and upload the files you want to merge. Reorder the files however you like and then click Merge files. After that, just download the merged PDF. This will combine all the JPGs-turned-PDFs into a single PDF you can easily share or view.

How do I save 3 jpegs as PDF?

Go to the file that your JPG pictures are located at, choose those you want to convert. Right-click to open a menu, now choose "Print". A new window will pop up for print settings. On the "Printer" column, choose "Microsoft Print to PDF" on the drop-down menu.

Can I create PDF with pictures?

Method 2: How to Create PDF from a Single Image Here's what you need to do: Go to the Explorer location where your image is stored and right-click it. Choose the “Create to PDF” option to convert to PDF and the file will be open in PDFelement automatically. Press “Ctrl + S” to save the PDF file.


2 Answers

I'd try using http://www.pdfsharp.net/

Something along the lines of

PdfPage page = outputDocument.AddPage();
page.Size = PdfSharp.PageSize.A4;
XGraphics gfx = XGraphics.FromPdfPage(page);
XImage image = XImage.FromFile("MyJPGFileXXX.jpg");
gfx.DrawImage(image, 0, 0);
like image 77
MikeM Avatar answered Oct 19 '22 08:10

MikeM


I am using iText for this requirement

Document document = new Document();
PdfWriter.getInstance(document, new FileOutputStream(yourOutFile));
document.open();

for(int i=0;i<numberOfImages;i++){
  Image image1 = Image.getInstance("myImage"+i+".jpg");
  image1.scalePercent(23f);
  document.newPage();
  document.add(image1);
}
document.close();
like image 33
Anupam Avatar answered Oct 19 '22 09:10

Anupam