PDFsharp & MigraDoc Foundation https://forum.pdfsharp.net/ |
|
image in A4 https://forum.pdfsharp.net/viewtopic.php?f=2&t=2702 |
Page 1 of 1 |
Author: | raasmasood [ Mon Jan 13, 2014 3:05 pm ] |
Post subject: | image in A4 |
i am using this code to images to pdf Code: static void Main(string[] args) { DirectoryInfo di = new DirectoryInfo(@"C:\Users\masoodr\Desktop\Pages"); FileInfo[] files = di.GetFiles(); string filename = String.Format("{0}_tempfile.pdf", Guid.NewGuid().ToString("D").ToUpper()); PdfDocument s_document = new PdfDocument(); //PdfPage p = s_document.AddPage(); for (int i = 0; i < files.Count(); i++) { DrawPage(s_document.AddPage(), files[i].FullName); } // Save the s_document... s_document.Save(filename); // ...and start a viewer Process.Start(filename); } public static void DrawPage(PdfPage page,string fileName) { XGraphics gfx = XGraphics.FromPdfPage(page); XImage image = XImage.FromFile(fileName); gfx.DrawImage(image, 0, 0); } but for some reason the images are so enlarged they dont fit in. image should fit in as an A4 size rectangle. so what can i do ? |
Author: | Thomas Hoevel [ Mon Jan 13, 2014 3:20 pm ] |
Post subject: | Re: image in A4 |
Hi! Use DrawImage() with 5 parameters and specify how large the image shall be drawn. See also: viewtopic.php?p=7533#p7533 |
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |