Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Thu Feb 06, 2020 2:18 pm

Hello
I'm using v8.1.10

See attachment

When the text of the chapter is long, the dots bite on the last character in the TOC (see chapter 2 of the example).

In chapter 3 title, I have manually deleted the last character "V" and have retyped a new one. This one is not rendered correctly in the PDF format (Chapter title and TOC).

The Word version of the backup seams correct.

Code: Select all
    // La TOC calcule mal les points de continuation
    // Supprimer manuellement un caractère et le retaper perturbe la sauvegarde PDF (SPACE supprimé)
    internal void DoTest()
    {
      string inputFilename = Path.Combine(Application.StartupPath, "AAA.docx");
      string outputPDFFilename = Path.Combine(Application.StartupPath, "AAA.pdf");
      Document document = new Document(inputFilename);
      Paragraph tocParagraph = new Paragraph(document);
      tocParagraph.AppendTOC(1, 1);

      Section section = document.Sections[0];
      section.Paragraphs.Insert(0, tocParagraph);
      document.UpdateTableOfContents();
      document.SaveToFile(outputPDFFilename);
      Process.Start(outputPDFFilename);
    }

danielhalte1
 
Posts: 23
Joined: Sat Dec 14, 2019 12:50 am

Fri Feb 07, 2020 7:41 am

Hello,

Thanks for your inquiry.
I tested your case using the normal conversion method and did reproduce your issue. However, when using the PS conversion method to convert your file, there is no problem with the generated PDF file.
Thus, I suggest you use the PS conversion method instead. Below is the corresponding code, and I also attached the output using the PS conversion method for your reference.
Code: Select all
            string inputFilename = "AAA.docx";
            Document document = new Document(inputFilename);
            Paragraph tocParagraph = new Paragraph(document);
            tocParagraph.AppendTOC(1, 1);

            Section section = document.Sections[0];
            section.Paragraphs.Insert(0, tocParagraph);
            document.UpdateTableOfContents();
            ToPdfParameterList pdf = new ToPdfParameterList
            {
                UsePSCoversion = true
            };
            document.SaveToFile("result-ps.pdf",pdf);


Sincerely,
Rachel
E-iceblue support team
User avatar

rachel.lei
 
Posts: 1571
Joined: Tue Jul 09, 2019 2:22 am

Fri Feb 07, 2020 10:40 am

Hello
I have tested and validated your method

joy and happiness

your method corrects both problems

Thank's

danielhalte1
 
Posts: 23
Joined: Sat Dec 14, 2019 12:50 am

Mon Feb 10, 2020 1:06 am

Hello,

Thanks for your feedback.
If you need other help in the future, just feel free to contact us.
Have a nice day!

Sincerely,
Rachel
E-iceblue support team
User avatar

rachel.lei
 
Posts: 1571
Joined: Tue Jul 09, 2019 2:22 am

Return to Spire.Doc