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.

Mon Jun 08, 2015 7:48 pm

Is it possible to create a pdf with the TOC on the lift had side like in the picture I have uploaded?

terrence@mactexas.com
 
Posts: 95
Joined: Tue May 19, 2015 8:09 pm

Tue Jun 09, 2015 6:22 am

Hello,

Thanks for your inquiry.
Here is the code for your reference.
Code: Select all
PdfDocument pdf = new PdfDocument("d:\\pdf_test.pdf");
            PdfTextFind[] result = null;
            string bookmark = "Performance Reduced";
            foreach (PdfPageBase page in pdf.Pages)
            {
                result = page.FindText(bookmark).Finds;
                foreach  (PdfTextFind find in result)
                {
                    float y = find.Position.Y;                   
                    PdfDestination vendorBookmarkDest = new PdfDestination(page, new PointF(0, y));
                    PdfBookmark vendorBookmark = pdf.Bookmarks.Add(bookmark);
                    vendorBookmark.Color = Color.SaddleBrown;
                    vendorBookmark.DisplayStyle = PdfTextStyle.Bold;
                    vendorBookmark.Action = new PdfGoToAction(vendorBookmarkDest);
                }
            }
            pdf.SaveToFile("result.pdf");


Best Regards,
Sweety

E-iceblue support team
User avatar

sweety1
 
Posts: 539
Joined: Wed Mar 11, 2015 1:14 am

Tue Jun 09, 2015 7:14 pm

Thank you for that code.

I want to know if I can do this coming from a word doc. I am creating the word doc with Spire.Doc library and I will put the bookmarks in the word doc.

I will save to .docx and .pdf.

If I open the pdf then who would I find all of the pre-existing bookmarks and make a left hand TOC ?

Thank you.

terrence@mactexas.com
 
Posts: 95
Joined: Tue May 19, 2015 8:09 pm

Wed Jun 10, 2015 2:50 am

Hello,

Thanks for your response.
You can do that coming from a word doc.
Here is the sample code for your reference.
Code: Select all
Document doc = new Document();
            doc.LoadFromFile(@"5166.docx");
            doc.UpdateTableOfContents();
            doc.SaveToFile("result5166.pdf", FileFormat.PDF);


Best Regards,
Sweety

E-iceblue support team
User avatar

sweety1
 
Posts: 539
Joined: Wed Mar 11, 2015 1:14 am

Wed Jun 10, 2015 8:53 pm

Sweety, I have bookmarks working for PDF.
Why am I getting nested bookmarks? There should only be one bookmarks named "Word Bookmarks"

Bookmarks 0 - 9 should be at the same level.


Code: Select all
public void BookMarks()
{
   string numbers = "  --01234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989901234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798990123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899";

   Document document = new Document();
   Section section = document.AddSection();

   for (int i = 0; i < 10; i++)
   {
      Paragraph paragraph = section.AddParagraph();
      paragraph.AppendBookmarkStart("SimpleBookMark -" + i.ToString());
      paragraph.AppendText("BookMark:" + i.ToString() + numbers);
      paragraph.AppendBookmarkEnd("SimpleBookMark -" + i.ToString());
   }

   ToPdfParameterList toPdf = new ToPdfParameterList();
   toPdf.CreateWordBookmarks = true;
   document.SaveToFile(@"e:\temp\Bookmarks2.Pdf", toPdf);

}

terrence@mactexas.com
 
Posts: 95
Joined: Tue May 19, 2015 8:09 pm

Thu Jun 11, 2015 7:18 am

Hello,

Thanks for your reply.
I have reproduced your issue. And I have posted the issue to our dev team. We will inform you when it is fixed. sorry for the inconvenience.

Best Regards,
Sweety

E-iceblue support team
User avatar

sweety1
 
Posts: 539
Joined: Wed Mar 11, 2015 1:14 am

Fri Jun 12, 2015 1:51 pm

Is there any bug fix on this issue?

terrence@mactexas.com
 
Posts: 95
Joined: Tue May 19, 2015 8:09 pm

Mon Jun 15, 2015 5:06 am

Hello,

Thanks for your reply.
The issue is already resolved. The fix will be included into the next version of Spire.Doc. We will inform you when it is released.

Best Regards,
Sweety

E-iceblue support team
User avatar

sweety1
 
Posts: 539
Joined: Wed Mar 11, 2015 1:14 am

Mon Jun 15, 2015 1:53 pm

Well do you have an estimate of time on when it will be available? I am evaluating this tool to purchase and if it is not soon, I will move on to anther product.

Thank you.

terrence@mactexas.com
 
Posts: 95
Joined: Tue May 19, 2015 8:09 pm

Tue Jun 16, 2015 3:19 am

Hello,

Thanks for your waiting.
Our development team has solved your problem. Please test the below new package:
http://www.e-iceblue.com/downloads/temp/spire.doc_5.4.36.zip

Best Regards,
Sweety

E-iceblue support team
User avatar

sweety1
 
Posts: 539
Joined: Wed Mar 11, 2015 1:14 am

Tue Jun 16, 2015 3:22 pm

Sweety, that worked Great! Thank you.

Could you give me an example of nested bookmarks in my doc file?

Thank you.

terrence@mactexas.com
 
Posts: 95
Joined: Tue May 19, 2015 8:09 pm

Tue Jun 16, 2015 4:47 pm

Sweety, I noticed a bug I think.

Now when I click on a bookmark, the page that has the bookmark is displayed, but the paragraph no longer goes to the top of the viewing area. Before the fix, every book mark section was displayed at the top of the viewing area when clicked.

terrence@mactexas.com
 
Posts: 95
Joined: Tue May 19, 2015 8:09 pm

Wed Jun 17, 2015 2:39 am

Hello,

Thanks for your reply.
There is an example about nested bookmarks in our website.
http://www.e-iceblue.com/Knowledgebase/Spire.Doc/Demos/Context/Word-Bookmark-for-C-VB.NET.html
In addition, I have tested your issue with the new package and the before version. Then I compared the generated word files. I didn't find the difference between them. Could you please supply detailed information shows the issue you encountered?

Best Regards,
Sweety

E-iceblue support team
User avatar

sweety1
 
Posts: 539
Joined: Wed Mar 11, 2015 1:14 am

Wed Jun 17, 2015 2:14 pm

Sweety, I have looked at that example and it does not work.
Note in the picture below that the bookmarks are not nested, but all fall under each other.

I would expect a nested bookmark to have a parent as in "Word Bookmarks" is a parent and then the nested bookmarks would fall under the parent, and if you clicked the "-" sign they would collapse, and then clicking the "+" sign and they would appear again.

So in the example, Root Data would have a "-" sign next to it and Nested level 1 and level 2 would be under and collapse if you clicked the "-" sign.

NestedBookMarks2.JPG

terrence@mactexas.com
 
Posts: 95
Joined: Tue May 19, 2015 8:09 pm

Wed Jun 17, 2015 2:15 pm

>>Could you please supply detailed information shows the issue you encountered?
I can not reproduce the bug, it must have been a fluke.
Thank you.

terrence@mactexas.com
 
Posts: 95
Joined: Tue May 19, 2015 8:09 pm

Return to Spire.Doc