we’ve encountered a problem, which was somewhat tricky tracking it down to the most simple scenario. It is about bookmarks and printing.
Following conditions must be met:
- The bookmark must be inside a table cell.
- It must enclose a multiline text
(see attached docx).
Now, if we set the bookmark’s text once and send the document to a printer, after that set the bookmark’s text again and print the document a second time, we get a NullReferenceException somewhere from the core of Aspose.Words.
It does not depend on the printer type being used. We are using the latest version of Aspose.Words, currently V17.1.
Attached is the testcase with a small program file, the stacktrace of the exception and the docx file representing the minimal requirements for getting the error.
Thanks in advance for any assistence for that case!
Hi, many thanks for looking at this!
The suggested resolution is working correctly as far as I can see. But there comes one question into my mind:
Would it be expensive to call doc.UpdatePageLayout() before each call to doc.Print()?
I am asking this, because the calling process, which is generating and printing documents, does not always know, wether it is printing a document a second time…