Hi Team,
Hi Shanthi,
Thanks for your inquriy. You may set PageInfo Width and Height property to convert HTML to a single Page PDF document as following. However, if later you want to resize the PDF page size then you can use ResizeContents() method of PdfFileEditor class.
HtmlLoadOptions options = new HtmlLoadOptions();
options.PageInfo.Margin.Left = 0;
options.PageInfo.Margin.Right = 0;
options.PageInfo.Margin.Top = 0;
options.PageInfo.Margin.Bottom = 0;
options.PageInfo.Width = 800;
options.PageInfo.Height = 3000;
var pdfDocument = new Aspose.Pdf.Document(@"D:\Downloads\StoFit\stofit.html", options);
/*
// Resize contents of resultant PDF
pdfDocument.ProcessParagraphs();
int[] page_cnt1 = new int[pdfDocument.Pages.Count];
for (int i = 0; i < pdfDocument.Pages.Count; i++)
page_cnt1[i] = i + 1;
PdfFileEditor pfe = new PdfFileEditor();
pfe.ResizeContents(pdfDocument, page_cnt1, PdfFileEditor.ContentsResizeParameters.PageResize(Aspose.Pdf.PageSize.A4.Width, Aspose.Pdf.PageSize.A4.Height));
*/
// Save output as PDF format
pdfDocument.Save(myDir + "stofit.pdf");
Please feel free to contact us for any further assistance.
Best Regards,
How can I be sure of my content height.
Hi Shanthi,
We would like to share with you that you can now convert HTML to Single Page PDF document using Aspose.PDF for .NET. In other words, you can now specify IsRenderToSinglePage property of HtmlLoadOptions Class in order to render HTML content on one page of PDF. Please consider using following code snippet:
HTML to PDF - Render all contents in single page
string outFile = "out.pdf";
HtmlLoadOptions options = new HtmlLoadOptions();
options.IsRenderToSinglePage = true;
Document doc = new Document("HTML/input.htm", options);
doc.Save(outFile);
The issues you have found earlier (filed as PDFNET-41253) have been fixed in Aspose.PDF for .NET 23.3.