I have a problem in my project.
- Code: Select all
PdfDocument document = new PdfDocument();
document.LoadFromFile(@"C:\Users\Test\OneDrive\Desktop\test.pdf");
PdfDocument newPdf = new PdfDocument();
newPdf.PageSettings.Margins.All = 0;
document.PageSettings.Margins.All = 0;
PdfUnitConvertor unitCvtr = new PdfUnitConvertor();
PdfPageBase page = document.Pages[0];
double height = unitCvtr.ConvertUnits((float)page.Size.Height, PdfGraphicsUnit.Point, PdfGraphicsUnit.Pixel);
double width = unitCvtr.ConvertUnits((float)page.Size.Width, PdfGraphicsUnit.Point, PdfGraphicsUnit.Pixel);
PdfPageBase newPage = newPdf.Pages.Add(new SizeF((float)width * 10, (float)height * 10));
loLayout.Layout = PdfLayoutType.OnePage;
page.CreateTemplate().Draw(newPage, new PointF(0, 0), loLayout);
Image bmp = newPdf.SaveAsImage(0);
This could resize the input pdf, debugging the code it works but when i call the function SaveAsImage, the output image is scaled regard to the original pdf, and i can't understand why?
Anyone could help me?