Do you have problem on converting HTML to PDF with certain page size before? For many reasons, we need a certain page size for PDF document while converting it from an online HTML page and HTML raw string. For example, to meet the requirement of your client or saving paper sometimes, you may need to scale the PDF size or save PDF page size in different dimension. However, it is usually not an easy task for people doing it perfectly. Actually, you can make it easily and quickly if you use the proper tool to do so.

XsPDF .NET HTML to PDF SDK helps you easily change the page size of your PDF while creating PDF from HTML in C#. It allows you to use the standard page size, including but not limited to Series A (A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10) which is used for Standard Printing and Stationery, and the Series B (B0, B1, B2, B3, B4, B5, B6, B7, B8, B9, B10) which is used for Posters, Wall-Charts etc. Certainly, you can directly set a certain dimension to output the PDF document in your C# programming project.

Convert HTML to PDF with Certain Page Size

In case you may want to have a quick evaluation on this function of our HTML to PDF converter, we provide C# class code as below. You can directly copy it to your C# project.

string html = @"sample.html";
string savePath = "sample.pdf";

// Create a Html converter instance 
HtmlToPdfConverter converter = new HtmlToPdfConverter();

// Set output PDF size, the most commonly used is A4
// and you can also set the customized size you wanted, like B4 or Letter
converter.PageSize = PageSize.A4;
// Convert html to PDF
converter.ConvertFromFile(html, savePath);

Notice - If you use the free trial version of .NET HTML to PDF SDK, there is a statement in PDF page footer, "This is an XsPDF trial version"