How to make Textboxes editable


#1

Hi Team,

I have been trying to make few section of my word document editable. With protect method, it protects the entire page . I also tried with doc.getSections().get(0).setProtectedForForms(false);

It is allowing me to make the section editable only if its a paragraph, but it is not allowing me to edit a Textbox if I place in the same section. Please assist me on how to make Objects like Textboxes,Charts to make them editable on a protected Document.

Thanks,
Prasanna


#2

@pshanmuganathan,

You can define different Editable Ranges in your document to meet this requirement. The following sample code demonstrates how you can protect document and then define some Editable Range. You can incorporate the same functionality in your project. Hope, this helps.

Document doc = new Document();
doc.removeAllChildren();

Section section = new Section(doc);
doc.appendChild(section);

Body body = new Body(doc);
section.appendChild(body);

Paragraph para = new Paragraph(doc);
body.appendChild(para);

Run run = new Run(doc);
run.setText("Hello ");
run.getFont().setColor(Color.RED);
para.appendChild(run);

Run run2 = new Run(doc);
run2.setText("World!");
para.appendChild(run2);

doc.protect(ProtectionType.READ_ONLY);

DocumentBuilder builder = new DocumentBuilder(doc);

EditableRangeStart start = builder.startEditableRange();
EditableRangeEnd end = builder.endEditableRange();

run2.getParentNode().insertBefore(start, run2);
run2.getParentNode().insertAfter(end, run2);

doc.save("D:\\temp\\awjava-18.10.0.docx");

#3

Hi Awais,

Thanks for the above. However, objects like Textboxes becomes uneditable though I place them between editable ranges. Please get back if you have more questions.


#4

@pshanmuganathan,

To ensure a timely and accurate response, please ZIP and attach the following resources here for testing:

  • Your simplified input Word document
  • Aspose.Words 18.11 generated output DOCX file showing the undesired behavior
  • Your expected DOCX document showing the correct output. You can create expected document by using MS Word.
  • Please also create a standalone simple Java application (source code without compilation errors) that helps us to reproduce your current problem on our end and attach it here for testing. Please do not include Aspose.Words JAR files in it to reduce the file size.

As soon as you get these pieces of information ready, we will start further investigation into your issue and provide you more information. Thanks for your cooperation.


#5

Aspose Support.zip (24.4 KB)
Hi Awais,

I have attached the required. Please check the Input and Output File. I am trying to create editable regions between the words “Check1” and “Check2”. Between them we have the contents below,

Text content : asdsadsadsadsa
and a Text box.

In the output rendered document, I am able to edit the text content but i am not able to edit the Text inside the Textbox as it gets locked .

Please check my Java sample application as well . I have tried to used the start and end editable regions method of the builder to make the contents editable.

Get back if you have any questions.

Thanks,
Prasanna


#6

@pshanmuganathan,

We tested the scenario and 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-17756. We will further look into the details of this problem and will keep you updated on the status of this issue. We apologize for your inconvenience.


#7

Hi Awais,

Any Update on this ? Please let me know

Thanks,
Prasanna


#8

@pshanmuganathan,

Unfortunately, this issue is not resolved yet. This issue is currently pending for analysis and is in the queue. We will inform you via this thread as soon as this issue is resolved. We apologize for your inconvenience.


#9

Hi Awais,

I just wanted to follow up and check if you have any update for this issue.

Thanks,
Prasanna Shanmuganathan


#10

@pshanmuganathan,

There is no further update available at the moment. This issue is currently pending for analysis and is in the queue. We will inform you via this thread as soon as this issue is resolved. We apologize for your inconvenience.