Re: Add hyphenation to PDF

Any news? the problem has been solved now?

I have also the same question in our project.

It looks like Aspose.Words supports hyphenation now, but Aspose.PDF still does not.

We create the Word-document with Aspose.Words and the hyphenation works very fine.

But when we create the PDF-document with Aspose.PDF and the hyphenation is missing.

Hi Xiaofeng,

Thanks for your patience. We have further investigated the requirement of adding hyphenation to existing PDF files and I am afraid we cannot support this feature because addition of hyphenation may corrupt the PDF file. However if you are creating PDF document using Aspose.Pdf for .NET and trying to adding hyphenation, they should appear in resultant file. In case you are facing an issue while adding the hyphenation while using Aspose.Pdf for .NET, can you please share the code snippet so that we can test the scenario at our end. We are sorry for your inconvenience.

Thanks for your prompt response.

please take a look at the attached screen shots. the first one is from a Word file and the second one is from a PDF file. You will notice that the word file has hyphenation but PDF does not.

in the following code snippet, doc is a Aspose.Words.Document object.

we create the PDF document with Aspose.Words.Document.

Word:

using (MemoryStream target = new MemoryStream())
{
    OoxmlSaveOptions opt = new OoxmlSaveOptions(SaveFormat.Docx);
    opt.Compliance = OoxmlCompliance.Iso29500_2008_Transitional;
    doc.Save(target, opt);
    return target.ToArray();
}

PDF:

using (MemoryStream target = new MemoryStream())
{
    doc.Save(target, SaveFormat.Pdf);
    return target.ToArray();
}

Now the problem is that, using the word Memory stream, we could get a word file with hyphenation, but using the pdf Memory stream, we get the pdf file without hyphenation.

Could we solve it now?

Hi Xiaofeng,

Thanks for sharing the details.

As per my understanding, you are using Aspose.Words.Document object to create Word as well as PDF files and hyphenation is missing when saving the output in PDF format. Can you please share the source Word document so that we can test the conversion at our end. We are sorry for your inconvenience.

yes, your understanding is right.

the screen shot in my previous message is from a German version of word.

for your convenience, I attached a English version of word.

please note that “mandated” and “factors” are the hyphenated words in the file.

Hi Xiaofeng,

Thanks for your inquiry. Unfortunately, Aspose.Words does not support automatic hyphenation yet . I have logged this issue in our bug tracking system. The ID of your issue is WORDSNET-9213. Your request has also been linked to this issue and you will be notified as soon as it is resolved. Sorry for the inconvenience.

Best regards,

Since our clients complain about this issue more and more, I am thinking that is there a way to work around this issue now temporarily before WORDSNET-9213 has been fixed?

I mean is there a feature or method to add the hyphenation back after loading the word document to Aspose.Words object and before saving the Aspose.Words object to PDF version.

Hi Xiaofeng,

Thanks for your inquiry.

Hyphenation which is applied in the document remains preserved when you open a document and save it back to Word formats. However, when you save the document to PDF format, Aspose.Words throws the following warning message:

MinorFormattingLoss: Automatic hyphenation is not supported. Content could be rendered differently.

Secondly, I am afraid, we cannot suggest you any programmatic workaround; therefore, you will have to wait for the fix of WORDSNET-9213 to come out. We apologize for your inconvenience.

Best regards,

Thanks for your feedbacks.

we will look forward the fix for WORDSNET-9213 to come out.

Hi Xiaofeng,

Thank you for your understanding and patience. Rest assured, we will inform you as soon as this issue is resolved.

Best regards,

Hi,

Xiaofeng is my colleague and now I’ve taken this bug from him. I’d like to know what progress of hyphenation issue is in Aspose.Words or any alternative workaround.

Thanks.

Hi Sheng,

Thanks for your inquiry. Unfortunately, your issue is not resolved yet and there is no further news about this issue. We regret to share with you that the implementation of this issue has been postponed till a later date. We will inform you via this thread as soon as this issue is resolved. We apologize for your inconvenience.

