Alignment and font issues in the generated PDF

We have a docx file in which Arial MT, Times New Roman fonts are used but upon conversion to pdf we see the following issues :

  1. everything is coming in Arial font and not Arial MT
  2. The header has correct font but it has additional “Itallic” style applied to it.

All the used fonts are provided during conversion.
We are using Groupdocs.Conversion for java 25.3 version on a linux machine.

Attaching the docx and pdf files for your reference.
testSEFE03.docx (1.2 MB)

testSEFE03.pdf (1.6 MB)

@kswati2206

To address the font issues you’re experiencing during the conversion of your DOCX file to PDF using GroupDocs.Conversion for Java, you can utilize font substitution options to ensure that the correct fonts are applied. Here’s how you can specify font substitutions in your conversion process:

  1. Disable Auto Font Substitution: Set the AutoFontSubstitution property to false to prevent the library from automatically substituting fonts.

  2. Specify Default Font and Font Substitutes: You can define a default font and create a list of font substitutes to map the fonts used in your DOCX file to the desired fonts in the PDF output.

Here’s a sample code snippet demonstrating how to implement these options:

import com.groupdocs.conversion.Converter;
import com.groupdocs.conversion.contracts.FontSubstitute;
import com.groupdocs.conversion.options.convert.PdfConvertOptions;
import com.groupdocs.conversion.options.load.WordProcessingLoadOptions;

import java.util.ArrayList;
import java.util.List;

