Adobe Acrobat SDK

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
   Adobe Acrobat SDK Forum Index -> Adobe Acrobat SDK
 
AuthorMessage
Prasanna_R (A_T) adobeforums.com
Guest





PostPosted: 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.CAcroApp
Dim gPdDoc As Acrobat.CAcroPDDoc
Dim gAvDoc As Acrobat.CAcroAVDoc
Dim gPDBookmark As Acrobat.AcroPDBookmark

gPDFPath = "C:\sample.pdf"

'Initialize Acrobat by creating App object
gApp = CreateObject("AcroExch.App")
gPDBookmark = CreateObject("AcroExch.PDBookmark")

' show Acrobat
gApp.Show()

'Set AVDoc object
'gAvDoc = gApp.GetActiveDoc
gAvDoc = CreateObject("AcroExch.AVDoc")

' open the PDF
If gAvDoc.Open(gPDFPath, "") Then
gPDBookmark.setTitle("First") 'IS IT RIGHT?
End If

Can you please help me to create the bookmark? If I get the code it would be really helpful.

Thanks...!
Back to top
Bernd Alheit
Guest





PostPosted: 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.
Back to top
malkyt (A_T) adobeforums.com
Guest





PostPosted: 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.
Back to top
Prasanna_R (A_T) adobeforums.com
Guest





PostPosted: 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.GetJSObject
BookMarkRoot = jsObj.BookMarkRoot
bok.createChild()

If I get any related stuffs it would be helpful.

Thanks..
Back to top
Bernd Alheit
Guest





PostPosted: 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.
Back to top
malkyt (A_T) adobeforums.com
Guest





PostPosted: Wed Aug 06, 2008 12:06 pm    Post subject: Re: How to create bookmark using VB.NET?

I would just use

jso = pdDoc.GetJSObject
jso.bookmarkRoot.createChild ( "BookmarkName", "BookmarkAction" )

bookmarkAction could be a script like

this.pageNum++
Back to top
Reinhard_Franke (A_T) adobeforums.com
Guest





PostPosted: Wed Aug 06, 2008 7:03 pm    Post subject: Re: How to create bookmark using VB.NET?

Have a look at this:

<http://groups.google.de/group/adobe.acrobat.sdk/browse_thread/thread/44c6c087ded64647/ea59571a8e0d438f?hl=de&lnk=gst&q=Reinhard#ea59571a8e0d438f>

HTH, Reinhard
Back to top
Prasanna_R (A_T) adobeforums.com
Guest





PostPosted: 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.CAcroPDDoc
Dim gAvDoc As Acrobat.CAcroAVDoc
Dim gPDFPath As String

Dim JSO As Object
Dim BMR As Object
Dim 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 object
gApp = CreateObject("AcroExch.App")

' show Acrobat
gApp.Show()

'Set AVDoc object
gAvDoc = CreateObject("AcroExch.AVDoc")

' open the PDF
If gAvDoc.Open(gPDFPath, "") Then
gPdDoc = gAvDoc.GetPDDoc()
JSO = gPdDoc.GetJSObject
BMR = JSO.BookmarkRoot
BMR.createchild("First Topic", "this.pageNum= 0", 0)
End If

Thanks...!
Back to top
Reinhard_Franke (A_T) adobeforums.com
Guest





PostPosted: 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
Back to top
Prasanna_R (A_T) adobeforums.com
Guest





PostPosted: 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 page
Sub-Heading 1_1 ' > It will be in 1st page
Sub-Heading 1_2 ' > It will be in 1st page
Heading 2 ' > It will be in 2nd page
Sub-Heading 2_1 ' > It will be in 2nd page
Sub-Heading 2_2 ' > It will be in 2nd page
Heading 3 ' > It will be in 3rd page
Sub-Heading 3_1 ' > It will be in 3rd page
Sub-Heading 3_2 ' > It will be in 3rdd page

When 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
Back to top
Bernd Alheit
Guest





PostPosted: 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.
Back to top
malkyt (A_T) adobeforums.com
Guest





PostPosted: 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 be

this.gotoNamedDest("MyNamedDest");

Bookmark create script (assuming jso is your JSObject)

jso.bookmark.createChild ("MyNamedDest", "this.gotoNamedDest(\"MyNamedDest\")");
Back to top
Prasanna_R (A_T) adobeforums.com
Guest





PostPosted: 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?
Back to top
malkyt (A_T) adobeforums.com
Guest





PostPosted: 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.
Back to top
arnaud_castel (A_T) adobeforums.com
Guest





PostPosted: Tue Oct 07, 2008 6:55 pm    Post subject: Re: How to create bookmark using VB.NET?

hi,
if you want to create bookmark, you should use JavaScript API.

with your exemple :

Dim gApp As Acrobat.CAcroApp
Dim gPdDoc As Acrobat.CAcroPDDoc
Dim gAvDoc As Acrobat.CAcroAVDoc
Dim gPDBookmark As Acrobat.AcroPDBookmark

gPDFPath = "C:\sample.pdf"

'Initialize Acrobat by creating App object
gApp = CreateObject("AcroExch.App")
gPDBookmark = CreateObject("AcroExch.PDBookmark")

' show Acrobat
gApp.Show()

'Set AVDoc object
'gAvDoc = gApp.GetActiveDoc
gAvDoc = CreateObject("AcroExch.AVDoc")

' open the PDF
If gAvDoc.Open(gPDFPath, "") Then

' create bookmark on page 1
JSO = gPdDoc.GetJSObject
BMR = JSO.BookmarkRoot
BMR.createchild("First Topic", "this.pageNum= 0", 0)

End If
Back to top
   Adobe Acrobat SDK Forum Index -> Adobe Acrobat SDKAll times are GMT
Goto page 1, 2  Next
Page 1 of 2

Related Topics