We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Text is displaced when converting a DOCX to PDF

Hello,

i attached a DOCX and the output PDF.
On page 4 the text is displaced.

1) Januar 2022.docx (845.0 KB)
1) Januar 2022.pdf (889.4 KB)

Kind regards,
Andy

@AStelzner As I can see the content is also displaced in the source DOCX document.

Could you please confirm you see the same problem in MS Word on your side?

Hello,

no, see my screenshots.

In the Word.png, the impresssum is correct (footer) and in the PDF.png the impressum (marked with a red border) is in the middle of the text.

Also „Bücherei Buxheim“ and „HvO Buxheim“ is displaced.

Kind Regards,

Andy

dfX3_fdc7b91e-6c57-4128-92c2-5b9fbad02274.png (1.42 KB)

QR8c341bc8-75b7-4e2c-99c3-2d2ba4031ede.png (458 Bytes)

PDF.png (351 KB)

Word.jpg (139 KB)

@AStelzner The problem occurs because of hyphenation. You can register a hyphenation dictionary using Hyphenation.RegisterDictionary method. In your case You should register dictionary for de-DE. See the following code:

Document doc = new Document(@"C:\Temp\in.docx");

// Register an German hyphenation dictionary by stream.
Stream dictionaryStream = new FileStream(@"C:\Temp\hyph_de_CH.dic", FileMode.Open);
Hyphenation.RegisterDictionary("de-DE", dictionaryStream);

doc.Save(@"C:\Temp\out.pdf");

I have used the dictionary from our examples: hyph_de_CH.zip (23.1 KB)

Hi again :slight_smile:

One last question, where can i get other dictionaries for hypenation?

Kind regards,
Andy

@AStelzner You can get dictionaries from here.

Ok, thanks :slight_smile:

However, I am a little confused because if I register all the DE dictionaries (de_AT, de_CH and de_DE) the text is shifted. If I register ONLY the de_CH dictionary, it works. But the text is German, so actually de_DE. How does such behaviour come about?

Is it necessary to register all DE Dictionaries?

Kind regards,
Andy

@AStelzner You can register multiple dictionaries for different languages if it is required. Please see the following article to lean more about hyphenation feature


In your sample document text is German, so it is required to register only German dictionary, like this:
Stream dictionaryStream = new FileStream(@"C:\Temp\hyph_de_DE.dic", FileMode.Open);
Hyphenation.RegisterDictionary("de-DE", dictionaryStream);

That’s the problem. If I register only the hyph_de_DE.dic file with the language de-DE (your sample code), the problem will come up again!

@AStelzner On my side hyph_de_DE.dic works properly. Here is the dictionary I have used hyph_de_DE.zip (267.0 KB)
By the way it is the same as hyph_de_CH.dic, the only difference in the dictionary description.