generate table of contents

PDF-XChange Editor SDK for Developers

Moderators: TrackerSupp-Daniel, Tracker Support, Paul - Tracker Supp, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Ivan - Tracker Software, Tracker Supp-Stefan

Forum rules
DO NOT post your license/serial key, or your activation code - these forums, and all posts within, are public and we will be forced to immediately deactivate your license.

When experiencing some errors, use the IAUX_Inst::FormatHRESULT method to see their description and include it in your post along with the error code.
Post Reply
kyo
User
Posts: 130
Joined: Mon Oct 31, 2016 11:58 am

generate table of contents

Post by kyo »

Dear all,
My application need to generate a table of contents for pdf binder.

Does the Editor SDK support this functionality?

Any help will be appreciated,and sample code will be quite well.

I look forward to your quick reply.

Many thanks.
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: generate table of contents

Post by Sasha - Tracker Dev Team »

Hello kyo,

Well we do allow generating content. Though please describe the task more thoroughly - then I can assist further.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
kyo
User
Posts: 130
Joined: Mon Oct 31, 2016 11:58 am

Re: generate table of contents

Post by kyo »

Dear Alex,
I have uploaded a attachment to illustrate what I need.

For example:
In image 1.jpg,it show a hierarchical relations of folders and files.
In image 2.jpg,it show a table of contents according to the hierarchy as shown in 1.jpg.

so,I want the Editor SDK API to support a capability with which I can generate a table of contents as shown in 1.jpg.

Do you understand what I want now?

It will be appreciated that if you can provide me some sample code to achieve my goal.

I look foward to your reply.
Thanks in advance.
Attachments
table_of_cotents.rar
(4.32 MiB) Downloaded 114 times
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: generate table of contents

Post by Sasha - Tracker Dev Team »

Hello kyo,

The bookmark plugin allows generating a table of contents from the bookmarks. Please try the Build Table of Contents feature in the end-user Editor in the Advanced menu.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
kyo
User
Posts: 130
Joined: Mon Oct 31, 2016 11:58 am

Re: generate table of contents

Post by kyo »

Hello,
I wonder that if the table of contents serously dependes on the bookmarks.In others words ,if there is no bookmark created, the table of contents would be blank either.

Only the bookmarks are created, can we build the table of contents accordingly.

Is my understanding right?
User avatar
Will - Tracker Supp
Site Admin
Posts: 6815
Joined: Mon Oct 15, 2012 9:21 pm
Location: London, UK
Contact:

Re: generate table of contents

Post by Will - Tracker Supp »

Hi kyo,

That's correct the ToC is built using the bookmarks in the document. If there are no bookmarks, you will have a blank ToC.

Thanks,
If posting files to this forum, you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded.
Thank you.

Best regards

Will Travaglini
Tracker Support (Europe)
Tracker Software Products Ltd.
http://www.tracker-software.com
kyo
User
Posts: 130
Joined: Mon Oct 31, 2016 11:58 am

Re: generate table of contents

Post by kyo »

Hello,
Can you give me some advice about how to use the bookmark plugin to generate a table of contents.

At the moment,I can add a bookmark to the pdf as I want,but I still do not know how to generate the table of contents.


Any help will be appreciate and some sample code would be pretty welcome.

I am waiting for your response.

Many thanks.
User avatar
Will - Tracker Supp
Site Admin
Posts: 6815
Joined: Mon Oct 15, 2012 9:21 pm
Location: London, UK
Contact:

Re: generate table of contents

Post by Will - Tracker Supp »

Hi kyo,

If you're looking for assistance on doing this with the End User application, please see here:
https://help.pdf-xchange.com/pdfxe6/

If with the SDK, I'll have to leave Alex to advise there.

Thanks,
If posting files to this forum, you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded.
Thank you.

Best regards

Will Travaglini
Tracker Support (Europe)
Tracker Software Products Ltd.
http://www.tracker-software.com
kyo
User
Posts: 130
Joined: Mon Oct 31, 2016 11:58 am

Re: generate table of contents

Post by kyo »

Hello,
Thank you for your help.
I want to do this programmatically with the Editor SDK.
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: generate table of contents

Post by Sasha - Tracker Dev Team »

Hello kyo,

This is not available programmatically with the Editor SDK right now. Meaning that the appropriate operations can't be used and are not yet documented to use. You only can use the commands as you are using them in the End-User Editor. We are planning to add this in the future though.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
kyo
User
Posts: 130
Joined: Mon Oct 31, 2016 11:58 am

Re: generate table of contents

