Skip to main content
Participating Frequently
February 17, 2014
Question

Getting the offset of a placed PDF within the container rectangle

  • February 17, 2014
  • 1 reply
  • 3678 views

I need to get the offset of a placed PDF inside of the container rectangle. I have figured out that this information should be available in the transformationMatrix of the placed file. So I do something like:

var pdfTransform = pdf.transformValuesOf(CoordinateSpaces.pasteboardCoordinates)[0];

var horzTranslation = pdfTransform.horizontalTranslation;

var vertTranslation = pdfTransform.verticalTranslation;

but the coordinates I get back are just weird. The horizontal value seems reasonable, but the vertical is way off what I expect.

There may be some precondition to doing this that I'm missing. Running the pageitems/TransformValuesOf.jsx sample from the Scripting Guide also gives weird values. That sample creates a rectangle with a center point of [0, 0] and then retrieves the transform. I would expect the translation to be [0, 0] but I actually get [5, -415.95] (horz, vert).

In that sample it talks about ruler coordinates, so I tried setting document.viewPreferences.rulerOrigin to different values, but that does nothing.

I'm stumped. Can someone please give me a hint on what's going on here?

This topic has been closed for replies.

1 reply

svenaxAuthor
Participating Frequently
February 20, 2014

Anyone?

Community Expert
February 20, 2014

What about the zero point? Reset it using myDoc.zeroPoint = [0,0], then try again.

If that doesn't help, maybe try comparing the geometricBounds of the PDF and those of its parent, the containing rectangle.

Peter

svenaxAuthor
Participating Frequently
February 27, 2014

The scripting model provides these crop types:

app.pdfPlacePreferences.pdfCrop = PDFCrop.cropArt

. . .cropPDF

. . .cropTrim

. . .cropBleed

. . .cropMedia

. . .cropContentAllLayers

. . .cropContentVisibleLayers

When I place a cropped PDF, the last two add a margin such as you describe, but the first four all place the PDF exactly cropped. What happens when you use the first four crop types?


Here's the deal - I am not the one creating the documents, and I have no control over the options used. Trying the different crop options available when placing a PDF using InDesign GUI, the first four (I am assuming cropPDF is the one called Crop here) places the PDF with the full margins from the file.

I just tried to export the InDesign document in IDML format, to see everything that InDesign knows about the objects. Here I find something called FrameFittingOption that looks like it could be relevant. Anyone know what this is and how I can access it from my script?