Word Content Control (Checkbox) get auto checked and unchangeable after WORD to PDF conversion

Hi, I have a Word file with Content Control (checkbox) when I convert the Word file to PDF using ASPOSE Word 20.2 some checkbox gets checked (has ‘X’ within) and the checkbox can’t be changed afterward. We are using a licensed version of aspose words 20.2 and I have tested with the latest version of aspose where the problem persists.

before conversion:
Problem.docx (12.4 KB)

after conversion: Problem.pdf (4.2 MB)

@ittahadakash1 The problem is not reproducible on my side using the latest 24.8 version of Aspose.Words and the following simple code:

Document doc = new Document(@"C:\Temp\in.docx");
PdfSaveOptions opt = new PdfSaveOptions();
opt.PreserveFormFields = true;
doc.Save(@"C:\Temp\out.pdf", opt);

out.pdf (18.3 KB)

So, please try using the latest version of Aspose.Words.

The problem is only reproduced when using a docker container. I am using dockerized .net6 application where the issue is reproduced. It’s working nicely in windows machines.

@ittahadakash1 Could you please attach the expected output produced on Windows machine?

The problem on your side might occur because the fonts used in your input document are not available on the machine where document is processed. The fonts are required to build document layout. If Aspose.Words cannot find the font used in the document, the font is substituted. This might lead into fonts mismatch and document layout differences due to the different fonts metrics. You can implement IWarningCallback to get notifications when font substitution is performed.
Please see our documentation to learn where Aspose.Words looks for fonts:
https://docs.aspose.com/words/net/specifying-truetype-fonts-location/

It is the generated pdf using my windows machine: Problem.pdf (5.2 MB)

Problem depicted:

Although the checkbox does not have an ‘X’ sign when generated from windows, it is non-editable.

@ittahadakash1 Thank you for additional information. Unfortunately, the only way to resolve the problem is updating to the newer version of Aspose.Words.

Sadly the issue exists on the latest version as well (24.8.0)

Generated a word → pdf with this:

The checkbox still gets crossed-out

@ittahadakash1 I cannot reproduce the problem on my side using the following simple code:

Document doc = new Document(@"C:\Temp\in.docx");
PdfSaveOptions opt = new PdfSaveOptions();
opt.PreserveFormFields = true;
doc.Save(@"C:\Temp\out.pdf", opt);

out.pdf (18.3 KB)

What type of OS you are running this on?

@ittahadakash1 I tested on both Windows and Linux. Here is the output produced on Linux on my side:
out_linux.pdf (12.8 KB)

out_docker_linux.pdf (4.6 MB)

Hi could you please check this output file. I just generated this from a linux based docker container and the problem is there.

This is the docx file:
testX.docx (14.1 KB)

@ittahadakash1 The problem is reproducible with the attached document. Looks like it occurs because there is a cell-level SDT with checkbox.

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): WORDSNET-27357

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

1 Like

@ittahadakash1 We have completed analyzing the issue and decided to close it as not a bug. Making a check box or other editable field out of a table cell is not supported. In a general case, a table cell can have many contents inside, like many paragraphs, other tables, text boxes etc. As in most of these cases complex contents cannot be represented as editable fields, it was decided that Aspose.Words does not export cell-level SDTs as editable fields at all.

Okay, thanks. Is there any plan to implement this in the future?

@ittahadakash1 No, there are no plans to implement this in the future. You should use inline level SDTs in your document to get them as editable form fields in the output PDF.

Hi support team,

Are there any APIs/ways/code examples that would allow us to determine whether such SDTs are present in the docx files? I think the warning interface does not provide such information.

@ittahadakash1 You con use the following code:

Document doc = new Document(@"C:\temp\in.docx");

foreach (StructuredDocumentTag sdt in doc.GetChildNodes(NodeType.StructuredDocumentTag, true))
{
    if (sdt.SdtType == SdtType.Checkbox && sdt.Level != MarkupLevel.Inline)
    {
        Console.WriteLine("CheckBox will not be exported as editable to PDF");
    }
}

The issues you have found earlier (filed as WORDSNET-27357) have been fixed in this Aspose.Words for .NET 24.10 update also available on NuGet.