C # Image and PDF Manipulation

5

I wonder if there is a way to turn multiple images into a single PDF file. In my application I'm already pulling their address.

    
asked by anonymous 19.05.2015 / 20:46

1 answer

2

Using iTextSharp 4 , can be done as follows:

iTextSharp.text.Document Doc = new iTextSharp.text.Document(PageSize.LETTER, 20, 20, 20, 20);
string PDFOutput = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "Output.pdf");
PdfWriter writer = PdfWriter.GetInstance(Doc, new FileStream(PDFOutput, FileMode.Create, FileAccess.Write, FileShare.Read));

Doc.Open();

string Folder = "C:\Diretorio\das\Imagens";
foreach (string F in System.IO.Directory.GetFiles(Folder, "*.jpg")) 
{
    Doc.NewPage();
    Doc.Add(new iTextSharp.text.Jpeg(new Uri(new FileInfo(F).FullName)));
}

Doc.Close();

I got the answer from here .

    
19.05.2015 / 21:28