HTML to PDF - Lower half getting cut

I have a html file which is basically a tabular report , it can easily go into multiple pages. I have observed that the lower half gets cut when the content of the table increases.

How to remediate it . I am using the below code for this.

        var options = new ImageSaveOptions
        {
            SmoothingMode = SmoothingMode.Default,
            HorizontalResolution = 100,
            VerticalResolution = 100,
            BackgroundColor = Color.White,
        };

        int PageWidth = 1000, PageHeight = 1000;

        options.PageSetup.AnyPage = new Page(new Aspose.Html.Drawing.Size(PageWidth, PageHeight));

//result is the variable which holds the html content.
var document = new Aspose.Html.HTMLDocument(result, “.”);
Aspose.Html.Converters.Converter.ConvertHTML(document, options, streamProvider);

@frendz

Would you kindly share your sample HTML in .zip format with us? We will test the scenario in our environment and address it accordingly.

AsposeIssue.zip (63.1 KB)

i have added the html file and the resulting pdf what i am getting. kindly let me know in case of any other information

@frendz

Looks like the resulting PDF is generated using Aspose.Words. Can you please share the complete sample code snippet that we can use to replicate the same issue in our environment that you are facing?

code.zip (1.1 KB)
I have attached the relevant piece of code which does the conversion from HTML to PDf.

@frendz

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): HTMLNET-4682

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

Where can I view the status of this issue HTMLNET-4682?

@frendz

The logged ticket has been investigated and resolved. You can see its status at the bottom of this thread. We will be sharing its details with you shortly.

@frendz

In the example, only the first of the streams is processed, so the result is only the first page : var memory = streamProvider.Streams.First();

In the case of multi-page documents, each page will be placed in a separate stream. Therefore, it is necessary to process them all.

var page = 0;
foreach(var memory in streamProvider.Streams)
{
    memory.Seek(0, System.IO.SeekOrigin.Begin);

    // Flush the result data to the output file
    using (System.IO.FileStream fs = System.IO.File.Create("output_" + page  +".jpg"))
    {
         memory.CopyTo(fs);
    }
    page++;
}

htmlnet-4642.PNG (54.9 KB)

1 Like

Thanks Asad, the issue looks to be resolved by this, but I am seeing quite a bit of white space . Am i missing something in the page size/configurations?
image.png (27.2 KB)

@frendz

The ticket information has been updated as per your feedback. We will investigate it and let you know soon. Please spare us some time.

Hi @asad.ali ,

Kindly let me know if there is any update on this.

@frendz

An white space appears due to the insertion of an image into a Aspose.Words.Document. If you use the conversion directly to PDF, then there is no such problem:

var pdfOptions = new PdfSaveOptions()
{
    HorizontalResolution = 100,
    VerticalResolution = 100,
     BackgroundColor = System.Drawing.Color.White,
};

var document = new Aspose.Html.HTMLDocument("StageSheet.html",new Aspose.Html.Configuration());
Aspose.Html.Converters.Converter.ConvertHTML(document, pdfOptions, streamProvider);

// Get access to the memory stream that contains the result data
using (var memory = streamProvider.Streams.First())
{
    memory.Seek(0, System.IO.SeekOrigin.Begin);

    // Flush the result data to the output file
    using (System.IO.FileStream fs = System.IO.File.Create("output.pdf"))
    {
        memory.CopyTo(fs);
    }
}

To clarify the options of the Word document, it is better to post in Aspose.Words forum.