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

Free Support Forum - aspose.com

SaveOptions.UpdateSdtContent does not work for a checkbox - Word to PDF

Hi @awais.hafeez,
Please find the input, and respective PDF’s with the SaveOptions.UpdateSdtContent value set as true and false.
Please see that there is no change in the final PDF even with the SaveOptions.UpdateSdtContent value as true or false.
The checkbox are still being marked on the first page, while the input document doesn’t have checkbox marked.

Regards,
Ankur

@sumeetm,

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

Aspose.Words for java is yet to be released, the last time I checked.

input.zip (592.1 KB)
Here is the input, and respective PDF’s.
The same was attached in that issue for a reason as it was suggested to use SaveOptions.UpdateSdtContent to true .
But clearly it doesn’t work in this case.
So either there is a bug in the Aspose Words jar or the earlier root cause analysis was incorrect.

Regards,
Ankur

@sumeetm,

Please upgrade to the latest version of Aspose.Words for Java i.e. 19.8 from the following link:
https://downloads.aspose.com/words/java

After that please use the following code:

Document doc = new Document("E:\\Temp\\input\\input.docx");

PdfSaveOptions opts = new PdfSaveOptions();
opts.setUpdateSdtContent(false);

doc.save("E:\\Temp\\input\\awjava-19.8-UpdateSdtContent-false.pdf", opts); 

Attachment: awjava-19.8-UpdateSdtContent-false.pdf (230.9 KB)

Hi,
I checked with the latest Apsose Words 19.9 and it is working fine for the input attached here in this new issue but the input attached in the older issue still gives wrong rendition.

Checkboxes.zip (740.3 KB)

Please check the file input.docx and the input.pdf on Page 1 itself. If you open the document in the Microsoft Word, it does not render the checkboxes but aspose does.

Regards,
Ankur Vashishtha

Document doc = new Document("C:\\Checkboxes\\input1.docx");
HandleDocumentWarnings callback = new HandleDocumentWarnings();
doc.setWarningCallback(callback);
SaveOptions pdfSaveOptions = new PdfSaveOptions();
pdfSaveOptions.setUpdateSdtContent(false);
doc.save("C:\\Checkboxes\\input1.pdf",pdfSaveOptions);

Sample code

Hi @awais.hafeez,
Can you please update this one.

Ankur

@sumeetm,

Please try using the following code:

Document doc = new Document("E:\\Temp\\Checkboxes\\input.docx");

PdfSaveOptions opts = new PdfSaveOptions();
opts.setUpdateSdtContent(false);

doc.save("E:\\Temp\\Checkboxes\\awjava-19.9-UpdateSdtContent-false.pdf", opts); 

awjava-19.9-UpdateSdtContent-false.pdf (230.9 KB)

Thats what I have used. I have added the sample code as well.

Ok I see PdfSaveOption instead of SaveOptions

It is working fine. You can close this issue

@sumeetm,

Thanks for your feedback. Please feel free to ask if you have any question about Aspose.Words, we will be happy to help you.

Hi @tahir.manzoor,
This doesn’t work if we enable the preserveformfield.

com.aspose.words.Document doc = new com.aspose.words.Document(“C:\Input.docx”);
HandleDocumentWarnings callback = new HandleDocumentWarnings();
doc.setWarningCallback(callback);
PdfSaveOptions pdfSaveOptions = new PdfSaveOptions();
pdfSaveOptions.setPreserveFormFields(true);
pdfSaveOptions.setUpdateSdtContent(false);
doc.save(“C:\out_preserve2.pdf”, pdfSaveOptions);

If I set PreserveFormField as true, it doesn’t matter , whatever I set in setUpdateSdtContent, the output is still same and checkboxes are not rendered correctly which would have been rendered, if setUpdateSdtContent set to false.

Is it correct behaviour or expected one?

Regards,
Ankur Vashishtha

@sumeetm,

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

The issues you have found earlier (filed as WORDSNET-19399) have been fixed in this Aspose.Words for .NET 20.2 update and this Aspose.Words for Java 20.2 update.