11 Replies Latest reply on Nov 10, 2016 7:50 AM by Laubender

# PDF options

Hi everyone,

Is it possible to set a PDF to show bookmarks through scripting in InDesign (as in after exporting in the script, can you access the PDF DOM?)? Or does this need to be done directly in Acrobat?

I'd want to do the same as:  properties>navigation tab>bookmarks panel and page

Thanks

• ###### 1. Re: PDF options

Hi Jake,

As far as I know you can't do it from the InDesign side so you would either have to send the pdf to Acrobat with some more vbs and have acrobat set the view options or try hack the raw binary file pdf file.

In other words see what acrobat does to the binary file and see if you can emulate that.

It might be quite easy or it might be not practical.

Regards

Trevor

• ###### 2. Re: PDF options

Thanks Trevor, I'll do some experiments

• ###### 3. Re: PDF options

Hi

The hack method could be quite tough but the vbs looks simple.

The js method from the acrobat DOM is this.pane = 'Bookmark'; (or this.pane = 'B')

Might be bookmark with a small b, I can't rembember

The script they give there is

```Dim AcroApp
Set AcroApp = CreateObject("AcroExch.App")
AcroApp.Show()

Set objPDDocNew = CreateObject("AcroExch.PDDoc")
If objPDDocNew.Create() = False Then
MsgBox "Could not create new file"
End If

Set objPDDoc = CreateObject("AcroExch.PDDoc")
If objPDDoc.Open("C:\tmp\Untitled.pdf") = False Then
MsgBox "Could not open existing file"
Return
End If

lngPages = objPDDoc.GetNumPages
'MsgBox "Existing doc page num " & lngPages

'Add pages to new file
If objPDDocNew.InsertPages(-1, objPDDoc, 0, lngPages, True) = False Then
MsgBox "Could not insert pages"
End If

Dim jso
Set jso = objPDDocNew.GetJSObject
jso.app.alert(jso.author)
jso.addScript "DocScript", "function f() {app.alert('doc alert')} f();"
Set jso = Nothing

If objPDDocNew.Save(1, "C:\tmp\tmp.pdf") = False Then
MsgBox "Could not save"
End If

objPDDocNew.Close()
Set objPDDocNew = Nothing
objPDDoc.Close()
Set objPDDoc = Nothing
AcroApp.Hide()
AcroApp.Exit()
Set AcroApp = Nothing```

So I would guess if your created document variable is objDoc then in vbs one would do Set objDoc.Pane = "Bookmark"

HTH

Trevor

1 person found this helpful
• ###### 5. Re: PDF options

Hi Trevor,

Thanks for the link

I've made an action in Acrobat which does this, would it be easier to run the action using vb/javascript?

• ###### 6. Re: PDF options

I would guess vbs but I would advise asking on the acrobat scripting thread above.

Gilad (Try67) knows a lot more about acrobat workflow than me

• ###### 7. Re: PDF options

Hi Jake,

the following is not meant as a "solution", but a possible way one could explore.

And yes, it can be done with some ExtendScript, InDesign's printing to PostScript feature and distilling to PDF by using Acrobat Distiller. E.g. by writing to a Distiller hotfolder. Not by using export to PDF. But since you are using bookmarks created with InDesign and exported to PDF, this may not be reliable.

I'm speaking of pdfmark annotations that can be placed with one or several generic EPS files to InDesign pages.
But the interpretation of this kind of annotations for PDFs can only made by Acrobat Distiller when creating a PDF out of PostScript or EPS.

The basic code of the EPS file is very simple, pure text that can be written to a file with suffix ".eps".

The EPS file will be later placed by using ExtendScript's method place() . Simple as that.

Code for a minimal EPSF header:

```%!PS-Adobe-3.0 EPSF-3.0
%%BoundingBox: 0 0 72 72
%%EndProlog
```

Code for a minimal footer:

```%%EOF
```

Between header and footer can go the pdfmark annotation stuff. See here what's possible:

http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/pdfmark_reference.pdf

Especially:

Page 29:

Document open options (DOCVIEW)

A code like the one below inside an EPS will be translated by Distiller to include an instruction for Adobe Reader or Acrobat Pro to open the PDF with bookmarks showing:

```[ /PageMode /UseOutlines /DOCVIEW pdfmark
```

If your bookmarks are simple ones, e.g. from a TOC with an InDesign document, you could also extract the necessary information for "Title" and "Pagenumber" for every bookmark by using the ExtendScript DOM and build your own bookmarks with pdfmark instructions. See Page 26: Bookmarks (OUT)

It's a shame that InDesign's PDF Export will not evaluate pdfmark instructions that come with placed EPS files.

Regards,
Uwe

2 people found this helpful
• ###### 8. Re: PDF options

Very interesting, Uwe, be hear if it can be got to work

• ###### 9. Re: PDF options

Hi Trevor,

forgot a line of PostScript, that should be included before doing the pdfmark annotations in the EPS code.
That line will disable the pdfmarks when printed on a PostScript printer, because pdfmark code will throw an error with the PostScript RIP:

```/pdfmark where {pop} {userdict /pdfmark /cleartomark load put} ifelse
```

Regards,
Uwe

• ###### 10. Re: PDF options

Thanks for all your help, I'll have a look into this and if I find a solution I'll be sure to post it here

• ###### 11. Re: PDF options

Hi Jake,

if you want to explore the pdfmark route, see the following ExtendScript script by Muppet Mark that is distilling a PostScript file with Acrobat Distiller using some parameters:

You could also do a "Watched Folder" with Distiller where you move a PostScript file to.
Used together with a hotfolder from Acrobat Pro where you can run a preflight process automatically.

( That's also a note to myself :-) )

Regards,
Uwe