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

Free Support Forum - aspose.com

Tabel of contents in pdf

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.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Hi

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

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:

http://www.aspose.com/documentation/.net-components/aspose.words-for-.net-and-java/aspose.words.document.appenddocument.html

Then insert TOC at the beginning of the final document:

http://www.aspose.com/documentation/.net-components/aspose.words-for-.net-and-java/aspose.words.documentbuilder.inserttableofcontents.html

And then, just before converting the final document to PDF, update TOC (the latest version of Aspose.Words already supports this feature):

https://blog.aspose.com/2010/04/08/toc-update-and-mergeformat-supported-by-aspose-words-for-net-9-0

Hope this could help you. Please let me know if you need more information, I will be glad to help you.

Best regards.

Unfortunatly we cannot concatinate these documents in Word-format since they need to have different information in their headers.

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

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.

Hi

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

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:

http://www.aspose.com/community/files/51/.net-components/aspose.words-for-.net/category1188.aspx

Best regards,

Sorry. Still the same problem. I don't know how we can come any further with this...

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

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");

doc.SaveToPdf(@"Test\out.pdf");

And please compare the resulting document with the document produced on my side I send this one to your e-mail.

Best regards,

Hi,

I have tried this, and unfortunatly, it keeps failing.

Attaching the input and output documents

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

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.

Best regards,

Thank you,

do you have any estimate for when this can be resolved?

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

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");

doc.UpdateTableLayout();

doc.Save("out.pdf");

Best regards,

Is there any progress on this issue or do you have any estimate for when this can be resolved?


Hi

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

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.

Best regards,

But this is an important problem that should be solved. We have to know when the issue will be solved.

Hello

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

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[0].CellFormat.Width = pageWidth;

}

}

}

// Save output document

doc.Save("out.pdf");

Best regards,

Hi,

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.

[Test]

public void TestDefect()

{

Document doc = TestUtil.Open(@"Defects\TestDefect19755.doc");

doc.UpdateTableLayout();

TestUtil.Save(doc, @"Defects\TestDefect19755.pdf");

}

The issues you have found earlier (filed as 19755) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.