|
|
Originally Posted by: Paul Rayman  Call page.Dispose after TransformClipPath. But it seems to me that this method is not what is needed for this task. Contact support@patagames.com with a description of the task. They will help you find a solution. With your hint and the help of Patagames support I got the solution: - I had to upgrade to version 4.56.2704
- Correct FS_RECTF creation (coordinates start at bottom not at top...)
- Set rotation to center of page
- Call pdfPage.Dispose
Thanks! Code:private static void RotateAndSave(PdfPage pdfPage, float rotation, Int32Size pageSize)
{
FS_RECTF fS_RECTF = new(0, pdfPage.Height, pdfPage.Width, 0);
FS_MATRIX fS_MATRIX = new();
fS_MATRIX.SetIdentity();
fS_MATRIX.Rotate(rotation, pageSize.Width / 2, pageSize.Height / 2, true);
bool result = pdfPage.TransformWithClip(fS_MATRIX, fS_RECTF);
pdfPage.Dispose();
using var bitmap = new PdfBitmap(pageSize.Width, pageSize.Height, true);
bitmap.FillRect(0, 0, pageSize.Width, pageSize.Height, FS_COLOR.White);
pdfPage.Render(bitmap, 0, 0, pageSize.Width, pageSize.Height, PageRotate.Normal, RenderFlags.FPDF_LCD_TEXT);
string pngFilename = @"C:\temp\rotated_pdf.png";
bitmap.Image.Save(pngFilename, System.Drawing.Imaging.ImageFormat.Png);
}
|
|
|
Call page.Dispose after TransformClipPath. But it seems to me that this method is not what is needed for this task. Contact support@patagames.com with a description of the task. They will help you find a solution.
|
|
|
Hi, I have to convert scanned PDF documents to PNG and try to compensate incorrect page orientation from scanning process. Here is an example of my tries. 'result' is always 'true', but the resulting PNG file always has same orientation like the original page in PDF. Code:private static void RotateAndSave(PdfPage pdfPage, float rotation, Int32Size pageSize)
{
FS_RECTF fS_RECTF = new(0, 0, pdfPage.Width, pdfPage.Height);
FS_MATRIX fS_MATRIX = new();
fS_MATRIX.SetIdentity();
fS_MATRIX.Rotate(rotation, true);
bool result = pdfPage.TransformWithClip(fS_MATRIX, fS_RECTF);
using var bitmap = new PdfBitmap(pageSize.Width, pageSize.Height, true);
bitmap.FillRect(0, 0, pageSize.Width, pageSize.Height, FS_COLOR.White);
pdfPage.Render(bitmap, 0, 0, pageSize.Width, pageSize.Height, PageRotate.Normal, RenderFlags.FPDF_LCD_TEXT);
string pngFilename = @"C:\temp\rotated_pdf.png";
bitmap.Image.Save(pngFilename, System.Drawing.Imaging.ImageFormat.Png);
}
Does Lite Edition not support this function? At https://pdfium.patagames...censing_FullAPICalls.htm I found also for Lite: Quote:PDF Page objects capability PDF object access and edit (Get/Set stroke color, Get/Set fill color, transform, copy, clone, bounding box, transparency,…)
Could please anyone help? Tried also with a demo license of Pdfium FULL and it doesn't work either. My environment: VS 2019, 16.9.5; WPF with .NET 5.0 Any ideas?
|