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


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.

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


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.


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:

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:
Also, see the following article to learn about font support by Aspose.Words:
Also, this article might be useful for you: