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

Free Support Forum - aspose.com

Unable to check/uncheck checkboxes - Aspose Words

Hi,
In one of our documents where we are making use of bookmarks to merge some data onto the document. Apart from that we are also merging Content control checkboxes on the document. We are able to check/uncheck these checkboxes on template. But when the same template gets generated as a document, we are not able to do so. Please refer attached image.
We tried attaching a sample project along with this mail, but it was giving an issue during upload.

Thanks,
Meenal
Hi Meenal,

Thanks for your inquiry. To ensure a timely and accurate response, please attach the following resources here for testing:

  • Your input Word document
  • Please attach the output Word file that shows the undesired behavior.
  • Please create a standalone console application (source code without compilation errors) that helps us reproduce your problem on our end and attach it here for testing.

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

PS: To attach these resources, please zip them and Click 'Reply' button that will bring you to the 'reply page' and there at the bottom you can include any attachments with that post by clicking the 'Add/Update' button.
Hi,
We tried uploading our sample project yet again, but we could not upload it successfully due to some technical issues with the site. I have attached a small portion of our sample code at the end of this mail, which contains the main gist of what our code tries to accomplish. I've also attached the source template and the generated document and have highlighted the regions where we faced an issue (on the generated output template). Please let us know if you're able to reproduce the issue at your end and how this issue can be fixed.

Thanks,
Meenal


Note:- Sample Code to insert text and bookmark on word template

public void mergedata1()
{
string appDataPath = Server.MapPath("~/app_data");
string file = Path.Combine(appDataPath, "trial01.docx");
Document doc = new Document(file);
DocumentBuilder Builder = new DocumentBuilder(doc);
Builder.Writeln("Hello World!");
Builder.MoveToBookmark("bktabletest");
Builder.Font.Name = "Arial";
Builder.Font.Size = 9;
Builder.StartTable();
Builder.CellFormat.Borders.Bottom.LineStyle = LineStyle.Hairline;
Builder.CellFormat.Borders.Top.LineStyle = LineStyle.Hairline;
Builder.CellFormat.Borders.Left.LineStyle = LineStyle.Hairline;
Builder.CellFormat.Borders.Right.LineStyle = LineStyle.Hairline;
Builder.CellFormat.Borders.Color = Color.LightGray;
Builder.InsertCell();
Builder.CellFormat.Shading.BackgroundPatternColor = Color.White;
Builder.CellFormat.Width = 175;
Builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
Builder.Write("Cell3");
Builder.InsertCell();
Builder.CellFormat.Shading.BackgroundPatternColor = Color.White;
Builder.CellFormat.Width = 30;
Builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
Builder.Write("Cell4");
Builder.EndRow();
Builder.EndTable();
doc.Save(System.Web.HttpContext.Current.Response, "Output.doc", ContentDisposition.Attachment, null);
}

Hi Meenal,

Thanks for sharing the detail. Please note that Aspose.Words mimics the same behavior as MS Word does. If you save your document (Docx) to Doc file format using MS Word, you will get the same output.

Please note that Microsoft introduced content controls with the release of Word 2007. So, please save your final output document to Docx to get the required output.

Moreover, the content control in your input document are not of type check-box. We have created a sample input document which contains content controls of type check-box. Please check the attached input and output Doc/Docx documents for your kind reference. The following code example generates the output documents.

Document doc = new Document(MyDir + "in.docx");

DocumentBuilder Builder = new DocumentBuilder(doc);

doc.Unprotect();

Builder.Writeln("Hello World!");

Builder.MoveToBookmark("bktabletest");

Builder.Font.Name = "Arial";

Builder.Font.Size = 9;

Builder.StartTable();

Builder.CellFormat.Borders.Bottom.LineStyle = LineStyle.Hairline;

Builder.CellFormat.Borders.Top.LineStyle = LineStyle.Hairline;

Builder.CellFormat.Borders.Left.LineStyle = LineStyle.Hairline;

Builder.CellFormat.Borders.Right.LineStyle = LineStyle.Hairline;

Builder.CellFormat.Borders.Color = Color.LightGray;

Builder.InsertCell();

Builder.CellFormat.Shading.BackgroundPatternColor = Color.White;

Builder.CellFormat.Width = 175;

Builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;

Builder.Write("Cell3");

Builder.InsertCell();

Builder.CellFormat.Shading.BackgroundPatternColor = Color.White;

Builder.CellFormat.Width = 30;

Builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;

Builder.Write("Cell4");

Builder.EndRow();

Builder.EndTable();

doc.Save(MyDir + "Out.doc");

doc.Save(MyDir + "Out.docx");

Hi,
We tried implementing the solution you provided for displaying the custom-control checkboxes correctly onto our generated word documents. It worked in case of our sample project (whose code snippet we sent you earlier). But, it did not work in case of our actual code. We have used Aspose.Words version 15.7.0.0 in our sample code, and use version Aspose.Words 7.0.0.0 in our actual code. Is there any backward compatibility issue?
Also, in case of our actual code we have an additional constraint that we cannot generate the final output document in the ".docx" format. As our end users, require documents solely in ".doc" format.
Can you suggest another way around, for this issue ?

Thanks,
Meenal
Hi Meenal,

Thanks for your inquiry.
meenalp:
As our end users, require documents solely in ".doc" format.
Can you suggest another way around, for this issue ?
Please note that Microsoft introduced content controls with the release of Word 2007. So, you can explain your customer that contents controls are not available in Doc file format.
meenalp:
But, it did not work in case of our actual code. ... use version Aspose.Words 7.0.0.0 in our actual code.
You are using very old version of Aspose.Words. There might be some issue in older version of Aspose.Words v7.0.0. We suggest you please upgrade to the latest version of Aspose.Words for .NET 16.2.0. Hope this helps you.