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

Free Support Forum - aspose.com

DOCX to PDF conversion issue with Swiss German hyphenation using C#

Given is the following word created in word 365 using swiss german language pack:
image.png (44.4 KB)

I use the following code to convert the word document into a pdf:
I did download the hyphen file from the aspose github repository: https://github.com/aspose-words/Aspose.Words-for-C/blob/7adc093b3734218c46cf2e685b095c0236fb1430/Data/Rendering-Printing/hyph_de_CH.dic

 //Set the hyphen dictionary
          using (var hyphenStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("WordToPdfHyphen.hyph_de_CH.dic"))
        {
            Hyphenation.RegisterDictionary("de-CH", hyphenStream);
        }

        //Load the word document
        Aspose.Words.Document asposeDoc;
        using (Stream stream = new MemoryStream(System.IO.File.ReadAllBytes(@"C:\temp\wordhyphentest.docx")))
        {
            asposeDoc = new Aspose.Words.Document(stream);
        }

        //Save the word as pdf
        var pdfOutput = new MemoryStream();
        asposeDoc.Save(@"c:\temp\pdffromword.pdf", Aspose.Words.SaveFormat.Pdf); 

The following image is a screenshot of the produced pdf.
There are actually hyphens, the the words are separated differently.
image.png (62.2 KB)

Question: Is there any current hyphen file which does produce the same output as word?

@manuelk

You need to use Swiss German hyphenation dictionary. If you still face problem, please ZIP and attach your input Word document here for testing. We will investigate the issue on our side and provide you more information.

As i wrote initially, i am using the swiss german hyphenation dictionary.
But the produced pdf uses different hyphenation than a pdf created using word.
I’ve attached a sample word document where the hyphen are not the same as the ones created by word.
wordhypen_20200123_124026_it.zip (20.1 KB)

@manuelk

We have logged this problem in our issue tracking system as WORDSNET-19899. You will be notified via this forum thread once this issue is resolved. We apologize for your inconvenience.

If you are using different hyphenation dictionary, please ZIP and attach it here for our reference.

Moreover, please convert your document to PDF using MS Word and share it also. Thanks for your cooperation.

I do not have another hyphenation dictionary. I think if i could get the hyphenation dictionary from office this might solve the problem. But i don’t know where the office hyphenation dictionary is.
I’ve also attached pdf saved using word which is shown exactly as the word document itself on my computer.
wordhypen_20200123_124026_it.pdf (69.5 KB)

@manuelk

Thanks for sharing the PDF file. We will inform you via this forum thread once this issue is resolved.

@manuelk

Thanks for your patience. It is to inform you that the issue which you are facing is actually not a bug in Aspose.Words. So, we have closed this issue (WORDSNET-19899) as ‘Not a Bug’.

Please register the hyphenation dictionary for de-CH locale as shown below.
Hyphenation.RegisterDictionary(“de-CH”, @“d:\hyph_de_CH.dic”);

Additionally, following pattern should be added to hyph_de_CH.dic dictionary.

.disco8vered.

Thanks for your answer.
But i already have other examples which still don’t look the same and my guess is in order to fix them i’d had to enhance the hyphenation file all the time.
Again i think the only tool which has all the correct hyphenation opens is word, and there seems to be no easy way to get it.

@manuelk

You need to register the hyphenation dictionary with all patterns to get the desired output. If you still face any issue while using Aspose.Words, please let us know.