Html to PDF Conversion | Small Font Issue


I have converted HTML file to PDF format using Aspose.PDF. Converted PDF file has content with very small font which is unreadable. One of the reasons of this small font issue is that there is some content in HTML which exceeds the normal page size, due to which you can see horizontal scrolling in HTML file. Most probably converter is reducing the font size to adjust the file content according to PDF page size.

I have converted file using this code:

string dataDir = @“F:\Tasks”;
FileStream htmlContentStream = new FileStream(dataDir + “Sample.htm”, FileMode.Open);
HtmlLoadOptions htmlLoadOptions = new HtmlLoadOptions(dataDir);
htmlLoadOptions.PageInfo.IsLandscape = true;
Document pdfDoc = new Document(htmlContentStream,htmlLoadOptions);
pdfDoc.Save(dataDir + “ConvertedSample.pdf”);

Please find the attached folder having HTML and converted PDF file. Kindly suggest me some solution to resolve this conversion issue. If it cannot be fixed then please provide any solution to wrap the content to next page in order to avoid small font problem. (222.9 KB)

Thanks in advance.


Thank you for contacting support.

I would like to share with you that neither the font size is being adjusted, nor the content is becoming unreadable. It appears unreadable just because the converted document is opened with zoom factor around 6%, owing to bigger page size. You can change the zoom factor while converting a document as in the code snippet below. I have attached generated PDF file for your kind reference. Zoom_18.2.pdf

        HtmlLoadOptions options = new HtmlLoadOptions(@"D:\Files\");
        // Load HTML file
        Document doc = new Document(@"D:\Files\Sample.htm", options);

        Aspose.Pdf.Annotations.GoToAction action = new Aspose.Pdf.Annotations.GoToAction(new Aspose.Pdf.Annotations.XYZExplicitDestination(1, 0, 0, .5));
        doc.OpenAction = action;

        // Save HTML file

I hope this will clarify any ambiguity. Please feel free to let us know if you need any further assistance.

Hi Farhan,

Thanks for the support.

I am facing out of memory exception during Aspose html to Pdf conversion using above code shared by you. Can you please suggest some solution.

I have attached one of the problematic html file. (253.1 KB)

Thanks in advance.


Thank you for getting back to us.

I would like to request you to please always create separate topics for separate issues. I have worked with the data shared by you and have been able to notice specified problem. A ticket with ID PDFNET-44342 has been logged in our issue management system for further investigation and resolution. The issue ID has been linked with this thread so that you will receive notification as soon as the issue is resolved.

Moreover, this HTM file is not getting converted to a PDF document with Adobe Acrobat, Foxit Reader, Browser’s printer Microsoft Print to PDF. Please share the generated PDF file, if you are able to convert attached HTM file.

We are sorry for the inconvenience.