Copy link to clipboard
Copied
Hello,
A portion of my script is reponsible for iteratring allGraphics, and and doing some inspection of their constituent image data. If certain conditions match, the graphic is exported as a JPEG image.
I've encountered an interesting problem whereby an artist has set a 2-page InDesign document using a 2-page PDF. On page 1 of the indd document, a rectangle is set, and they have placed PDF page 1 as its graphic.
The same is true for page two. The artist has placed, again, this same 2-page pdf, but on page two of the indd, its rectangle uses page 2 of the pdf. Neat lazy trick, I think. Rather than have two links in their document, they have simply used the same asset, twice, and simply arranged the pdf in such a way that it can be used twice. Cute trick.
But that cute trick is giving my graphic exporter fits. When it reaches that link, and its graphic, it is only exporting page one of it.
I am seeking help here in this forum to determine how to address the graphic, and get it to export both pages.
When I export a multi-page indd as JPEG, I have access to jpegExportRange. I use ExportRangeOrAllPages.EXPORT_RANGE, and I specify app.jpegExportPreferences.pageString = [1,2,3,4,5], etc, and indesign dutifully exports that page to a jpeg. The exported JPEG filename, of course, includes that page number; eg: indd-document-page-1.jpg, indd-document-page-2.jpg, and so on.
Well, this strategy is not working for the Link graphic. I can see that the graphic PDF has two pages when I inspect graphic.pdfAttributes.pageNumber. But when I export that Link Graphic to the filesystem, as a JPEG (or other format), I only receive page 1.
Thanks for any insights you might have.
Copy link to clipboard
Copied
<facepalm>
Filename is important. And, reading comments I wrote into this script 8 years ago...
Apparently, a client I had during the Obama administration had an interesting edge case. To resolve this, just prior to export, I actually removed the link, and re-placed it. Likely to clear out fitting options. I wanted the whole graphic, but this client had done some interesting fitting options that was obsucring parts of the image. So, I blew away the link graphic, and re-placed it.
That action screwed up the 2nd phase, the actual graphic export.
tl;dr: Comment your code well. Read your old comments. Heed your own warnings from your younger self.
{sigh}
Copy link to clipboard
Copied
Hi @jeffmlevy ,
I have setup 2 pages document as below.
export2jpg();
function export2jpg() {
if (!(app.documents.length)) return;
app.jpegExportPreferences.properties = {
jpegColorSpace: JpegColorSpaceEnum.RGB,
jpegExportRange: ExportRangeOrAllPages.EXPORT_ALL,
jpegQuality: JPEGOptionsQuality.MAXIMUM,
}
var __ = $.global.localize,
doc = app.documents[0],
docFile = new File(doc.fullName),
docPath = docFile.parent,
jpgPathPattern = docPath + "/indd-document-page-%1.jpg";
var re = /\.pdf$/i, link, rectangle, page, pageName;
for (var i = 0, links = doc.links, n = links.length; i < n; i++) {
link = links[i];
if (re.test(link.name)) {
rectangle = link.parent.parent;
if ((page = rectangle.parentPage)) {
pageName = page.name;
rectangle.exportFile(ExportFormat.JPG, new File(__(jpgPathPattern, pageName)));
}
}
}
}
Generated 2 separate jpg file