More INX Tricks: Changing PDF pages and Layer Visibility
Recently I had to fix a problem with some multi-page PDFs placed in a bunch of InDesign files. Someone had the placed the right PDFs but the wrong pages, so I just needed to change which PDF pages were placed. Of course, you can choose which pages are placed initially, if you turn on Show Import Options in the Place dialog box. But once the PDF is placed, there’s no way to change the page through the user interface. There is at least one script floating around that does this sort of thing: Show PDF Options. But the files I was handed were in INX, so I was curious to see if I could just fix the problem there.
I looked in the INX to see where InDesign was storing the number of the visible PDF page. Not surprisingly, it’s in an element called PDFa. PDFa has three attributes: PageNumber (Pgnb), PDFPlaceCrop (DFcr), and TransparentBkgrd (TBkg).
At the end of the Pgnb attribute is a character which corresponds to the absolute page number in the PDF. If there are fewer than ten pages in the PDF, that character is the page number. If there are more than ten pages, things get more complicated. Letters replace numbers, so the 10th page is “a” the 11th page is “b” and so on. In my case, I wanted to place the 3rd page of the PDF in InDesign, I changed the number to 3.
If I could’ve edited the PDFs, I would’ve also had a couple other options (quoting from the InDesign Help):
- If you delete pages in the original PDF, the placed PDF page changes to the page that now falls on the originally placed page number.
- If you reorder the pages in the original PDF file and update the link, the placed PDF page (changes).
Serving Up Some Glop
I also had to change the layer visibility of some placed graphics. This is a doable task in the user interface, via Object > Object Layer Options. But since I was in INXville, I figured I’d see if I could take care of it while I was there. With a little poking around, I found the magic word. It’s not “please,” it’s “glop.”
Placed graphics are represented in <imag> elements with several child elements, one of which is <glop> (graphic layer option). To control the layer visibility in placed files, you manipulate the children of the glop element. Glop has child elements called <grlr> (graphic layer) which correspond to each layer in the placed graphic. So to change the current visibility of layers, you change the last letter of the crvi attribute, to either t(rue) or f(alse), as desired.
If you’re interested in figuring out how to hack INX files, and you don’t mind goofing around in glop, check out the InDesign CS3 SDK.
CS4 IDML
For the CS4 crowd (hopefully there’s a crowd or at least a crowdlet), these jobs are nearly identical.
To affect which page is placed from a multi-page PDF, change the value of the PageNumber attribute of the PDFAttribute element.
To change the visibility of layers in placed graphics, change the value of the CurrentVisibility attribute.



Hey Mike, thanks for this explanation – this was on my to-do list for today! If you download the ‘Show PDF Options’ script there is fix for CS3 in the notes below it.
Very cool. Mike, in the IDML example, which of the files contained in the .idml did you edit?
I edited spread.xml files. If you open the IDML package and look in the Spreads folder, you’ll see all the document spreads listed in order as separate XML files.
But, if the PDF or graphic is on a master page, then edit the files in the MasterSpreads folder.
This is awesome. Thanks for glopping around and digging up these tricks.
Note that you can also bypass the Show Import Options script trick by using the Show Import Options checkbox in the Relink dialog box, as mentioned here.
But the INX or IDML route lets you batch process many images quickly! Very interesting.
Is there a DTD or schema that you’ve seen to help you find these elements? Or did you just dig through it looking for elements and attributes that sounded like they’d work?
Jason-
There is no schema for INX, but the next best thing is a document called “ScriptingDefs.h”. Download the CS3 SDK, and look in source > public > includes. The document has a huge list of script classes, events, properties, etc which which translate those opaque little 4-letter codes.
As for IDML, you can get the schema here: http://www.adobe.com/devnet/indesign/docs/idml-schema.zip
Have fun!
>> At the end of the Pgnb attribute is a character which corresponds to the absolute page number in the PDF. If there are fewer than ten pages in the PDF, that character is the page number. If there are more than ten pages, things get more complicated. Letters replace numbers, so the 10th page is “a” the 11th page is “b” and so on. <<
I suspect that the page number is actually stored in hexadecimal text format, so that after “f” (fifteen) comes “10″ (sixteen). Otherwise, when you run out of alphabet, you run out of page numbers.
Thanks, Shmuel! I did wonder about that, but since I didn’t have to deal with it, I didn’t wonder too much.
I apologize for being late to the party again, but, what if I had a document with 1000 text frames all of the same size, and wanted to change to a specific size. Say from 100pts wide to 50pts wide. What would I look for in the code?
Hi,
I have a special question on idml.
How can I get the order of stories (display order textframe in indesign) ?
Robert-
I don’t know of an easy way to answer that.
TextFrame objects have attributes to define the ParentStory they belong to, and in the case of linked frames, a PreviousTextFrame and a NextTextFrame. There’s also an attribute called ItemTransform that lists an array of values to tell InDesign where on the spread the TextFrame sits.
You might want to look at the specification and cookbook documents on the Adobe Devnet.
Jose-
Sorry I missed your comment till now. You would have to manipulate the ItemTransform values on each of the TextFrame elements. It wouldn’t be a trivial task, but with some experimentation, I bet you could find the pattern of values to change.