Post by kyo »

Hello,
I have got it.
By the way,which command can be used to generate the table of contents with Editor SDK ,or which command does the End-User Eidtor use?
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: generate table of contents

Post by Sasha - Tracker Dev Team »

Hello kyo,

Should be cmd.bp.toTOC

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
kyo
User
Posts: 130
Joined: Mon Oct 31, 2016 11:58 am

Re: generate table of contents

Post by kyo »

Hello,
Have you meant that there is no way to create a table of contents programmatically even with the latest released Editor SDK.
This is not available programmatically with the Editor SDK right now. Meaning that the appropriate operations can't be used and are not yet documented to use. You only can use the commands as you are using them in the End-User Editor. We are planning to add this in the future though.
I am a little confused about your reply- "You only can use the commands as you are using them in the End-User Editor".

I need to clarify one thing that can the Editor SDK generate a table of contents,no matter what measures(except via UI) be used ?

Under the current situaton,what is the proper workaround to generate table of contents without UI interface?

Until now, I have made little progress in the "table of contents" for many days.

I am waiting for your quick reply anxiously.
Thanks in advance.
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: generate table of contents

Post by Sasha - Tracker Dev Team »

Hello kyo,

There is a way - we give the possibility to create text content at the needed coordinates with needed styles and also we give the possibility to Insert pages. Basically you can do all of this on the Core Level by using the https://sdkhelp.pdf-xchange.com/vie ... wTextBlock method.
Here's the small sample on how to use this:
https://gist.github.com/Polaringu/10ccd ... d54f5072d2
Also, you can search the forums - there were such questions before.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
kyo
User
Posts: 130
Joined: Mon Oct 31, 2016 11:58 am

Re: generate table of contents

Post by kyo »

Hello,
There is a way - we give the possibility to create text content at the needed coordinates with needed styles and also we give the possibility to Insert pages. Basically you can do all of this on the Core Level by using the https://sdkhelp.pdf-xchange.com/vie ... wTextBlock method.
Here's the small sample on how to use this:
https://gist.github.com/Polaringu/10ccd ... d54f5072d2
Also, you can search the forums - there were such questions before.
I feel that the response has nothing to do with my question.Maybe, you have made a mistake that send a wrong message to me.

I did look for the solution for generating table of contents,not for inserting page etc.
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: generate table of contents

Post by Sasha - Tracker Dev Team »

I did give you a solution to your question. For now, the only possible way is to manually insert text and pages if needed to create the table of contents from code without using the UI.
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
kyo
User
Posts: 130
Joined: Mon Oct 31, 2016 11:58 am

Re: generate table of contents

Post by kyo »

Hello,
oh,I see.
Thanks.
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: generate table of contents

Post by Sasha - Tracker Dev Team »

:)
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
kyo
User
Posts: 130
Joined: Mon Oct 31, 2016 11:58 am

Re: generate table of contents

Post by kyo »

Dear All,

Code: Select all

private void addRotatedTextToolStripMenuItem_Click(object sender, EventArgs e)
{
  PDFXEdit.IPXC_Document doc = pxcInst.NewDocument();

  PDFXEdit.PXC_Rect rcMedia;
  rcMedia.left = 0;
  rcMedia.bottom = 0;
  rcMedia.top = 800;
  rcMedia.right = 600;
  PDFXEdit.IPXC_UndoRedoData urData;
  PDFXEdit.IPXC_Page page = doc.Pages.InsertPage(0, ref rcMedia, out urData);

  PDFXEdit.PXC_Rect rcText;
  rcText.left = 100;
  rcText.bottom = 600;
  rcText.top = 700;
  rcText.right = 300;

  PDFXEdit.IPXC_ContentCreator CC = doc.CreateContentCreator();
  PDFXEdit.PXC_Rect rcBlock;
  CC.TranslateCS(100, 0); //Shifting 100 by X axis
  CC.RotateCS(3.0); //3 degrees rotation
  CC.ShowTextBlock("Test Text Block Text", rcText, rcText, 0, -1, null, null, null, out rcBlock);  //draw text block
  page.PlaceContent(CC.Detach(), (UInt32)PDFXEdit.PXC_PlaceContentFlags.PlaceContent_After);

  pdfCtl.OpenDocFrom(doc);
}
I am working on generating a table of contents for pdf.
I intend to insert text and pages to the pdf manually, as you told me.And I decide to use the above sample code ,to add text to page.

