Scripting Acrobat

kaiserwilhelm

Well-known member
I have a very talented Indesign scripter on staff. The scripts he has written for our department save us hours every day. We are getting in more and more pdfs (supposedly run ready) from clients. In the commercial web press world, I must have .187 plate gap.
Is there a software, or do you think it is possible to have a script / hotfolder where a PDF is dropped and a KEYLINE of .187 is put on the document from all four edges? IE, 8.5 x 11 would have a KEYLINE color (set to overprint) added to the PDF that is .187 from the top, left, right, and bottom?
 
I don't think that can be done by scripting Acrobat alone. What I would do is import the PDF in InDesign, add your stroke frame all around and re-export as PDF. I've came with the following. Save the code as AppleScript application and drop any PDF on it's icon. It will open the PDF (or multiple PDFs that will process one at a time) to gather page number, PDF width and height, then place the PDF in InDesign, add the overprinting stroke all around and export a new "refried" PDF to a desktop folder named "Refried PDFs". I wasn't sure if you wanted the stroke weight to be added to the document size. Right now, the script will take a 8.5 x 11 PDF and center it into a 8.874 x 11.374. Tested it here and it works. You can also edit the code to attach it to a mac hot folder by using the "Configure Folder Actions" on your mac so as soon as a PDF will be dropped in, it will trigger the script.

--Script by Colorblind, tested with Acrobat X and InDesign CS5
on open pdf_list
set desktop_path_hfs to the path to the desktop as string
--the next variable sets the weight of the keyline
set keyline_weight to 0.187
repeat with mypdf in pdf_list
tell application "Finder"
activate
set dest_pdf_folder to desktop_path_hfs & "Refried PDFs:" as string
if not (exists dest_pdf_folder) then
make new folder with properties {name:"Refried PDFs"}
end if
set this_pdf_name to the name of mypdf
tell application "Adobe Acrobat Pro"
activate
open file mypdf
set b to get crop box of page 1 of active doc
set w1 to item 3 of b as integer
set w0 to item 1 of b as integer
set h1 to item 2 of b as integer
set h0 to item 4 of b as integer
set PDFheight to (h1 - h0) / 72
set PDFwidth to (w1 - w0) / 72
set pagecount to count every page of active doc
set idh to PDFheight & " i" as string
set idw to PDFwidth & " i" as string
close active doc without saving
end tell


set idpage to 1
set pdfpage to 1

tell application "Adobe InDesign CS5"
activate
set mydoc to make document
tell document preferences of mydoc
set facing pages to false
set page width to idw
set page height to idh
set pages per document to pagecount

end tell
repeat pagecount times
set page number of PDF place preferences to pdfpage

-- the "crop PDF" parameter can be changed to the following: crop content/crop art/
--crop PDF/crop trim/crop bleed/crop media/crop content/crop art/¬
--crop PDF / crop trim / crop bleed / crop media

set PDF crop of PDF place preferences to crop PDF

set mypdfpage to place mypdf on page idpage of mydoc
set idpage to idpage + 1
set pdfpage to pdfpage + 1
end repeat
end tell
end tell
set idpage to 1
set new_page_width to (PDFwidth + (keyline_weight * 2))
set new_page_height to (PDFheight + (keyline_weight * 2))
tell application "Adobe InDesign CS5"
activate
set my_final_destination to dest_pdf_folder
tell document preferences of document 1
set page width to new_page_width
set page height to new_page_height
end tell
tell document 1
try
set stroke_color to make color with properties {color value:{100, 0, 100, 0}, name:"Overprint Stroke"}
end try
repeat pagecount times
tell page idpage
set RectangleImage to (make new rectangle with properties {geometric bounds:{0, 0, new_page_height, new_page_width}})
set stroke weight of RectangleImage to (keyline_weight * 72)
set stroke alignment of RectangleImage to inside alignment
set overprint stroke of RectangleImage to true
set stroke color of RectangleImage to "Overprint Stroke"
set idpage to idpage + 1
end tell
end repeat
-- You can change "High Quality Print" to any other PDF preset
export format PDF type to my_final_destination & this_pdf_name using "High Quality Print" without showing options

end tell
end tell
end repeat
end open
 
I appreciate this script. I will give it to my INDD scripter to try. My only concern is "re-fring" the PDF. We work in an APPE format. I wonder what will become of my unflattened PDF??
Does anyone from Adobe know? I am SURE they will just gasp at the thought of going into INDD.
However, I might just use this as a way of making sure I have plate gap and then (if I do have plate gap), using the original PDF?
 
I appreciate this script. I will give it to my INDD scripter to try. My only concern is "re-fring" the PDF. We work in an APPE format. I wonder what will become of my unflattened PDF??
Does anyone from Adobe know? I am SURE they will just gasp at the thought of going into INDD.
However, I might just use this as a way of making sure I have plate gap and then (if I do have plate gap), using the original PDF?

Although the export folder is titled "refried", I personally do not consider *exporting* a PDF to be "refrying". I think of refrying as going to *PostScript + redistilling*. Exporting a PDF of a placed PDF from InDesign is not in the same class, even more so if one is using a PDF version format that does not flatten.

As mentioned toward the end of the script code, one can use any PDF export preset name, so it is possible to make a custom PDF preset setting to for use with this script (no jpeg, no resampling, no flattening etc).


Stephen Marsh
 
Colorblind, I tried the script with AcroPro9 & InDesign 5.

The script reports an error of "data is out of range". The PDF is placed on the ID page, however no stroke colour or stroke is applied and no export takes place (the output folder is empty).

P.S. Is there code to set the stroke attributes to overprint, rather than just the swatch name?

I like what you have done so far!

Stephen Marsh
 
I appreciate this script. I will give it to my INDD scripter to try. My only concern is "re-fring" the PDF. We work in an APPE format. I wonder what will become of my unflattened PDF??
Does anyone from Adobe know? I am SURE they will just gasp at the thought of going into INDD.
However, I might just use this as a way of making sure I have plate gap and then (if I do have plate gap), using the original PDF?

As Stephen said, placing PDFs into InDesign and re-exporting is _NOT_ refrying.
 
@ Leonard

Thanks for the clarification about "refrying".

@ Stephen

As I said, I tested the script here and it works but, as they say, programming is 10% coding and 90% debugging. Will try to have a look. As for you stroke attribute question, in the lines:

set RectangleImage to (make new rectangle with properties {geometric bounds:{0, 0, new_page_height, new_page_width}})
set stroke weight of RectangleImage to (keyline_weight * 72)
set stroke alignment of RectangleImage to inside alignment
set overprint stroke of RectangleImage to true

The variable RectangleImage is a reference to the rectangle (or frame) that will have the stroke applied to so the line "set overprint stroke of RectangleImage to true" will overprint the stroke.

I quickly wrote another script that should set all strokes of rectangles, text frames and polygons in any open InDesign document to overprint, (your mac should beep 3 times when it's done) but as I mentioned earlier, writing the code is only 10% of the work :) so forgive me if it doesn't work perfectly on your machine.
That being said, thumbs up to Adobe for implementing so well AppleScript into InDesign and Photoshop.

set volume 5
tell application "Adobe InDesign CS5"
activate
set dc to 1
set doc_count to (count every document)

repeat doc_count times
tell document dc
tell layout window 1
set overprint preview to true
end tell
--this is to ungroup all groups or else strokes that are in a group wont overprint
repeat
set my_groups to get every group
if the result is {} then exit repeat
if my_groups is not {} then
repeat with this_group in my_groups

ungroup this_group
end repeat
end if
end repeat
--end of code to ungroup
set my_rectangles to (every rectangle whose stroke weight is not 0.0)
set my_frames to (every text frame whose stroke weight is not 0.0)
set my_polygons to (every polygon whose stroke weight is not 0.0)


repeat with this_frame in my_frames
try
get this_frame
set overprint stroke of this_frame to true
end try
end repeat
repeat with this_rectangle in my_rectangles
try
get this_rectangle
set overprint stroke of this_rectangle to true
end try
end repeat
repeat with this_polygon in my_polygons
try
get this_polygon
set overprint stroke of this_polygon to true
end try
end repeat
end tell
set dc to dc + 1
end repeat
end tell
beep 3
 
Last edited:
Hey, I'm just happy to be a senior member now! Guess it comes when you have the only CiPress 500 digital web press in the nation sitting five feed from your Mac!
 
Leonard, I am shocked! Pleasantly shocked! I thought for SURE you would say that that is not a proper way to make a pdf.
Are you giving me the Adobe blessing to place a pdf in (1.7) and export back out (1.7)?? I might just owe you a beer and or Coke if so.
 
@ Stephen

As I said, I tested the script here and it works but, as they say, programming is 10% coding and 90% debugging. Will try to have a look. As for you stroke attribute question, in the lines:

The variable RectangleImage is a reference to the rectangle (or frame) that will have the stroke applied to so the line "set overprint stroke of RectangleImage to true" will overprint the stroke.

Thank you Colorblind for pointing out the part of code about overprinting (obvious now that you point it out).

And thanks for the script, it is appreciated and I do understand the issues with scripting and coding - so I am grateful for what you have done for the community in this script! As the script errors out before making the spot colour, I am guessing that the problem is somewhere there in the code...

You have done all the heavy lifting, it is not hard to simply add a new layer above the default and to then create the colour and apply the stroked overprinted frame to this new layer on the master page - then export.


Best,

Stephen Marsh
 
Last edited:
The only problem I can see is it will be harder to trace such a file since it will say that InDesign was creator of the PDF irrespective of the source of the original PDF, but I'm thinking that is just a minor thing to be aware of.
 
Leonard, I am shocked! Pleasantly shocked! I thought for SURE you would say that that is not a proper way to make a pdf.
Are you giving me the Adobe blessing to place a pdf in (1.7) and export back out (1.7)?? I might just owe you a beer and or Coke if so.

Placing a PDF into InDesign(!) and then exporting it is as PERFECTLY REASONABLE thing to do. BE AWARE, that I am saying this ONLY about InDesign and NOT the general case.

and I never turn down free beer :).
 
The only problem I can see is it will be harder to trace such a file since it will say that InDesign was creator of the PDF irrespective of the source of the original PDF, but I'm thinking that is just a minor thing to be aware of.

In the document-level metadata, that is true. However, the original PDF's metadata will be carried as "object level" metadata in the PDF.
 
leonard,

Should I ever meet you, Sam Adams Octoberfest on me.
I am still blown away that PDF into INDD back into PDF is safe! FANTASTIC!
 
I am still blown away that PDF into INDD back into PDF is safe! FANTASTIC!

"Safe" is a bit relative. I commonly see issues with PDFs that are handled this way. My RIPping front-end will cite an error about being unable to locate a xObject. The page itself, when opened in Acrobat, will display a pop-up saying that an error exists on the page. I haven't been able to isolate the problem.
 
"My RIPping front-end will cite an error about being unable to locate a xObject. The page itself, when opened in Acrobat, will display a pop-up saying that an error exists on the page. I haven't been able to isolate the problem.

Rich, I believe you're using ApogeeX, am I right? So do I and at some point I was sometimes getting these "xObject" pop-ups in Acrobat when opening a composite PDF that was generated and trapped by ApogeeX (using PDF-Ready TP). When ApogeeX wasn't trapping the file I wouldn't get that error in Acrobat. I tried different things and the only way I could get final composite trapped PDFs out of ApogeeX was by using 2 different hot tickets, the first one would just trap incoming ps and export a trapped ps file to a second hot ticket that would then normalize the trapped ps and export a trapped composite PDF. So in my case it's clear it had nothing to do with InDesign, ApogeeX was the culprit.
 
Yep, ApogeeX. I'm not using PDF-Ready, though.

My situation comes about when PDFs, say advertisements, are placed into a publication being built in InDesign and then exported out as new PDFs. I need to find one of these situations and play with export settings to see if something in there is causing the issue.

I've had to come up with a work-around recently, that begins to close in on the issue. The problematic pages tend to have raster images with transparency. Think of the kind of images that you would've created bit-maps of in the past.
 

PressWise

A 30-day Fix for Managed Chaos

As any print professional knows, printing can be managed chaos. Software that solves multiple problems and provides measurable and monetizable value has a direct impact on the bottom-line.

“We reduced order entry costs by about 40%.” Significant savings in a shop that turns about 500 jobs a month.


Learn how…….

   
Back
Top