[VB.NET/C#] Resize PDF to specific page dimensions
[VB.NET/C#] Resize PDF to specific page dimensions
Hello,
I have a pdf file where every page is 899,6 mm x 1238,2 mm big. This huge size is problematic for other components of my program, so I would like to resize it to standard 297mm x 210 mm (a standard A4).
Is there an "easy" way to do this. The only way I've found so far, is converting every page to an image with the method "RenderPdfPageAsImage", then creating an empty pdf with pages of the correct size, and drawing all the created images on the new PDF. But this increases the size of the pdf heavily. If i lower the dpi of the created images, then the pdf at the end it smaller, but I lose way to much quality.
Thanks for the help,
Kind regards
I have a pdf file where every page is 899,6 mm x 1238,2 mm big. This huge size is problematic for other components of my program, so I would like to resize it to standard 297mm x 210 mm (a standard A4).
Is there an "easy" way to do this. The only way I've found so far, is converting every page to an image with the method "RenderPdfPageAsImage", then creating an empty pdf with pages of the correct size, and drawing all the created images on the new PDF. But this increases the size of the pdf heavily. If i lower the dpi of the created images, then the pdf at the end it smaller, but I lose way to much quality.
Thanks for the help,
Kind regards
Re: Resize PDF
Hello,
Unfortunately this feature is not yet supported. A workaround is to use the rasterization, but it is not really suitable for non image based PDF documents.
We should deliver such feature within 4 months.
Kind regards,
Loïc
Unfortunately this feature is not yet supported. A workaround is to use the rasterization, but it is not really suitable for non image based PDF documents.
We should deliver such feature within 4 months.
Kind regards,
Loïc
Re: Resize PDF
Has there been any progress on this? We are using v9, and I'm trying to accomplish the same thing.
Basically, we have a legal document that we'd like to convert to letter size (8.5" x 11"), with a .5" margin. We are able to do this with PdfTron, but are converting everything over to GdPicture.NET.
Any advice would be greatly appreciated. Thanks!
Basically, we have a legal document that we'd like to convert to letter size (8.5" x 11"), with a .5" margin. We are able to do this with PdfTron, but are converting everything over to GdPicture.NET.
Any advice would be greatly appreciated. Thanks!
Re: Resize PDF
Hello,
This can now be easily be done with 9.1 and higher:
Let me know if you need further information.
Kind regards,
Loïc
This can now be easily be done with 9.1 and higher:
Code: Select all
Const PAGE_WIDTH As Integer = 210
Const PAGE_HEIGHT As Integer = 297
Using gdPicturePDF As New GdPicturePDF
gdPicturePDF.LoadFromFile("c:\input.pdf", False)
gdPicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter)
Dim pageCount As Integer = gdPicturePDF.GetPageCount
For i As Integer = 1 To pageCount
gdPicturePDF.SelectPage(i)
gdPicturePDF.NewPage(PAGE_WIDTH, PAGE_HEIGHT)
gdPicturePDF.SelectPage(pageCount + 1)
gdPicturePDF.DrawPage(gdPicturePDF, i, 0, 0, PAGE_WIDTH, PAGE_HEIGHT)
gdPicturePDF.DeletePage(i)
gdPicturePDF.MovePage(pageCount, i)
Next
gdPicturePDF.SaveToFile("c:\output.pdf", True)
End Using
Kind regards,
Loïc
Re: Resize PDF
Thanks so much for your help, Loic!
Re: Resize PDF
You're welcome
By the way, there is now and even more easier way to do it:
using VB.NET
or C#
By the way, there is now and even more easier way to do it:
using VB.NET
Code: Select all
Const PAGE_WIDTH As Integer = 210
Const PAGE_HEIGHT As Integer = 297
Using gdPicturePDF As New GdPicturePDF
gdPicturePDF.LoadFromFile("c:\input.pdf", False)
gdPicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter)
Dim pageCount As Integer = gdPicturePDF.GetPageCount
For i As Integer = 1 To pageCount
gdPicturePDF.SelectPage(i)
gdPicturePDF.ResizePage(PAGE_WIDTH, PAGE_HEIGHT)
Next
gdPicturePDF.SaveToFile("c:\output.pdf", True)
End Using
Code: Select all
const int PAGE_WIDTH = 210;
const int PAGE_HEIGHT = 297;
using (GdPicturePDF gdPicturePDF = new GdPicturePDF())
{
gdPicturePDF.LoadFromFile("c:\\input.pdf", false);
gdPicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter);
int pageCount = gdPicturePDF.GetPageCount;
for (int i = 1; i <= pageCount; i++) {
gdPicturePDF.SelectPage(i);
gdPicturePDF.ResizePage(PAGE_WIDTH, PAGE_HEIGHT);
}
gdPicturePDF.SaveToFile("c:\\output.pdf", true);
}
Who is online
Users browsing this forum: No registered users and 1 guest