Email headers uneven

We are using a combination of email-java and words-java to convert an email to PDF. We had a working version, but it did not handle Asian character sets.

We added a font source:

LoadOptions options = new LoadOptions();
  options.setLoadFormat(loadFormat);
  FolderFontSource intradynFontSource =
             new FolderFontSource("/vault/compliancevault/cv/emails/export/webcore/fonts",
                                  true);
  try {
      Document pdf = new Document(is, options);
      pdf.setFontSettings(new FontSettings());
      pdf.getFontSettings().
                setFontsSources(new FontSourceBase[]{intradynFontSource});
      pdf.save(dest, SaveFormat.PDF);
  }

It handled the text, but the headers got out of line:

Screenshot from 2021-09-23 17-22-25.png (28.6 KB)

This happens for all email, whether they contain odd characters or not.

Excuse me, wrong screen shot:
Screenshot from 2022-01-13 18-33-46.png (16.0 KB)

@intradyn Could you please attach a sample input and output files here for testing? We will check the issue and provide you more information.

https://app.box.com/s/sh6a945qobojueq81n8s2x4689278pop

The link above will be valid for 24 hours. Please download within that time.

@intradyn Thank you for additional information. The problem occurs because the fonts in your document are substituted with Baekmuk Gulim font. And size of whitespace is different in this font. If implement IWarningCallback to warn about font substitutions, I see the following warnings on my side:

Font 'Calibri' has not been found. Using 'Baekmuk Gulim' font instead. Reason: first available font.
Font 'MS Mincho' has not been found. Using 'Baekmuk Gulim' font instead. Reason: first available font.
Font 'PMingLiU' has not been found. Using 'Baekmuk Gulim' font instead. Reason: first available font.
Font 'SimSun' has not been found. Using 'Baekmuk Gulim' font instead. Reason: first available font.
Font 'MS Gothic' has not been found. Using 'Baekmuk Gulim' font instead. Reason: first available font.
Font 'Microsoft JhengHei' has not been found. Using 'Baekmuk Gulim' font instead. Reason: first available font.
Font 'Times New Roman' has not been found. Using 'Baekmuk Gulim' font instead. Reason: first available font.
Font 'Georgia' has not been found. Using 'Baekmuk Gulim' font instead. Reason: first available font.

If also specify SystemFontSource (on Windows), the rendered document look as expected:

pdf.getFontSettings().setFontsSources(new FontSourceBase[]{new SystemFontSource(), intradynFontSource});

Thank you for your response.

Unfortunately, that solution does not wok on Linux.

Blockquote
pdf.getFontSettings().
setFontsSources(new FontSourceBase[]{new SystemFontSource(),intradynFontSource});

Blockquote

Screenshot from 2022-01-17 11-45-55.png (16.4 KB)

@intradyn On Linux you have to put the required fonts into the folder and specify this folder as font source or install the required fonts.
SystemFontSource uses fonts installed in the system, and set of fonts on Linux and Widows is different. To get the same rendering result on Linux and Windows the same set of fonts must be available in both environments.

I am not trying to get the same rendering in Windows and Linux, I’m just trying to get ANY rendering on Linux. I have added your change and the Asian characters are not shown.

It would be one thing if the space issue still showed. But it fails to show any of the Chinese characters.

When I display the reasons I get:

Blockquote
Font ‘sans-serif’ has not been found. Using ‘Bitstream Vera Sans’ font instead. Reason: first available font.
Font ‘MS Mincho’ has not been found. Using ‘Bitstream Vera Sans’ font instead. Reason: first available font.
Font ‘SimSun’ has not been found. Using ‘Bitstream Vera Sans’ font instead. Reason: first available font.
Font ‘MS Gothic’ has not been found. Using ‘Bitstream Vera Sans’ font instead. Reason: first available font.
Font ‘Arial’ has not been found. Using ‘Bitstream Vera Sans’ font instead. Reason: first available font.
Font ‘Times New Roman’ has not been found. Using ‘Bitstream Vera Sans’ font instead. Reason: first available font.

Blockquote

How do I make it choose anything BUT the first available choice?

@intradyn The first available font is a penultimate substitution rule used by Aspose.Words when other substitution rules fail. You can configure substitution rules according to the available fonts.