Issue with docx to pdf conversion and line breaking and coming to next page

Hi,

We are trying to convert from word to pdf using below code snippet, but either font is getting change and lines are also breaking and coming to next page that cause a major issue.

We have recently moved to Kubernetes, is this issue is related to kubernates?

public static void convertDocxToPdf() throws Exception {
        OutputStream outputStream = null;
        OutputStream fileOutputStream = new FileOutputStream(new File("C:\\Work\\font-issue\\check_font_issue.pdf"));
        try {
        	File initialFile = new File("C:\\Work\\font-issue\\check_font_issue.docx");
            InputStream inputStream = FileUtils.openInputStream(initialFile);
            long startAPITime = System.currentTimeMillis();
            outputStream = new ByteArrayOutputStream();
            Document returnFile = new Document(inputStream);
//            returnFile = saveDocxFile(returnFile);
//            returnFile.acceptAllRevisions();

            NodeCollection comments = returnFile.getChildNodes(NodeType.COMMENT, true);
            // Remove all comments.
            comments.clear();

//            if (File.pathSeparator.equalsIgnoreCase(":")) {
                FontSettings fontSettings = new FontSettings();
                fontSettings.setFontsFolder("C:\\Work\\font-issue\\Fonts", true);
                returnFile.setFontSettings(fontSettings);
                PdfSaveOptions opt = new PdfSaveOptions();
                opt.setExportDocumentStructure(true);
                opt.setSaveFormat(SaveFormat.PDF);
                opt.setMemoryOptimization(true); // will increase time
                returnFile.save(outputStream, opt);
            byte[] fileByteArray = ((ByteArrayOutputStream) outputStream).toByteArray();
            fileOutputStream.write(fileByteArray);
            long endAPITime = System.currentTimeMillis();
        } catch (Exception e) {
            throw e;
        } finally {
            if (outputStream != null)
                outputStream.close();
            if (fileOutputStream != null)
                fileOutputStream.close();
        }

    }

Please verify and let us know if anything required from our side.

@rabinintig Could you please attach your input and output documents here for testing? We will check the issue and provide you more information.

Hi,

I have attached input and output documents. changes are highlighted in the pdf document.

Input document.docx (244.5 KB)
Output Document.pdf (2.6 MB)

@rabinintig Thank you for additional information. The problem occurs because fonts used in your document are not available in the environment where the document is processed. The fonts are required to build document layout. If Aspose.Words cannot find the font used in the document, the font is substituted . This might lead into fonts mismatch and document layout due to the different fonts metrics. You can implement IWarningCallback to get notifications when font substitution is performed.
Please see our documentation to learn where Aspose.Words looks for fonts:
https://docs.aspose.com/words/java/specifying-truetype-fonts-location/

Is it possible to provide us all supported fonts that we can insert to environment.
Also kindly provide steps to incorporate font issue to docker container , is there any specific font need to install while creating image?

@rabinintig There is no list of supported fonts. Aspose.Words uses the font available in the specified font sources. Please see our documentation to learn where Aspose.Words looks for fonts:
https://docs.aspose.com/words/java/specifying-truetype-fonts-location/
Also, see the following article to learn about font support by Aspose.Words:
https://docs.aspose.com/words/net/manipulating-and-substitution-truetype-fonts/#differences-in-processing-of-font-formats-in-asposewords-and-microsoft-word
Also, this article might be useful for you:
https://docs.aspose.com/words/net/installing-truetype-fonts-on-linux/