PDFsharp & MigraDoc Foundation
http://forum.pdfsharp.de/

How to create a pdf document with images
http://forum.pdfsharp.de/viewtopic.php?f=2&t=1323
Page 1 of 1

Author:  srikanthgaddala [ Sat Sep 04, 2010 11:41 am ]
Post subject:  How to create a pdf document with images

Hi All,
i have a problem with creating pdf document.
My requirement is in my project i am scanning documents and saving them as tiff images.i need to add those scanned tiff images to a pdf file.
for ex:if i have scanned 3 images then those 3 images should be added to some sample.pdf file....

Please help me to solve this....

Author:  peterh [ Mon Jan 24, 2011 1:32 pm ]
Post subject:  Re: How to create a pdf document with images

This may be a bit (more than a bit, actually) late, but it might still be using for someone opening this topic after a search.

Here's how I do it: one-by-one.
Code:
            PdfSharp.Pdf.PdfDocument document = new PdfSharp.Pdf.PdfDocument();
           
            foreach(string s in System.IO.Directory.GetFiles(SourceFolder, "*.tif"))
            {
                PdfSharp.Pdf.PdfPage page = new PdfSharp.Pdf.PdfPage();
                page.Size = PdfSharp.PageSize.A4;
                PdfSharp.Drawing.XGraphics xGr = PdfSharp.Drawing.XGraphics.FromPdfPage(document.Pages.Add(page));
                PdfSharp.Drawing.XImage img = PdfSharp.Drawing.XImage.FromFile(s);
                xGr.DrawImage(img, 0, 0);
            }
           
            document.Save(TargetName);
            document.Close();


hth,
peter

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/