Free Support Forum - aspose.com

Apply Hyphenation Dictionary & Save to PDF/A-1a or PDF 1.7 using C# | Prevent Word DOCX PDF Document Loading in 'protected view'

Hello,

We have Aspose integrated in our comparison software (GlobalVision).
When I open a specific word document, it launches in protected view, where i have to click on ‘enable editing’ (the yellow message bar that appears at the top).
In this protected view, some words that should be hyphenated, appear not hyphenated.
When I click on ‘enable editing’, the words appear hyphenated.

In my software, when i load that word file, it appears not hyphenated, as if it’s loading in protected view.

Any idea what the solution could be?

Thanks,

Fouad

@fnoujaim,

Thanks for your inquiry. Have you tried the latest version of Aspose.Words for .NET i.e. 20.3 on your end? In case the problem still remains, please ZIP and upload your input Word document and Aspose.Words generated DOCX/DOC Word file showing the undesired behavior here for testing. We will then investigate the issue on our end and provide you more information.

Aspose.zip (40.5 KB)

I added the files in question, List 2_el_soft hyphen Sample (1) has the words ‘sample’ in page two and they are not getting hyphenated when loading them in my software.

unfortunately, i am not a developer, I don’t think i can test within aspose directly. I’m a project manager looking for help around the subject. Can you perhaps run this file through aspose and let me know what happens?

@awais.hafeez

We tried the new version with my developer and the result is the same.
Please see the Files I sent in my last response.

Kindly let me know if you’re able to help with that.

Thanks

@fnoujaim,

We loaded your “List 2_el_soft hyphen Sample (1).docx” into Aspose.Words for .NET 20.3 and re-saved it to DOCX format (see output 20.3.zip (19.4 KB)) by using the following simple code on our end:

Document doc = new Document("E:\\aspose\\List 2_el_soft hyphen Sample (1).docx");
doc.Save("E:\\aspose\\20.3.docx");

Both the input and output DOCX documents look identical when viewing with MS Word 2019 on our end. Also, MS Word 2019 does not open any of these documents in protected view.

Can you please also provide a piece of source code that will help us to reproduce the same problem on our end? Also, what MS Word version are you using on your end?

image.png (194.1 KB)

Thank you for your response.
Please see screenshot added to this reply. The page on the right, shows the word Sample not hyphenated. This is taken directly from our software that uses Aspose.

image.png (119.3 KB)

The second screenshot shows the hyphen in those words mentioned earlier.

I will see if there’s any source code that i can provide.

Thanks again,

Fouad

@fnoujaim,

Thanks for the additional information.

Yes, we can confirm that words in “List 2_el_soft hyphen Sample (1).docx” are properly hyphenated while hyphenation is not applied on same words in “List 1_el Master (1).docx”.

But, we also need to understand what Aspose.Words code did you guys use to produce this problematic document on your end?

We will wait for your further input on this topic. Thanks for your cooperation.

GlobalVision_Class2.zip (825 Bytes)

Please see the code snippet attached to this reply.

Thank you!

@fnoujaim,

We managed to produce the following PDF file on our end by using the code you supplied in previous post:

And we see the following message when opening above PDF with Adobe Acrobat Reader DC; and of-course hyphenation is not applied.

This file claims compliance with the pdf/a standard and has been opened read-only to prevent modification.

Please also try applying the following hyphenation dictionary (by using Hyphenation.RegisterDictionary Method) before saving to PDF and see how it goes on your end?

C# Code

    ...
    ...
    Hyphenation.RegisterDictionary("en-GB", "E:\\Temp\\hyph_en_US.dic");
    doc.Save(inDest, options);

    return 1;
}

Hello,

Here is the response from my developer.

I update output pdf from PDF/A-1a standard to PDF 1.7 standard to disable the Read-Only protection. and also add the “RegisterDictionary“ to register the dic.

image.png (38.3 KB)

The updated code is shown in GlobalVision_class3.cs

But the soft-hyphen is still miss in the result file.

image.png (102.5 KB)

Above image show the List2_1.7 (PDF 1.7 standard) do not have hyphen on the page 2.

@fnoujaim,

Thanks for the additional information. We tested the scenario and have managed to reproduce the same problem on our end. For the sake of any correction, we have logged this problem in our issue tracking system. The ID of this issue is WORDSNET-20204. We will further look into the details of this problem and will keep you updated on the status of linked issue. We apologize for your inconvenience.

@fnoujaim,

Regarding WORDSNET-20204, we have completed the work on your issue and concluded to close this issue with “Not a Bug” status. We have found an improved version of hyphenation dictionary here:

Also, instead of using “en-GB”, please use “en-US” locale when registering the dictionary:

Simple code to produce this PDF file (20.3-en-US.pdf (114.5 KB)) on our end is as follows:

Document doc = new Document("E:\\temp\\aspose\\List 2_el_soft hyphen Sample (1).docx");
Hyphenation.RegisterDictionary("en-US", "E:\\Temp\\hyph_en_US.dic");
PdfSaveOptions opts = new PdfSaveOptions();
opts.Compliance = PdfCompliance.Pdf17;
doc.Save("E:\\temp\\aspose\\20.3-en-US.pdf", opts);

Hope, this helps in achieving what you are looking for.

Thank you very much for your help. My developer managed to fix the issue, now the soft hyphen displays when we load the file.

@fnoujaim,

Thanks for your feedback. It is great that you were able to resolve this issue on your end. Please let us know any time you may have any further queries in future.