How to convert A4 to A3 PDF using C# and VB.NET?
Syncfusion Essential PDF is a .NET PDF library used to create, read, and edit PDF documents. Using this library, you can convert A4 size PDF to A3 size PDF document using C# and VB.NET.
Steps to convert A4 size PDF to A3 size PDF programmatically:
- Create a new C# Windows Forms application project.
- Install the Syncfusion.Pdf.WinForms NuGet package as reference to your .NET Framework application from NuGet.org.
- Include the following namespaces in the Form1.Designer.cs file.
C#
using Syncfusion.Pdf; using Syncfusion.Pdf.Parsing; using Syncfusion.Pdf.Graphics; using System.Drawing;
VB.NET
Imports Syncfusion.Pdf Imports Syncfusion.Pdf.Parsing Imports Syncfusion.Pdf.Graphics Imports System.Drawing
- Use the following code snippet to convert A4 size PDF to A3 size PDF.
C#
//Load a PDF document PdfLoadedDocument ldoc = new PdfLoadedDocument("input.pdf"); //Create a new instance of PdfDocument class PdfDocument document = new PdfDocument(); //Set page margin value as 0 document.PageSettings.Margins.All = 0; //Set page size as A3 document.PageSettings.Size = PdfPageSize.A3; for (int i = 0; i < ldoc.Pages.Count; i++) { //Get loaded page as template PdfTemplate template = ldoc.Pages[i].CreateTemplate(); //Create new page PdfPage page = document.Pages.Add(); //Create Pdf graphics for the page PdfGraphics g = page.Graphics; //Draw template with the size as page size g.DrawPdfTemplate(template, new PointF(0, 0), new SizeF(page.GetClientSize().Width, page.GetClientSize().Height)); } //Save and Close the document document.Save("A3SizePDF.pdf"); document.Close(true);
VB.NET
'Load a PDF document Dim ldoc As PdfLoadedDocument = New PdfLoadedDocument("input.pdf") 'Create a new instance of PdfDocument class Dim document As PdfDocument = New PdfDocument() 'Set page margin value as 0 document.PageSettings.Margins.All = 0 'Set page size as A3 document.PageSettings.Size = PdfPageSize.A3 For i = 0 To ldoc.Pages.Count - 1 'Get loaded page as template Dim template As PdfTemplate = ldoc.Pages.Item(i).CreateTemplate() 'Create new page Dim page As PdfPage = document.Pages.Add() 'Create Pdf graphics for the page Dim g As PdfGraphics = page.Graphics 'Draw template with the size as page size g.DrawPdfTemplate(template, New PointF(0, 0), New SizeF(page.GetClientSize().Width, page.GetClientSize().Height)) Next 'Save and Close the document document.Save("A3SizePDF.pdf") document.Close(True) 'Close the Loaded PDF document ldoc.Close(True)
A complete working sample can be downloaded from ConvertA4ToA3PDF.zip.
By executing the program, you will get the PDF document as follows.
Take a moment to peruse the documentation for working with document, where you will find other options like page rotation, orientation, and transition in the PDF document.
Refer here to explore the rich set of Syncfusion Essential PDF features.
An online sample link to adding pages with different settings such as rotation, orientation, page size and transition.
Note:
Starting with v16.2.0.x, if you reference Syncfusion® assemblies from the trial setup or the NuGet feed, include a license key in your projects. Refer to the link to learn about generating and registering the Syncfusion® license key in your application to use the components without a trial message.
Conclusion:
I hope you enjoyed learning about how to convert A4 to A3 PDF using C# and VB.NET.
You can refer to our Flutter PDF feature tour page to learn about its other groundbreaking features and documentation, and how to quickly get started with configuration specifications. You can also explore our Flutter PDF Flutter PDF examples to understand how to create and manipulate data.
For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion®, you can try our 30-day free trial to explore our other controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums or feedback portal. We are always happy to assist you!