Thus,I need some basic functions ,as follows,to achieve this:
1.how to get the added text size or rect (I need calculate the position of the text)?
2.how to set the font size,font color ,font style of the added text?
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: generate table of contents

Post by Sasha - Tracker Dev Team »

Hello kyo,

1) For the rectangle calculation use the ShowTextBlock method with the PXC_DrawTextFlags.DTF_CalcSizeOnly flag.
2) You will need to use the correspondent methods of the Content Creator to set the font size, color etc.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
kyo
User
Posts: 130
Joined: Mon Oct 31, 2016 11:58 am

Re: generate table of contents

Post by kyo »

1) For the rectangle calculation use the ShowTextBlock method with the PXC_DrawTextFlags.DTF_CalcSizeOnly flag.
2) You will need to use the correspondent methods of the Content Creator to set the font size, color etc.
I did not quite understand what you mean.
Please give me a simple code snippet to illustrate your approach that I can understand more easily.

1)I only want to mesure the text's size/rect ,but indeed,not add the text to pdf.How can I do this using ShowTextBlock method ?Please give me a code snippet.

2)How can I use Content Creator to the font size, color etc.?Please give me a code snippet.

Thanks in advance.
kyo
User
Posts: 130
Joined: Mon Oct 31, 2016 11:58 am

Re: generate table of contents

Post by kyo »

Hello,

Besides,I also want to know how to define a PXC_Rect variable whose size(left/top/right/bottom) is assigned according to the text's length and font size.

Thanks.
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: generate table of contents

Post by Sasha - Tracker Dev Team »

As I previously said:
1) The method will look the same, only the nFlags attribute should be PXC_DrawTextFlags.DTF_CalcSizeOnly. This will give the size of the text that you want to show but it will not show the text itself.
2) Look at the IPXC_ContentCreator methods SetFont, SetFontSize, SetColor etc. With this you are setting the Content Creator with specific parameters that will be used when showing text.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
kyo
User
Posts: 130
Joined: Mon Oct 31, 2016 11:58 am

Re: generate table of contents

Post by kyo »

Hello,
Ok,I have already got it.

Thanks.
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: generate table of contents

Post by Sasha - Tracker Dev Team »

:)
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
kyo
User
Posts: 130
Joined: Mon Oct 31, 2016 11:58 am

Re: generate table of contents

Post by kyo »

Dear All,
I have successfully generated a simple table of contents by adding text and inserting pages manually.

But all the items are static and can not be linked to the target page.

Now,what I want is that I need all the items are linked.That is to say,if a user clicks one of the items ,it can go to the correponding page like a hyperlink.

How can I implement my goal?

Thanks.
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: generate table of contents

Post by Sasha - Tracker Dev Team »

Hello kyo,

You will need to add the link annotation on page and copy the action list of the correspondent bookmark into it.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
kyo
User
Posts: 130
Joined: Mon Oct 31, 2016 11:58 am

Re: generate table of contents

Post by kyo »

Hello,
Can you give a simple code illustrate how to do this?
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: generate table of contents

Post by Sasha - Tracker Dev Team »

Hello kyo,

Please search the forums first. Here's how you can do that:
https://www.pdf-xchange.com/forum3 ... mit=Search
Scroll a little bit to the bottom and you will find Topic: InsertNewAnnot link

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
prasantha
User
Posts: 43
Joined: Fri Jun 24, 2022 8:15 am

Re: generate table of contents

Post by prasantha »

Sasha - Tracker Dev Team wrote: Wed Nov 16, 2016 11:34 am Hello kyo,

This is not available programmatically with the Editor SDK right now. Meaning that the appropriate operations can't be used and are not yet documented to use. You only can use the commands as you are using them in the End-User Editor. We are planning to add this in the future though.

Cheers,
Alex
Is this availble in pdf exchange ediot version 9.0,354?
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17810
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: generate table of contents

Post by Tracker Supp-Stefan »

Hello prasantha,

I would recommend you to give it a try - and see if the discussed features are available in that older build. If not - please contact sales@pdf-xchange.com and we will work with you on getting up to the current version.

Kind regards,
Stefan
prasantha
User
Posts: 43
Joined: Fri Jun 24, 2022 8:15 am

Re: generate table of contents

Post by prasantha »

Hi Stefan

Can you provide me sample code how to implement in using c#?

Thank you
Prasantha
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17810
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: generate table of contents

Post by Tracker Supp-Stefan »

Hello prasantha,

There are quite a few samples included in the SDK installation package. Please do take a look at those first, as I am not a developer myself and can not get you such samples from my end.

Kind regards,
Stefan
Post Reply