Free Support Forum - aspose.com

PDF to HTML using Aspose.PDF for Java- Issue related to fitting HTML content to page

I am using the Aspose library to convert PDF to HTML. But after conversion, I am facing a page fitting issue. On browser HTML file shows a white area on the right side. Does anyone have an idea of how to solve this issue?

    doc.setFitWindow(true);
            doc.getPageInfo().setLandscape(true);
            // Instantiate HTML Save options object
            HtmlSaveOptions newOptions = new HtmlSaveOptions();
            // Enable option to embed all resources inside the HTML
            newOptions.PartsEmbeddingMode = HtmlSaveOptions.PartsEmbeddingModes.EmbedAllIntoHtml;
            newOptions.LettersPositioningMethod = LettersPositioningMethods.UseEmUnitsAndCompensationOfRoundingErrorsInCss;
            newOptions.RasterImagesSavingMode = HtmlSaveOptions.RasterImagesSavingModes.AsEmbeddedPartsOfPngPageBackground;
            newOptions.FontSavingMode = HtmlSaveOptions.FontSavingModes.SaveInAllFormats;
            newOptions.setConvertMarkedContentToLayers(true);
            // Output file path
            String outHtmlFileName = new StringBuilder(source.getName().replaceAll(Constant.PDF_EXTENSION, "")).append(Constant.DASH).append(System.currentTimeMillis()).append(Constant.HTML_EXTENSION).toString();
            String outFileName = new StringBuilder(targetDirectory).append(Constant.SLASH).append(outHtmlFileName).toString();
            // Save the output file
            doc.save(outFileName, newOptions);

I have tried newOptions.setFixedLayout(false) but no luck. Please find attached PDF and screenshot after converting PDF to HTML.

OriginalPDF.pdf (1.8 MB)
Screenshot 2021-04-06 at 2.56.29 PM.png (776.2 KB)

@mamale

It seems to be a limitation with API rendering. A ticket with ID PDFJAVA-40349 has been created to further investigate and resolve the issue. This thread has been linked with the issue so that you may be notified once the issue will be fixed