0

I want to convert an HTML form to a PDF form using HTML Renderer. I know how to convert an HTML page to PDF using HTML Renderer, but I'm not getting all the pages, it is displaying only first page.

When I open HTML in the browser it is displaying all the content and after transformation to PDF it is showing less content and it's up to only one page.

I have tried and searched for different solutions, but none of them are working for me. Please help me to display all the content in multiple pages.

I have used the following:

PdfDocument pdf2 = PdfGenerator.GeneratePdf(html, PdfSharp.PageSize.Letter);
pdf2.Save(filename);

and tried this

PdfDocument pdf = PdfGenerator.GeneratePdf(htmlContent, PdfSharp.PageSize.A4);

I want to transform XML to PDF and HTML to PDF using either HTML Renderer or aspose libraries only.

tony
  • 1
  • 1

1 Answers1

2

To generate PDF from XML using Aspose.PDF API, you need to create XML based on XML Schema, which can be found in XML folder in Aspose.PDF installation directory or from this link. Now the XML file that follows the schema can be converted to PDF document with BindXML method, as in the code snippet below:

Document doc = new Document();
doc.BindXml(dataDir + "XML_DOM.xml");
doc.Save(dataDir + "XMLtoPDF_out.pdf");

About HTML to PDF conversion, you may use below code snippet to load a HTML file and save it as a PDF document.

HtmlLoadOptions options = new HtmlLoadOptions(dataDir);
Document pdfDocument = new Document(dataDir + "Test.html", options);
pdfDocument.Save(dataDir + "HTMLToPDF_out.pdf");

PS: I work with Aspose as Developer Evangelist.

Farhan Raza
  • 382
  • 1
  • 8
  • :thanks for your response ,for me xml to pdf conversion didn't work , the otput.pdf file is creating as per your code but it is not able to get any data and it is showing as [there was an error opening this document ,because it has no pages] and in case of html2pdf conversion i'm able to get and open the pdf file but still it is not getting full content(upto last)] and also shows [Evaluation Only.Created with Aspose.Pdf.Copyright 2002-2017 Aspose Pty Ltd.Evaluation Only. Created with Aspose.Pdf. Copyright 2002-2017 Aspose Pty Ltd.]how can i remove this heading on every page? – tony May 09 '19 at 07:45
  • You are facing evaluation limitations so you may test the API in its full capacity by applying a free [30-days temporary license](https://purchase.aspose.com/temporary-license). About XML to PDF, your XML file must follow the schema of Aspose.PDF API. Above were some brief details and code snippet for the conversion, where further details and sample files can be found in [documentation](https://docs.aspose.com/display/pdfnet/Create+a+Hello+World+PDF+Document+through+XML+and+XSLT). – Farhan Raza May 10 '19 at 18:22