We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Issue in Convert HTML to PDF - Width expands to unusual size

Hi Support,

Im using your latest Aspose.pdf (18.8) Eval. version to Convert the HTML to PDF.
While converting, the PDF Width is expands to the Max size (49.42in) (Normal size 8.26in Width).
Please see the attached pdf and Source code, HTML content in zip.
Please let us know the solution to fix this issue.AsposePDFTestApp.zip (955.6 KB)

Notes-030920181853.pdf (884.0 KB)

// Convert HTML to PDF
public bool ConvertNotesHtmlToPdf(byte[] data, string fileName, string appPath)
{

    HtmlFragment htmlHeaderfragment = null;

    if ((data == null) || (data.Length == 0))
        return false;
    using (MemoryStream memStream = new MemoryStream())
    {
        // Write the Body of HTML to PDF
        memStream.Write(data, 0, data.Length);
        memStream.Position = 0;
        HtmlLoadOptions htmlLoadOptions = new HtmlLoadOptions();
        htmlLoadOptions.PageInfo.Margin.Bottom = 30;
        htmlLoadOptions.PageInfo.Margin.Top = 150;
        htmlLoadOptions.PageInfo.Margin.Left = 20;
        htmlLoadOptions.PageInfo.Margin.Right = 20;
        htmlLoadOptions.PageInfo.IsLandscape = false;
        Document doc = new Document(memStream, htmlLoadOptions);

        Aspose.Pdf.HeaderFooter header = new Aspose.Pdf.HeaderFooter();
        Aspose.Pdf.HeaderFooter footer = new Aspose.Pdf.HeaderFooter();

        // Set the Header Content for the PDF
        Header = SetHeader(appPath);
        if (String.IsNullOrEmpty(Header))
            return false;
        htmlHeaderfragment = new HtmlFragment(Header);
        htmlHeaderfragment.HorizontalAlignment = Aspose.Pdf.HorizontalAlignment.Center;
        htmlHeaderfragment.VerticalAlignment = Aspose.Pdf.VerticalAlignment.Top;
        htmlHeaderfragment.Margin.Top = 0;
        header.Margin.Left = 20;
        header.Paragraphs.Add(htmlHeaderfragment);

        // Set the Footer Content for the PDF
        Aspose.Pdf.Text.TextFragment fTxt = new Aspose.Pdf.Text.TextFragment("$p / $P ");
        fTxt.TextState.Font = FontRepository.FindFont("Arial");
        fTxt.TextState.FontSize = 10;
        fTxt.HorizontalAlignment = Aspose.Pdf.HorizontalAlignment.Right;
        footer.Paragraphs.Add(fTxt);

        // Open each page and assign Header and Footer
        foreach (Aspose.Pdf.Page page in doc.Pages)
        {
            page.Header = header;
            page.Footer = footer;
        }

        // Save the PDF
        doc.Save(fileName);

    }
    return true;
}<a class="attachment" href="/uploads/discourse_instance3/18350">AsposePDFTestApp.zip</a> (955.6 KB)

@rajendranb

Thanks for contacting support.

We have tested the scenario in our environment and managed to replicate the issue which you have mentioned. We have also tried by specifying height and width of page as follows but got no success.

htmlLoadOptions.PageInfo.Height = PageSize.A4.Width;
htmlLoadOptions.PageInfo.Width = PageSize.A4.Height; 

We have logged the issue as PDFNET-45332 in our issue tracking system and will investigate it in details. As soon as we have some definite updates to share, we will surely inform you. Please be patient and spare us little time.

We are sorry for the inconvenience.

Hi Support,

Thanks a lot for your reply. could you please tell us the time frame to fix this issue.

Thanks

@rajendranb

Thanks for your inquiry.

As we recently have logged the issue in our issue tracking system, it is pending for investigation. Please note that the issue is logged under free support model and has low priority. It will be investigated and resolved on first come first basis and may take long time to get resolved depending upon the how long is the queue of previously logged issues. We will surely let you know as soon as some significant progress is made toward issue resolution.

You may also check our paid support option where issues are resolved on high priority and blocker/urgent issues are recommended to be reported there. In case your issue is on of the type, you can please check priority support option.

We are sorry for the inconvenience.

Hi Support Team,

Any update on this above said issue. Please let us know.

Thanks

@rajendranb

Thanks for your inquiry.

I regret to share that earlier logged issue is not yet resolved due to other pending issues in the queue. As soon as we have some definite update regarding its resolution, we will let you know. Please spare us little time.

We are sorry for the inconvenience.

Is there an update on this issue? I believe we are also experiencing this issue.

Thanks

@ajivener

Earlier logged issue is not yet resolved due to other high priority issues in the queue. However, as soon as we have some definite updates regarding its resolution, we will surely inform you. Please spare us little time.

We are sorry for the inconvenience.

Is there any update on this issue? We also met this problem while convert html to pdf using Aspose.PDF 21.7

@lucy.hq

We are afraid that the earlier logged ticket could not get resolved due to other pending issue logged prior to it. However, we have updated its information as per your comments and will surely inform you once we make some significant progress towards its resolution. Please spare us some time.

We are sorry for the inconvenience.