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

Free Support Forum - aspose.com

Problem with multiline bookmarks and printing


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!

Kind Regards

Hi Christof,

Thanks for your inquiry. 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 as WORDSNET-14835. Our product team will further look into the details of this problem and we will keep you updated on the status of this issue. We apologize for your inconvenience.

Best regards,

Hi Christof,

Regarding WORDSNET-14835, our product team has completed the work on your issue and has come to a conclusion that this issue is not a bug in Aspose.Words. Your issue (WORDSNET-14835) has now been closed with ‘Not a Bug’ resolution.

To fix this issue, please call Document.UpdatePageLayout(); method before calling the Save or Print methods second time. Please check the following description of this method.

This method is automatically invoked when you first convert a document to PDF, XPS, image or print it. However, if you modify the document after rendering/printing and then attempt to render/print it again - Aspose.Words will not update the page layout automatically. In this case you should call UpdatePageLayout before rendering again.

Best regards,

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…

Hi Christof,

If after printing first time, you modify document and then call UpdatePageLayout before printing the second time, then yes UpdatePageLayout has to spend some time to re-layout pages. Roughly, Aspose.Words layouts 10 pages per second; so, the extra amount of time Aspose.Words may take to format a document into pages depends on the number of pages your Word document has. Please note that this process is not linear. It may take a minute to render one page and may take a few seconds to render 100 pages. It depends on document’s complexity. Hope, this helps.

Best regards,