public class ConvertDocxToPdf {
    public static void main(String[] args) {
        String sourceFilePath = "path/to/your/testSEFE03.docx";
        String outputFilePath = "path/to/output/testSEFE03.pdf";

        // Create load options with font substitution
        WordProcessingLoadOptions loadOptions = new WordProcessingLoadOptions();
        loadOptions.setAutoFontSubstitution(false);
        loadOptions.setDefaultFont("Arial"); // Set a default font if needed

        List<FontSubstitute> fontSubstitutes = new ArrayList<>();
        fontSubstitutes.add(FontSubstitute.create("Arial MT", "Arial")); // Map Arial MT to Arial
        fontSubstitutes.add(FontSubstitute.create("Times New Roman", "Times New Roman")); // Ensure Times New Roman is used

        loadOptions.setFontSubstitutes(fontSubstitutes);

        // Initialize the converter
        try (Converter converter = new Converter(sourceFilePath, () -> loadOptions)) {
            PdfConvertOptions options = new PdfConvertOptions();
            converter.convert(outputFilePath, options);
            System.out.println("Conversion completed successfully.");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

Key Points:

  • Font Substitution: This code maps “Arial MT” to “Arial” to ensure that the correct font is used in the PDF. You can adjust the mappings based on your specific needs.
  • Italics Issue: If the header is still appearing in italics, ensure that the styles in your DOCX file are correctly set and that the conversion options are not altering them.

Make sure to replace the file paths with the actual paths of your DOCX and desired output PDF files. This approach should help resolve the font issues you are encountering during the conversion process.

If you continue to experience problems, consider checking the documentation for any additional settings that may affect font rendering in your specific environment.

Sources:
[1]: Convert WordProcessing Document to PDF with Font Substitution

Attaching the screenshot of the issue
image.jpg (91.2 KB)

I checked in the docx file and the fonts are correct.

Hello @kswati2206 ,

Thank you for contacting us.

We have investigated your scenario and would like to clarify a few points on your side.
Could you please let us know how you are using Windows fonts during the conversion process?
Have you installed them locally, or are you simply trying to add the required fonts using the ConverterSettings.setFontDirectories() method?

To avoid font-related issues during conversion, we strongly recommend installing Windows fonts locally.
As a reference, you can check this documentation for more details.

This step is important because when you attempt to add fonts individually via the setFontDirectories() property and then view the converted document locally, your viewer (e.g., Adobe Reader) may not correctly render the font names.
In most cases, the viewer relies on locally installed fonts, and if (as in your case) the font Arial is installed locally while you try to add ArialMT via setFontDirectories(), the viewer will display the font name simply as Arial.

We have also tested the scenario on our side using GroupDocs.Conversion 25.5, and the converted document appears identical to the original.
We’ve attached the output and a screenshot — please try downloading it and verify it on your end.
output_docker_withFonts.pdf (1.7 MB)

Screenshot_1.png (103.4 KB)

We are providing the fonts using the SetFontDirectory option and have the following set of fonts for this Org, could you please try reproducing this issue by providing all of these?

Arial_fonts.zip (2.2 MB)

Fonts_others.zip (2.0 MB)

@kswati2206 ,

Indeed, there is an issue with the style of the Times New Roman font you are attempting to pass via the setFontDirectories() parameter (Screenshot_2.png (106.7 KB)).
However, we added the required fonts on our side, and the result matches the original document.

Please try adding those fonts as well (TNR.zip (2.2 MB)).

Regarding the Arial MT font — as you can see in the Screenshot_2.png, it is present in the document and its name is displayed correctly.

As far as we understand, you are viewing the result on macOS, while the conversion itself is performed on Linux.

In this case, we recommend that you always check two things when viewing the document in Adobe Reader on macOS:

  1. Use the Ctrl + D shortcut in Adobe Reader to inspect the fonts embedded in the document. (Screenshot_3.png (90.9 KB))
  2. If Adobe Reader displays a different font name or style (which often happens with Windows fonts), double-check whether the font is available in the dropdown list, as shown in the attached screenshot (Screenshot_4.png (100.2 KB)).

It’s possible that the font is correctly embedded in the document, but Adobe Reader renders it incorrectly due to how it handles font substitution or style mapping on macOS.

After using the Times New Roman font provided by you the Itallic issue is resolved but the two column layout is breaking now. It could be related to font files.
I will check other font files too if there could be any issues with them.

@kswati2206 ,

If you have any further questions, please don’t hesitate to contact us.

Hi @evgen.efimov I tried your suggestion and checked all other font files as well. There are still some style and alignment issues that i could see.

  1. The font is coming as Arial (like you mentioned it might be because of viewing on MAC), but the style should match correctly. I see the Italics being applied to the paragraphs which are of Normal variants.
  2. The two column layout is not holding up post conversion.

Attaching the docx and PDF files for your review.
TestMicroNHHAlignment (1).pdf (1.7 MB)

TestMicroNHHAlignment_test_2025613_174356 (1).docx (1.6 MB)

Screenshot of the Arial with italic style:
Screenshot 2025-06-16 at 2.53.32 PM.jpg (137.7 KB)

Screenshot of two column layout breaking and Dejavu Sans font getting applied instead of Arial/ArialMT
Screenshot 2025-06-16 at 2.55.33 PM.jpg (143.6 KB)

Hello @kswati2206

Thank you for contacting us.
We have investigated your resulting PDF file and found that the DejaVu Sans font was applied to the document instead of Arial. As you can see in the Screenshot_1.png (195.5 KB), the Arial font was not embedded into the document.

We also performed a conversion using the latest version of GroupDocs.Conversion 25.5.1 and generated the attached file (outputWithUserFonts.pdf (1.7 MB)), in which none of the previously mentioned issues were observed.

Please try performing the conversion on your side using the provided fonts (font.zip) and share the results with us.

Additionally, we would like to give a quick tip regarding the inclusion of required fonts during conversion.
If you open your .docx file as a ZIP archive, you will find the fontTable.xml file, which lists all fonts used in the document (note: this list may sometimes include unused fonts due to past editing).

Since each font has multiple styles, we recommend always including the full font family when specifying fonts using the setFontDirectories() method.

As you can see in fonts.zip, the full Arial and Arial MT font families are included, which allowed us to avoid the issues you reported.

I did a quick check of the generated PDF which you had shared and this does not have the two column layout issue, but still the style is getting changed to italics.
Please Refer to this screenshot attached.
Screenshot 2025-06-16 at 7.31.48 PM.jpg (85.2 KB)

Meanwhile i will try to generate the pdf by adding the fonts provided by you in the latest version and let you know the results.
Thanks.

@kswati2206 ,

Based on your screenshot, it appears that Arial MT is likely not installed on your system, and the viewer is displaying it as regular Arial.

Regarding the italic style issue: when viewing the document in Microsoft Word, it may seem that the font is not italicized. However, if you compare the actual text in both documents, you will notice that the text content, positioning, and slant fully match the original.

Even if you try to manually change the font style in the .docx file (e.g., switch to Bold), you will immediately notice that the slant of the text changes, confirming that the original had an italic effect.

Additionally, if you save your .docx file using Microsoft Word, the font for that paragraph changes to Arial MT Extra Bold. Meanwhile, when using GroupDocs.Conversion, the resulting text remains consistent with the original formatting.
Screenshot_2.png (315.9 KB)

Hi @evgen.efimov I don’t see your point. The two paragraphs are completely having different styles.
Screenshot 2025-06-16 at 9.33.06 PM.jpg (227.5 KB)

I also tried applying bold font into docx file but still the style does not seems to be italic in any way.
Screenshot 2025-06-16 at 9.36.56 PM.jpg (224.8 KB)

Also, I do have Arial MT Fonts installed in my system, So, that should not be a problem.
Screenshot 2025-06-16 at 9.40.00 PM.png (363.7 KB)

I hope you see the issue is very clear here.
Example : Lets take the text content “The Willow House, 26A, 122, Oak Lane” from the docx file, when i see the document.xml it has the folllowing run tag
Screenshot 2025-06-16 at 9.50.11 PM.jpg (166.2 KB)

<w:r w:rsidRPr=“005C3502”><w:rPr><w:rFonts w:ascii=“Arial MT” w:eastAsia=“Calibri” w:hAnsi=“Arial MT” w:cs=“Calibri”/><w:sz w:val=“18”/><w:szCs w:val=“18”/></w:rPr><w:t xml:space=“preserve”>The Willow House, 26A, 122, Oak Lane,</w:t></w:r>

If it were in italics, we would have seen the <w:i> tag along with <w:rpr>
Please do let me know if any more details required from our end.

I did not get time to check this with the latest version yet, will share my findings by tomorrow.

Thanks
Swati

@kswati2206 ,

If you don’t mind, could you please share the list of Arial MT font variants installed on your system?

I’ve recently removed all existing Arial MT fonts and reinstalled only Arial MT Regular. As a result, the font in Word is no longer rendered in italic for me, and now it looks identical to what I see in your screenshots.

It seems that my system previously had overlapping or conflicting styles, which caused the text in both the .docx and the resulting .pdf to appear italicized.

Thank you in advance!

I have already shared that in the above comment. Kindly check the screenshot Screenshot 2025-06-16 at 9.40.00 PM.png

Regarding this point, we cant ask customers to not provide Italics font as they are using this style for other word documents.

Hello @kswati2206 ,

I saw the list of the Arial MT font family that you previously shared, but my goal is to exactly reproduce the same setup on my side — using only the fonts that are installed on your system.

If you’re unable to share those font files directly, that’s completely fine — I’ll try to recreate the environment myself.

I’ll get back to you as soon as I have any updates.

@kswati2206 ,

After additional investigation, we found that when both the Arial and Arial MT font families are provided via the setFontDirectories() property during conversion, text using the Arial MT font is rendered in italic style.

We’ve created a separate issue (ID: CONVERSIONJAVA-2908) to investigate this behavior in more detail.

As a workaround, you can use the ttf_fonts.zip (3.3 MB) package that contains only the fonts required for conversion — without Arial MT. In this case, the Arial MT font will be replaced with Arial. Since these fonts are visually indistinguishable, this might serve as a temporary solution if acceptable in your case.

We’ll keep you informed as we make progress.

Thanks for the prompt update.
Let me share this workaround with our customer.