# Acrobat Developer Center forum, where Adobe Acrobat developers discuss programming issues. Topics cover all Adobe related technologies, acrobat, Photoshop, After Effects, etc...

Keywords Adobe, Acrobat, SDK, create, bookmark, using, VB, NET

# How to create bookmark using VB.NET?

Goto page 1, 2  Next

AuthorMessage
Guest

 Posted: Wed Aug 06, 2008 7:18 am    Post subject: How to create bookmark using VB.NET? Hi,I've got a code to create bookmark in pdf file but I don't think only having this line of code we can't create bookmark. I am using vb.net to do this.Dim gApp As Acrobat.CAcroAppDim gPdDoc As Acrobat.CAcroPDDocDim gAvDoc As Acrobat.CAcroAVDocDim gPDBookmark As Acrobat.AcroPDBookmarkgPDFPath = "C:\sample.pdf"'Initialize Acrobat by creating App objectgApp = CreateObject("AcroExch.App")gPDBookmark = CreateObject("AcroExch.PDBookmark")' show AcrobatgApp.Show()'Set AVDoc object'gAvDoc = gApp.GetActiveDocgAvDoc = CreateObject("AcroExch.AVDoc")' open the PDFIf gAvDoc.Open(gPDFPath, "") ThengPDBookmark.setTitle("First") 'IS IT RIGHT?End IfCan you please help me to create the bookmark? If I get the code it would be really helpful.Thanks...!
Bernd Alheit
Guest

 Posted: Wed Aug 06, 2008 7:27 am    Post subject: Re: How to create bookmark using VB.NET? It is not possible to create a bookmark with OLE. You can try Acrobat JavaScript.
Guest

 Posted: Wed Aug 06, 2008 10:37 am    Post subject: Re: How to create bookmark using VB.NET? You can use the JSObject in IAC to run the javascript to create the bookmarks.
Guest

 Posted: Wed Aug 06, 2008 11:20 am    Post subject: Re: How to create bookmark using VB.NET? Thanks Bernd,I tried to get the code to create tbe bookmark but didn't get the exact one.jsObj = pdDoc.GetJSObjectBookMarkRoot = jsObj.BookMarkRootbok.createChild()If I get any related stuffs it would be helpful.Thanks..
Bernd Alheit
Guest

 Posted: Wed Aug 06, 2008 11:32 am    Post subject: Re: How to create bookmark using VB.NET? bok.createChild()What is bok? The method createChild requires the cName parameter.
Guest

 Posted: Wed Aug 06, 2008 12:06 pm    Post subject: Re: How to create bookmark using VB.NET? I would just usejso = pdDoc.GetJSObjectjso.bookmarkRoot.createChild ( "BookmarkName", "BookmarkAction" )bookmarkAction could be a script likethis.pageNum++
Guest

 Posted: Wed Aug 06, 2008 7:03 pm    Post subject: Re: How to create bookmark using VB.NET? Have a look at this:HTH, Reinhard
Guest

 Posted: Thu Aug 07, 2008 5:47 am    Post subject: Re: How to create bookmark using VB.NET? MANY THANKS to you all for taking the effort..I also got the code to create a bookmark using JSObject but the only issue is when I click on the link it is not going to the particular section since I didn't mention anything apart from this.I tried a lot to get the details about the same but I failed in this. So, again I am coming to you only.This is my code.Dim gPdDoc As Acrobat.CAcroPDDocDim gAvDoc As Acrobat.CAcroAVDocDim gPDFPath As StringDim JSO As ObjectDim BMR As ObjectDim BMC As Object'hard coding for a PDF to open, it can be changed when needed.gPDFPath = "C:\sample.pdf"'Initialize Acrobat by creating App objectgApp = CreateObject("AcroExch.App")' show AcrobatgApp.Show()'Set AVDoc objectgAvDoc = CreateObject("AcroExch.AVDoc")' open the PDFIf gAvDoc.Open(gPDFPath, "") ThengPdDoc = gAvDoc.GetPDDoc()JSO = gPdDoc.GetJSObjectBMR = JSO.BookmarkRootBMR.createchild("First Topic", "this.pageNum= 0", 0)End IfThanks...!
Guest

 Posted: Thu Aug 07, 2008 8:01 am    Post subject: Re: How to create bookmark using VB.NET? ...,"this.pageNum= 0",This is your bookmark - (JS) action. So if you click on the bookmark it goes to the first page (zero-based page numbering).If you want to go to a particular section by mouse-click on bm you have to look in the AJS-helpfile for the JS-code you need. I assume somthing like "named destination(?)".Best regards, Reinhard
Guest

 Posted: Mon Aug 11, 2008 11:08 am    Post subject: Re: How to create bookmark using VB.NET? Hi,I gone through AcroJS_DesignerJS.pdf, js_api_reference.pdf and js_developer_guide.pdf but I didn't get anything related to my requirement.As you mentioned, I need to point out the "named destination when we click on the bookmark so that it will move to that particular page and the particular topic will be shown.My requirement is, for example, I will have 3 headings and 2 sub- headings for each headings in a pdf file. When I open that pdf I need to create bookmarks using vb.net like,Heading 1 ' > It will be in 1st pageSub-Heading 1_1 ' > It will be in 1st pageSub-Heading 1_2 ' > It will be in 1st pageHeading 2 ' > It will be in 2nd pageSub-Heading 2_1 ' > It will be in 2nd pageSub-Heading 2_2 ' > It will be in 2nd pageHeading 3 ' > It will be in 3rd pageSub-Heading 3_1 ' > It will be in 3rd pageSub-Heading 3_2 ' > It will be in 3rdd pageWhen I click on a particular topic it should be directed to the corresponding destination. How can I set the destination using Javascript in VB.Net?Thank you.Regards,R. Prasanna
Bernd Alheit
Guest

 Posted: Mon Aug 11, 2008 11:59 am    Post subject: Re: How to create bookmark using VB.NET? You can use named destinations like:this.gotoNamedDest("chapter5");You can't add named destinations with Acrobat JavaScript.
Guest

 Posted: Mon Aug 11, 2008 1:14 pm    Post subject: Re: How to create bookmark using VB.NET? Assuming you PDF file has Named Destinations already included then the JavaScript would bethis.gotoNamedDest("MyNamedDest");Bookmark create script (assuming jso is your JSObject)jso.bookmark.createChild ("MyNamedDest", "this.gotoNamedDest(\"MyNamedDest\")");
Guest

 Posted: Mon Aug 11, 2008 1:37 pm    Post subject: Re: How to create bookmark using VB.NET? From where I can get these kind of details? After your reply only I am able to search with the word and implement it.How can we set the name to the destination before creating the bookmark?
Guest

 Posted: Mon Aug 11, 2008 1:50 pm    Post subject: Re: How to create bookmark using VB.NET? All of my responses have been taken from the JS_API_Reference.pdf document from the SDK. Although knowledge of the PDF spec and the SDK is required.The name of the destination is set when you create the destination, This cannot be created in the JavaScript, so it needs to be available in the PDF file before you create your bookmarks.For info on Destinations, see the Acrobat help, PDF Reference document.