Best regards,

In order for Germany to use our product, their final PDF reports must retain auto-hyphanation as it was in the Word reports after performing word merging. We have been waiting for quite some time for an Aspose fix for this.

We need to provide them a timeline and plan for addressing this issue. Without a definite timeframe and planned release for this fix in Aspose.PDF, we will need to use other products instead of Aspose.

Please provide us with what specific Aspose release will correct this issue and when that release will be available.

This will be critical for us.

We look forward to hearing back from you.

Mark Wadington, Principal
Mercer | 544 Lakeview Parkway Suite 300 Vernon Hills, IL 60061, USA
+1 847 549 4525 | Fax +1 847 549 4401 | Mobile +1 630 373 2753 | Home +1 847 548 4787 Mark.Wadington@mercer.com

www.mercer.com | Mercer (US) Inc.****

Hi Mark,

Thanks for your inquiry. Unfortunately, this issue is not resolved yet. However, I have informed our development team of your concern. I will try to get a firm estimate on this feature and provide you some further feedback. We apologize for your inconvenience.

Best regards,

The issues you have found earlier (filed as WORDSNET-9213) have been fixed in this .NET update and this Java update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.

Hi,

Thanks for being patient. It is to update you that Aspose.Words’ layout engine now supports Hyphenation. However, to be able to use this feature, you must register a hyphenation dictionary specific to your language as follows:

Document doc = new Document(@"C:\Temp\in.doc");
Hyphenation.RegisterDictionary("en-US", @"C:</font>HyphDic\hyph_en_US.dic");
//Hyphenation.RegisterDictionary("de-CH", @"C:\HyphDic\hyph_de_CH.dic");

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

I hope, this helps.

PS: a few such dictionaries can be found here*

Best regards,

Hi Hafeez,

Thank you for your information and update. Looks new version provides hypenation supports. Great news. But unfortunately, when I want to use your given sample code to generate our PDF file, it failed and threw an ‘Infinite loop detected’ exception. I just attached the sample docx here. Our report is very complex. Could you guys have a look at that?

Another question is for the 2nd paramter ‘dictionaryPath’ of Hyphenation.RegisterDictionary method. What’s the format of this path, absolute path, or relative path, or other? I found sometimes I put the correct absolute path in it, but the method didn’t find it and threw an exception. What’s the problem?

Thanks.

Hi Sheng,

Thanks for your inquiry. Unfortunately, I was unable to reproduce this issue on my side when using Aspose.Words for .NET 14.4.0. It would be great if you please create a standalone runnable console application that helps us reproduce your problem on our end and attach it here for testing. As soon as you get this simple application ready, we’ll start further investigation into your issue and provide you more information. Secondly, please supply absolute path to the dictionary file in Hyphenation.RegisterDictionary method.

Best regards,

Hi Hafeez,Thank you for your reply. My code is very simple:

try
{
    Aspose.Words.License wordLic = new License();
    wordLic.SetLicense("Aspose.Total.lic");
    WordDocument sourceDoc = new WordDocument("pdfhyphen2.docx");
    Hyphenation.RegisterDictionary("de-DE", string.Format(@"{0}\{1}", AppDomain.CurrentDomain.BaseDirectory, "hyph_de_DE.dic"));
    sourceDoc.Save("Target.pdf", SaveFormat.Pdf);
    Console.WriteLine("Done");
}
catch (Exception ex)
{
    Console.WriteLine(ex.Message);
}

Use code above, the template attached in prior post and combine your 14.4 version, I still got the same exception. I attached a screenshot of exception occurred. Please have a look.

Thanks.

Hi Sheng,

Thanks for the additional information. I managed to reproduce this issue on my side and have logged it in our bug tracking system. The ID of this issue is WORDSNET-10193. Your thread has also been linked to this issue and you will be notified as soon as it is resolved. Sorry for the inconvenience.

Best regards,