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

Free Support Forum - aspose.com

Display an Inline Shape alongside the Heading 1 Text | DOCX to PDF using C# | Avoid Pageref in TOC Field | Table of Contents


I’m hoping you can help me with something. I am currently experiencing an issue with the Table of Contents when converting from DOCX to PDF.

I have a requirement to display an inline shape alongside the H1 text. On the DOCX this works perfectly, howeve,r the behaviour is different on the PDF. In this case the table of contents seems unable to render the page number when a shape appears on page 1. The other entries in the table of contents are working absolutely fin however.

Instead the PDF will show the shape then the explicit pageref and I can’t work out why this is the case.

I have uploaded an example docx and pdf. Any support with this would be appreciated.

documents.zip (66.7 KB)


I am afraid, we do not see any DOCX Word document attached to your post. Please also ZIP and upload your input Word DOCX document here for testing. We will then investigate the issue on our end and provide you more information.

@awais.hafeez Hi, yes sorry about that I must have uploaded the wrong file. I’ve amended my post and uploaded a zip file containing the pdf and docx file.


We tested the scenario and have managed to reproduce the same problem on our end by using the following code.

Document doc = new Document("E:\\Temp\\documents (2)\\result.docx");
doc.Save("E:\\Temp\\documents (2)\\20.3-UpdateFields.pdf");

For the sake of correction, we have logged this problem in our issue tracking system. The ID of this issue is WORDSNET-20134. We will further look into the details of this problem and will keep you updated on the status of correction. We apologize for your inconvenience.

However, the issue does not occur when using either of the following code snippets:

Document doc = new Document("E:\\Temp\\documents (2)\\result.docx");
PdfSaveOptions opts = new PdfSaveOptions();
opts.UpdateFields = false;
doc.Save("E:\\Temp\\documents (2)\\20.3-UpdateFields-false.pdf", opts);

Document doc = new Document("E:\\Temp\\documents (2)\\result.docx");
doc.Save("E:\\Temp\\documents (2)\\20.3.pdf");


Thank you for looking into this and thank you for supplying the work around, I will use this for now.

The issues you have found earlier (filed as WORDSNET-20134) have been fixed in this Aspose.Words for .NET 20.5 update and this Aspose.Words for Java 20.5 update.