Checkbox display truncated when converting to PDF

Hi,

We are currently on Aspose.Words 14.8 and are considering moving to the latest version to resolve issues regarding the display of checkboxes in Word documents after conversion to PDF. The checkbox fields are created on the fly by our program, and then the resulting Word document is saved to PDF. While there is a source document created in Word, the checkboxes are rendered into the Word document, and the PDF generation are done in Aspose.Words. The interesting tidbit is that checkbox fields at the left margin DO render correctly - only the indented ones don’t. If you try converting the attached Word document to PDF you should see the issue - Look for the checkboxes that should be after the question: “What type of accident caused the illness/injury”, and “Was another party responsible for this accident” Both should have indented checkboxes. I can make them appear by increasing the cell width from 25 to 40, but we have used the 25 value for years, so we’re reluctant to change it because it would likely cause layout issues on existing documents.

I have attached the Word document before conversion to PDF. If you can let us know if you can duplicate this, or have a suggestion on what we should do, I would very much appreciate it. Naturally, while checkboxes in documents are pretty rare, naturally one of our larger and better clients uses them, so it’s a big problem for us.

Please let me know as soon as possible as it will affect our ability to roll out our product to our client, and obviously affect whether we buy the new version.

Thanks!

Jeff Bireley
Taylor Communications
(formerly Standard Register)

Here’s the code used to generate the checkbox field:

private void ProcessSingleListOptionField(WordMergeField mergeField, IWordFieldData fieldData)
{
Section currentSection = mDocumentBuilder.CurrentSection;
PageSetup pageSetup = currentSection.PageSetup;

// TODO: should the width of the checkbox cell be font size-dependent?
// In other words, should we be trying to measure the width of a checkbox?
double checkboxCellWidth = 25d; // points

// For an example of building tables with DocumentBuilder, see
// Aspose.Total Product Family
mDocumentBuilder.StartTable();

double tableWidth = pageSetup.PageWidth - pageSetup.LeftMargin - pageSetup.RightMargin;
for (int index = 0; index < fieldData.ListOptionCount; index++)
{
Cell cell = mDocumentBuilder.InsertCell();

// Make sure the table grid lines are invisible
cell.CellFormat.Borders.LineStyle = LineStyle.None;

mDocumentBuilder.CellFormat.Width = checkboxCellWidth;

string listOptionValue = fieldData.ListOptionValue(index, mergeField.LocaleId);
bool isChecked = fieldData.IsListOptionSelected(index);

// VSTS 5372 - there are problems rendering form-type checkboxes to PDF.
// See, for example:
// Word Check Box Form Field Does are not converted correctly with Aspose.PDF
// The alternative is not to use a real checkbox but instead render a checked or unchecked box using
// the Wingdings font.

// Use one or the other of the following two lines:
mDocumentBuilder.InsertCheckBox(string.Empty, isChecked, 0);
//WriteCheckboxUsingWingdingsFont(isChecked);

mDocumentBuilder.InsertCell();
mDocumentBuilder.CellFormat.Width = tableWidth - checkboxCellWidth;

mDocumentBuilder.Write(listOptionValue);
mDocumentBuilder.CurrentParagraph.ParagraphFormat.Alignment = ParagraphAlignment.Left;

mDocumentBuilder.EndRow();
}
mDocumentBuilder.EndTable();
}

Hi Jeff,


Thanks for your inquiry. After an initial test with Aspose.Words 16.8.0, I was unable to reproduce this issue on my side (see attached 16.8.0.pdf). I would suggest you please upgrade to the latest version of Aspose.Words. You can download it from the following link. I hope, this helps.

Best regards,

I see that your sample document does look correct, but I’m attaching one ALSO created with 16.8.0 that has the sameWord document I sent as the source document, and you’ll notice that the indented checkboxes are completely missing.

Are there some settings that might affect this? After the document is loaded, all we’re doing is calling the ConvertToPdf() method.

Thanks,

Jeff Bireley

Hi Jeff,


The PDF you shared was actually generated by using “evaluation mode” of Aspose.Words for .NET version 14.8.0. Please do the following steps to check it:

  • Open your PDF document with Adobe Acrobat
  • Click on the ‘File’ menu and choose ‘Properties’ to open ‘Document Properties’ dialogue box.
  • In the ‘Decsription’ tab, under ‘Advanced’ section, you’ll see ‘Pdf Producer’ name.

If we can help you with anything else, please feel free to ask.

Best regards,

You’re right, of course. I apologize for wasting your time. I had downloaded the new version but neglected to change the reference in the project. That’s what I get for trying to do too many things at the same time.

We’ll proceed with getting the new version.

Thanks!

Jeff Bireley

Hi Jeff,


It is great that you managed to resolve this issue on your end. Please let us know any time you have any further queries.

Best regards,