Free Support Forum - aspose.com

Aspose HTML to PDF - Convert big html file to multi-page pdf using Aspose.PDF for .NET

Hello,

i’m using aspose.pdf to convert html files to pdf files.

    public int AsposeHtmlConvertToPdf(string inputFile, string outputFile)
    {
        int ret = 0;
        try
        {
            // Initialize HTMLLoadSave Options
            Aspose.Pdf.HtmlLoadOptions options = new Aspose.Pdf.HtmlLoadOptions();
            // Set Render to single page property
            //options.IsRenderToSinglePage = true;
            // Load document
            Aspose.Pdf.Document doc = new Aspose.Pdf.Document(inputFile, options);
            // Save
            doc.Save(outputFile);
        }
        catch
        {
            ret = -1;
        }
        return ret;
    }

Regardless of the “IsRenderToSinglePage” option, my final pdf is one page. I would like to be able to render the widht but if my html file is big, to break the final pdf to a multi-page file. (not different files)

Thank you!

@panosk

Could you please share a sample HTML file along with expected output PDF document. We will test the scenario in our environment and share our feedback with you accordingly.

Desktop.zip (753.3 KB)

Here you are!

@panosk

The PDF file which was in shared Archive seems to be generated with Aspose.PDF. Would you kindly share (as requested earlier) an expected output PDF document which you want to generate using the API and apparently you are unable to. We will try to generate it at our end and share our feedback with you accordingly.

I cannot provide an expected pdf because i can’t know what options i have regarding breaking my output pdf to pages. I would like to know if this option is available and what options do we have and we will decide how we will set it up according to our client needs.

@panosk

In case you want to break pages inside output PDF during conversion from HTML. You can specify following CSS property in your HTML content that will cause a page break:

page-break-before: always;

Please let us know in case you have further requirements or our feedback is not according to what you actual require.