With Aspose.Pdf.Kit for .NET we have developed a function in Sharepoint where the user can pick up several word documents and generates a pdf-document. This works fine except for “table of contents” that looks weird in the pdf-document that is generated. I attach the Word-document, may be you can test and tell me what to do.
Thanks for your request. I tried converting your document to PDF and the output PDF document looks exactly as your MS Word document.
Maybe in your case it would be better to concatenate MS Word document using Aspose.Words:
Then insert TOC at the beginning of the final document:
And then, just before converting the final document to PDF, update TOC (the latest version of Aspose.Words already supports this feature):
Hope this could help you. Please let me know if you need more information, I will be glad to help you.
Unfortunatly we cannot concatinate these documents in Word-format since they need to have different information in their headers.
When I save as PDF using the latest version of Aspose.Words, the table gets compacted and unreadable. See the attached pdf and word documents.
Thank you for your inquiry. I cannot reproduce the problem on my side using the latest version of Aspose.Words (9.1.0). You can download this version from here:
Sorry. Still the same problem. I don’t know how we can come any further with this…
Thanks for your request. Could you please try converting your innholdsfortegnelse.docx to PDF using the following code?
Document doc = new Document(@"Test\innholdsfortegnelse.docx");
And please compare the resulting document with the document produced on my side I send this one to your e-mail.
I have tried this, and unfortunatly, it keeps failing.
Attaching the input and output documents
Thank you for additional information. You are right; it works fine with .docx version of your document but fails with .doc. I managed to reproduce the problem on my side. Your request has been linked to the appropriate issue. You will be notified as soon as it is fixed. As a workaround you can try open/save the attached document using MS Word and then convert to PDF using Aspose.Words.
do you have any estimate for when this can be resolved ?
Thanks for your inquiry. Currently I cannot provide you any reliable estimate regarding this issue. You will be notified as soon as it is fixed.
Also you can try calling UpdateTableLayout method with this document (in this case the output PDF looks fine). But you should note, calling UpdateTableLayout can break formatting of other your documents.
Document doc = new Document("innholdsfortegnelse.doc");
Is there any progress on this issue or do you have any estimate for when this can be resolved?
Thanks for your inquiry. Unfortunately, the issue is still unresolved and currently I cannot provide you any reliable estimate regarding this issue. You will be notified as soon as it is fixed.
But this is an important problem that should be solved. We have to know when the issue will be solved.
Thanks for your inquiry. I added your request to my monthly report, so its priority will be increased. I will notify you as soon as the problem is resolved. As a temporary workaround you can try using the following code:
// Open Document Document doc = new Document("yourDoc.doc");
// Calculate width of the page
PageSetup ps = doc.FirstSection.PageSetup;
double pageWidth = ps.PageWidth - ps.RightMargin - ps.LeftMargin;
Node tables = doc.GetChildNodes(NodeType.Table, true).ToArray();
foreach(Table table in tables)
foreach(Row row in table.Rows)
if (row.Cells.Count == 1)
row.Cells.CellFormat.Width = pageWidth;
// Save output document
Here is another workaround for your. This document is one of those documents that contain missing or “invalid” width for table in the DOC file and by default Aspose.Words does not recalculate table widths.
You just need to call Document.UpdateTableLayout() before you convert the document to PDF. This “fixes” the table widths and the output is fine.
The reason we do not automatically invoke UpdateTableLayout for all documents is because this method is not yet capable of working with all complex table widths cases. So in 99% of the cases the table widths in DOC are valid and not recalculating table widths is best. Yet in rare documents table widths have a problem and we cannot offer much in this case excep calling UpdateTableLayout before converting to PDF.
public void TestDefect()
Document doc = TestUtil.Open(@"Defects\TestDefect19755.doc");