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

Free Support Forum - aspose.com

Disable Yellow Color of Content of Editable Ranges using Java | Lock Watermark Shape | DOC Opened in Protected View

I am using
DocumentBuilder builder = new DocumentBuilder(doc);
doc.protect(ProtectionType.READ_ONLY);

It is highlighting the text in all the pages with Yellow color. How to disable that?
Also doc extn files are giving Some warning about doc is protected. How to disable this warning ?

Screen Shot 2020-03-27 at 8.19.46 PM.jpg (92.8 KB)
Screen Shot 2020-03-27 at 8.18.56 PM.png (131.9 KB)

Any help very much appreciated .

Thanks

I see DOC problem is fixed in new version of aspose words.

DocumentBuilder builder = new DocumentBuilder(doc);
doc.protect(ProtectionType.READ_ONLY);
Screen Shot 2020-03-27 at 8.19.46 PM.jpg (92.8 KB)
Screen Shot 2020-03-27 at 8.18.56 PM.png (131.9 KB)

but when i use protect mode i am seeing two issues.

  1. Text in the edit range is default highlighted with YELLOW color. How to disable this ?
  2. For DOC extn files, it is giving a warning that “PROTECTED View” . How to disable this warning ?

Attached the documents for the error for reference

@vgcnerella2019,

We tested the scenarios and have managed to reproduce the same problems on our end. For the sake of corrections, we have logged the following issues in our issue tracking system.

WORDSNET-20206: ProtectionType.ReadOnly causes MS Word to Open DOC in Protected View
WORDSNET-20207: Provide option to disable default Yellow color of content of Editable Ranges

We will further look into the details of these issues and will keep you updated on the status. We apologize for your inconvenience.

Is there any alternative approach with which i can just lock a shape object in header and leaving the rest of the document as editable without loosing user experience ?
This should be for both DOC and DOCX .

Thanks for the help.

@vgcnerella2019,

Please ZIP and upload your sample input Word document and your expected document showing the desired behavior here for our reference. You can create this expected document by using MS Word. Please also list the complete steps that you performed in MS Word to create the expected document on your end. We will then investigate the scenario further on our end and provide you more information.

There is nothing specific about the doc. I created a doc in google docs and exported as docx. Doc will have multiple pages. Expectation is to have the watermark on the top right corner of the header on each page.

Attached sample and expected in zip fileArchive.zip (30.4 KB)

@vgcnerella2019,

But in your supplied document i.e. “Sample_WM.docx”, we are able to delete the ‘Private’ Shape object located at the top-right Header corner using MS Word 2019 on our end. Can you please clarify a bit more, what do you mean by locking Shape in Header of Word document?

The standard way of adding watermark (text or shape) is mentioned in the following article:

I did not know that you expected us to put the locked Watermark one. I attached the locked one with two formats. WithWM.zip (32.0 KB)

@vgcnerella2019,

Thanks for the additional information. We have logged these details in our issue tracking system and will keep you posted here on any further updates.

Any update on this ? what is the approximate ETA for the fix ?

Thanks

@vgcnerella2019,

I am afraid, your issues are not resolved yet and there are no estimates available at the moment. Once the analysis of both of these issues will be completed, we may then be able to calculate and share the ETA (estimates) with you. We apologize for any inconvenience.

There was one problem with Aspose cells. I raised a ticket for it but could you please also track similar issue for doc and docx also ?

image.png (48.1 KB)

We should not allow locked Shape to be deleted even in O365 online edit case but all the other document should be editable.

Ticket number for the Cells on your system is

CELLSJAVA-43156 – Locking WordArt Watermark does not work for Office 365

@vgcnerella2019,

Thanks for the additional information. We have logged these details in our issue tracking system and will keep you posted on any further updates.

@vgcnerella2019,

Regarding WORDSNET-20206 (ProtectionType.ReadOnly causes MS Word to Open DOC in Protected View), please note that the default editor group type is NONE. For DOC format, any type of editor group causes a “PROTECTED VIEW” problem, except EVERYONE. Therefore, the only solution is to set EditorType.Everyone into the StartEditableRange.

EditableRangeStart start = builder.startEditableRange();
start.getEditableRange().setEditorGroup(EditorType.EVERYONE);

So, this is an issue with MS Word i.e. any type of editor group except Everyone causes PROTECTED VIEW message while opening DOC-format document. Please set EVERYONE explicitly to get the desired output. Hope, this helps.

@vgcnerella2019,

Regarding WORDSNET-20207, Unfortunately, Word documents do not store any property to disable highlighting (color) of editable regions. You can only disable yellow highlighting (color) of editable ranges be using macros.

However, we can offer you another way to add a watermark shape in Word document. Please see these input/output Word documents (Sample Docs 210662.zip (18.8 KB)) and try running the following Java code:

Document doc = new Document("E:\\Temp\\Input.docx");
Section mainSection = doc.getFirstSection();
mainSection.getBody().getFirstParagraph().getParagraphFormat().setPageBreakBefore(false);
mainSection.getPageSetup().setSectionStart(SectionStart.CONTINUOUS);
mainSection.setProtectedForForms(false);
HeaderFooter header = mainSection.getHeadersFooters().getByHeaderFooterType(HeaderFooterType.HEADER_PRIMARY);
if (header == null)
{
    header = new HeaderFooter(doc, HeaderFooterType.HEADER_PRIMARY);
    mainSection.getHeadersFooters().add(header);
}
header.isLinkedToPrevious(true);

Section watermarkSection = (Section)mainSection.deepClone(false);
watermarkSection.setProtectedForForms(true);

Shape watermark = new Shape(doc, ShapeType.TEXT_PLAIN_TEXT);
watermark.getTextPath().setText("CONFIDENTIAL");
watermark.setWidth(500);
watermark.setHeight(100);
watermark.setRotation(-40);
watermark.getFill().setColor(Color.GRAY);
watermark.setStrokeColor(Color.GRAY);
watermark.setRelativeHorizontalPosition(RelativeHorizontalPosition.PAGE);
watermark.setRelativeVerticalPosition(RelativeVerticalPosition.PAGE);
watermark.setWrapType(WrapType.NONE);
watermark.setVerticalAlignment(VerticalAlignment.CENTER);
watermark.setHorizontalAlignment(HorizontalAlignment.CENTER);

Paragraph watermarkPara = new Paragraph(doc);
watermarkPara.appendChild(watermark);

header = new HeaderFooter(doc, HeaderFooterType.HEADER_PRIMARY);
watermarkSection.getHeadersFooters().add(header);
header.appendChild(watermarkPara);

doc.insertBefore(watermarkSection, mainSection);
doc.protect(ProtectionType.ALLOW_ONLY_FORM_FIELDS);
doc.save("E:\\Temp\\Output.docx");

but above solution is also imperfect.
Also unfortunately, documents using ‘Restrict Editing’ cannot be edited in Office 365 online version, because this feature is not implemented there.

4 posts were split to a new topic: Yellow Color of Content of Editable Ranges Turns Red after Calling Document.Unprotect Method C# .NET