PDFsharp & MigraDoc Foundation https://forum.pdfsharp.net/ |
|
XImage.FromGdiPlusImage() method https://forum.pdfsharp.net/viewtopic.php?f=2&t=4064 |
Page 1 of 1 |
Author: | mnord [ Mon Nov 25, 2019 8:25 pm ] |
Post subject: | XImage.FromGdiPlusImage() method |
In version 1.50, I am trying to use XImage.FromGdiPlusImage() and it is not available for the selected image frame. Image img = Image.FromFile(@"C:\\Multi_page.tif"); string destination = @"C:\\Multi_page.pdf"; PdfDocument document = new PdfDocument(); for (int pageIndex = 0; pageIndex < img.GetFrameCount(FrameDimension.Page); pageIndex++) { img.SelectActiveFrame(FrameDimension.Page, pageIndex); PdfSharp.Drawing.XImage xImage = PdfSharp.Drawing.XImage.FromGdiPlusImage(img); var page = new PdfPage(); if (xImage.PixelWidth > xImage.PointHeight) { page.Orientation = PageOrientation.Landscape; } else { page.Orientation = PageOrientation.Portrait; } document.Pages.Add(page); PdfSharp.Drawing.XGraphics xgr = PdfSharp.Drawing.XGraphics.FromPdfPage(document.Pages[pageIndex]); xgr.DrawImage(xImage, 0, 0); } What is the alternative that should be used? Thanks so much!! |
Author: | TH-Soft [ Mon Nov 25, 2019 9:21 pm ] |
Post subject: | Re: XImage.FromGdiPlusImage() method |
mnord wrote: In version 1.50, I am trying to use XImage.FromGdiPlusImage() and it is not available for the selected image frame. Where's the problem?You have to take the GDI+ build of PDFsharp if you want to use GDI+-specific methods like XImage.FromGdiPlusImage(). Quote: if (xImage.PixelWidth > xImage.PointHeight) What's the point of comparing PixelWidth and PointHeight?
|
Author: | mnord [ Mon Nov 25, 2019 9:28 pm ] |
Post subject: | Re: XImage.FromGdiPlusImage() method |
TH-Soft: How do you select the GDI+ build of PDFSharp? It is not an option with the Nuget package. As for the PixelWidth and PixelHeight, it is used to set the page orientation. Thanks, Marty |
Author: | TH-Soft [ Mon Nov 25, 2019 10:11 pm ] |
Post subject: | Re: XImage.FromGdiPlusImage() method |
mnord wrote: TH-Soft: How do you select the GDI+ build of PDFSharp? It is not an option with the Nuget package. Try one of those:https://www.nuget.org/packages/PDFsharp-gdi/ https://www.nuget.org/packages/PDFsharp-MigraDoc-GDI/ mnord wrote: As for the PixelWidth and PixelHeight, it is used to set the page orientation. I don't understand why you compare PixelWidth and PointHeight. Comparing PixelWidth with PixelHeight makes sense.
|
Author: | mnord [ Mon Nov 25, 2019 10:15 pm ] |
Post subject: | Re: XImage.FromGdiPlusImage() method |
TH-Soft: Thanks for the reply. I didn't know those options were possible. I made a typo. It should have been PixelHeight instead of PointHeight. My goof. |
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |