IT WORKS!! IT ACTUALLY FLIPPINWELL WORKS!!
This is, in part, code I have been using for 4 or 5 days, but I had never added the last line. If anyone wants a file to test, let me know, but my test file of 4 images on one page, all the same, with the top left image with a surrounding crop box, gets trimmed to the crop box.
Still got to make sure multi-page document pages all trim individually, but really, success.
A BIG, BIG THANK YOU TO EVERYONE, but especially Steve McCarthy, and Extra Special Thanks to Shane & Yvan, who have worked so bloody HARD to help.
Regards
Santa
tell application "Adobe Acrobat" tell active doc repeat with i from 1 to count of pages tell page i # set temp to {} set temp to crop box as list if (count of temp) ≤ 1 then set temp to bounds as list if (count of temp) ≤ 1 then set temp to media box as list if (count of temp) ≤ 1 then set temp to art box as list if (count of temp) ≤ 1 then set temp to trim box as list if (count of temp) ≤ 1 then set temp to bleed box as list set crop box to temp set bounds to temp # set media box to temp # end tell end repeat end tell end tell
On 9 Jan 2017, at 3:38 pm, Brian Christmas < email@hidden> wrote:
G’day EVERYONE
The past 9 years have seen me try many different ways of printing Acrobat images, rather than using Acrobat per sey, and all have failed to re-produce the EXACT image my Clients Clients send in the first place. The worse of the whole bunch was GraphicConverter, which, 3 years ago, offered THREE different interpretations of Acrobat PDF’s, NONE of which reproduced the original image exactly. And I had extensive communication with Thorsten Lemke over the hassles. However, the new posting under Acrobat PDF cropping script by Steve offers me new hope. I have NEVER tried just setting the Media Box to the crop box (or whatever if the crop box is not set) and saving.
Investigations underway. I’ll keep you all informed once I find the time to test.
BTW, repaired iMac delivered and installed. She’s now got to to get fixed wireless Internet, being alone on a farm. Paired with Android (shudder) phone for temporary access. It’s my 7th give-away. Supposed to be a lucky number.
Regards
Santa On 9 Jan 2017, at 10:37 am, Robert Poland < email@hidden> wrote:
On Jan 8, 2017, at 1:33:PM, Brian Christmas <email@hidden> wrote:
G’day Shane & Yvan
Seems that I’ve stirred up a hornets nest concerning my need to really ‘crop’ PDF’s.
It’s critical that I do so with the utmost accuracy, and any failure to ‘crop’ or ‘trim' to the crop is costing my Clients a LOT of money. They’ve only let me know about this recently, after years of putting up with no trimming, and wearing the extra cost, without telling me.
I’m in a bind. My present GUI method is slow, yet I’m under a directive to keep the speed of processing to a maximum. My GUI method has greatly slowed down PDF processing.
I’m not absolutely sure that either of your methods will be acceptable, despite the amount of work you’ve kindly put in.
I must MUST maintain quality, and I MUST trim. The saving as TIFFS seems, at least with my tests, to have maintained the original quality (hadn’t checked file sizes, thanks for that tip, Shane, 1,143,674 bytes). The TIFFS are trashed after use.
Saving as JPEG does not always trim, and I don’t know why, but I’m resorting to it if the resultant TIFFS are too large. I’m also presuming if the TIFFS are too large, then they are full page, with no crop box.
I’ve been investigating Java, which can save PDF’s as pages, but I don’t know if it trims to the crop box when doing so.
Shane, the extra four text boxes, two with Barcodes, are being added via _javascript_.
Regards, and many, many thanks,
Santa
On 8 Jan 2017, at 10:37 pm, Shane Stanley <email@hidden> wrote:
On 8 Jan 2017, at 9:29 pm, Yvan KOENIG <email@hidden> wrote:
There is a huge difference. Although they are twice big than files given by the "old" one they display VERY LESS crisp characters.
That's right.
Here's Brian's original summary:
Sometimes our clients send large images, with a crop box, and images outside the crop box.
We only want to print what's in the crop box, but to fit the extra 4 text boxes on the image, I have to enlarge its boundaries.
This sometimes reveals (and prints) the extra image components that the sender has not cropped.
In other words, he wants to completely remove any items outside the PDF crop boxes -- and there's no way to do that (with the tools at hand).
The compromise he is using is to make bitmaps of the PDF pages, which *can* be cropped to the crop box. These bitmaps can then be saved in PDFs, to which he can add the other material.
The result is much bigger files and potentially lower quality, as you have seen. (The quality can be increased by making the files even bigger.)
But there's not much choice -- if he just exports the pages as your code does, the unwanted components will still remain on the page, and will (re)appear when he resets the crop bounds to add the other images. The same thing will happen if he exports them using Acrobat or Smile.
It may be that another workaround would be to first add white boxes to mask the extra area before adding the other items -- that would retain the quality. But I don't know how Brian's adding them, so I don't know how feasible it would be.
(Another workaround would be to place the PDF on a page in InDesign, cropped to the crop box, add the other items, and then export the page as a PDF.)
-- Shane Stanley <email@hidden> <www.macosxautomation.com/applescript/apps/>, <latenightsw.com>
I've been using GraphicConverter (without scripting) for years to edit the graphic content of PDFs.Robert PolandFort Collins, CO
|