Copy link to clipboard
Copied
We have PDF files that are generated using PHP to send to a printing company. The printing company want us to add Bounding Boxes in these PDFs but with the technologies we're using, there's no way to add them without having the box visible on print paper. Also, since the number of PDFs generated are dynamic, it'll take a lot of work for them to add the Bounding Boxes manually.
I'm new to Adobe Acrobat SDK, does anyone know if there's a way to achieve the following tasks:
1. Loop through each existing PDFs
2. Add / Identify the Bounding Box
3. Save file with newly added Bounding Box
4. Move to the next PDF
The PDFs each have 2 pages, each page is 336.35mm x 226.35 (with 3.175 mm Bleeds - 6.35mm total), Finished size is 330mm x 220mm. Also, assuming if the bounding box is successfully added, will it be visible in printing paper?
Thank you.
Copy link to clipboard
Copied
What does the printing company mean by a “bounding box”? That isn’t a formal term for PDF
Copy link to clipboard
Copied
I think it's a trim box in PDF, based on this image.
Copy link to clipboard
Copied
Looks like they want you to set the trim box AND bleed box rectangles. These boxes are not visible unless you also set page content. Other information shown is just page content. You could set the boxes in Acrobat but absolutely not from PHP, as Acrobat isn't licensed for server use.
Copy link to clipboard
Copied
I understand that there's no way to achieving this in PHP, which is why we're looking into alternatives that will satisfy all tasks as described in my original post. If you have insights on any of them please share.
Copy link to clipboard
Copied
Well, I am initially concerned that you are talking about PHP – since that is a server-side language and Acrobat is not licensed for use on a server. So that would pretty much make any recommendation we give you a non-starter.
Of course, if you are going to develop this locally on a desktop machine – then Acrobat can indeed do the job.
Copy link to clipboard
Copied
PHP doesn't natively support PDF so it's incorrect to say that "there's no way to achieving this in PHP". Of course there is a way, you just need to use the right PHP library to generate the PDF. Which PDF Library are you using? For what it's worth, dompdf does add a media box to each page.
Copy link to clipboard
Copied
lrosenth wrote
What does the printing company mean by a “bounding box”? That isn’t a formal term for PDF
Isn't that what "BBox" means, for example in the getPageBox method in JS?
Copy link to clipboard
Copied
There is a curious story here. document.getPageBox can get the CropBox, ArtBox, TrimBox or BleedBox for a page. To that add MediaBox which you get another way. All of these are well defined concepts in PDF, and they are stored in the PDF for each page. (Or, there are rules for what to use if the box is missing, a heirarchy of defaults which all devolve to MediaBox, which is always present). You can also use setPageBox for all of these. So far so good. Now we come to BBox, which the documentation notes...
"Note that the BBox box type is read-only and only supported in getPageBox". So you can't set it, but why not?
Actually lrosenth is entirely right, it isn't a formal term for PDF pages. Read the PDF specification and it is never mentioned for pages. (It appears for certain other kinds of thing, such as form XObjects and fonts, but that doesn't help us). Yet, the documentation for document.getPageBox states "For definitions of these boxes see the PDF Reference version 1.7." This is simply wrong for the case of BBox, but right for all the others.
So, what is BBox? It doesn't tell us. But the term Bounding Box comes to use from EPS where "the bounding box is the smallest rectangle that encloses all the marks painted on the single page of the EPS file." In EPS this is needed to tell apps how large the box is to place it on a page. It is defined unambiguously, though some developers choose to ignore this definition and set it to some other rectangle that suits them, but they are wrong, and everyone gets it wrong for bezier curves: but I digress.
So I am going to GUESS what getPageBox means by BBox. I guess it is the result of looking at all the graphics on the page, getting each graphic's bounding box, and giving the box that contains all graphics. Because it is calculated it can't be set. (Unlike in EPS where it is present, and required to be an accurate reflection of what is in the file). Different apps might produce different results in some cases.
So... coming around to the original problem: if someone says you need to "set the bounding box" for a PDF file, it doesn't mean anything. They all have one, and you don't set it. Notice in the example that the BBox will enclose all the marks and captions on the page. So I'd be included to agree they actually want BleedBox and TrimBox set.
Copy link to clipboard
Copied
Yes, I remember wondering why it was not available in the setPageBoxes method... Thanks for the clarification and the story behind it!
Speaking of which, it's a pretty bad name, as that method can only set one type of box at a time, but for multiple pages, so why the plural form on "box" and not on "page"? If anything it should be setPagesBox or setPagesBoxes, but I digress...
Copy link to clipboard
Copied
Honestly these concepts are totally new to me so my apology for the misleading term there. What they want is definitely a trim box and yes, there're no way of doing so in PHP. This is why I'm looking into Adobe SDK, hopefully there would be a way to do so programatically. Is it possible to achieve this in JS?
Thanks for the clarification.
Copy link to clipboard
Copied
There is nothing in the PDF itself about a “bounding box” – there are other known page boxes (MediaBox, CropBox, etc.) but not a bounding one. On the other hand, for things like Form XObjects, there is a bounding box (BBox).
Now, you mention a TrimBox – there is a TrimBox for each page. That can most certainly set using the Plugin APIs of the SDK.
Copy link to clipboard
Copied
Now, you mention a TrimBox – there is a TrimBox for each page. That can most certainly set using the Plugin APIs of the SDK.
Will this satisfy all tasks as described in my original post? If yes please point me to the documentations and tools needed to set this up.
Thank you