Possible to set the bleed and trim box? #59

Closed
opened 2021-04-25 19:58:23 +00:00 by josch · 0 comments
Owner

By Chris G on 2019-03-08T10:35:09.595Z

Is it possible to set the bleed and trim box values?


By josch on 2019-03-08T11:47:07.466Z


Please be more specific about what you request.


By Chris G on 2019-03-08T12:09:20.522Z


Hi Josch,

Currently we can set the pagesize e.g.

img2pdf --pagesize 1224.57ptx875.91pt ...

We are preparing files to go to print and need to specify the trim box and bleed box. It would be really handy to be able to pass these on the command line as well - maybe something like:

img2pdf --pagesize 1224.57ptx875.91pt bleedbox "top,left,width,height" trimbox "top,left,width,height" ...

An examaple output that we'd get from one of our pfds with everything set correctly:

pdfinfo -box print.pdf
Producer:       GPL Ghostscript 9.22
CreationDate:   Thu Feb 21 13:30:43 2019
ModDate:        Thu Feb 21 13:30:43 2019
Tagged:         no
Form:           none
Pages:          2
Encrypted:      no
Page size:      1224.57 x 875.91 pts (rotated 0 degrees)
MediaBox:           0.00     0.00  1224.57   875.91
CropBox:            0.00     0.00  1224.57   875.91
BleedBox:           8.50     8.50  1216.06   867.40
TrimBox:           17.01    17.01  1207.56   858.90
ArtBox:             0.00     0.00  1224.57   875.91

Thanks
Chris


By josch on 2019-03-08T12:27:17.588Z


Ah cool! Could you send me an example document implementing that?


By Chris G on 2019-03-08T13:48:00.446Z


Here you go:

pdfinfo -box test.pdf
Producer:       img2pdf 0.3.3
CreationDate:   Fri Mar  8 13:39:33 2019
ModDate:        Fri Mar  8 13:39:33 2019
Tagged:         no
Form:           none
Pages:          1
Encrypted:      no
Page size:      422.68 x 622.68 pts (rotated 0 degrees)
MediaBox:           0.00     0.00   422.68   622.68
CropBox:            0.00     0.00   422.68   622.68
BleedBox:           8.50     8.50   414.17   614.17
TrimBox:           17.01    17.01   405.67   605.67
ArtBox:             0.00     0.00   422.68   622.68
File size:      256851 bytes
Optimized:      no
PDF version:    1.3

I added the correct boxes using podofobox

test.pdf


By josch on 2019-03-08T14:16:37.866Z


I was not ware of the podofo tools. Thanks!


By josch on 2019-03-09T08:23:15.149Z


I'm wondering how to best implement this feature.

I don't like the idea to let the user freely specify these boxes because img2pdf is supposed to be just for the use-case of converting images to pdf and not a fully fledged pdf editor. If one wants to set the boxes precisely, then there is podofobox.

So I'm thinking about implementing this feature in the same way as the --border option was implemented. So instead of giving all four corners, one just gives the relative horizontal and vertical distance between the MediaBox. This would then also play nice with images of different sizes where each pdf page would have a different size.

Would that satisfy your use-case or do you need precise control of each coordinate of the boxes? If yes, why?


By Chris G on 2019-03-09T09:15:58.389Z


That would definitely satisfy my use case and would be ideal.

I'm sure there will be people out there who do need to control each coordinate, but I can't think of any obvious reason to do that and as you say if that's what you want then using podofobox is probably the right solution.


By josch on 2019-03-28T09:29:08.074Z


Mentioned in issue #61


By josch on 2019-04-02T05:40:20.245Z


Hi, could you test the version from git? Commit ed6187d5 should implement the feature you need. Try using the new --crop-border, --bleed-border, --trim-border and --art-border options.


By josch on 2020-04-05T13:18:41.904Z


This should be fixed in version 0.3.4


By josch on 2020-04-05T13:18:41.989Z


Status changed to closed

*By Chris G on 2019-03-08T10:35:09.595Z* Is it possible to set the bleed and trim box values? --- *By josch on 2019-03-08T11:47:07.466Z* --- Please be more specific about what you request. --- *By Chris G on 2019-03-08T12:09:20.522Z* --- Hi Josch, Currently we can set the pagesize e.g. ``` img2pdf --pagesize 1224.57ptx875.91pt ... ``` We are preparing files to go to print and need to specify the trim box and bleed box. It would be really handy to be able to pass these on the command line as well - maybe something like: ``` img2pdf --pagesize 1224.57ptx875.91pt bleedbox "top,left,width,height" trimbox "top,left,width,height" ... ``` An examaple output that we'd get from one of our pfds with everything set correctly: ``` pdfinfo -box print.pdf Producer: GPL Ghostscript 9.22 CreationDate: Thu Feb 21 13:30:43 2019 ModDate: Thu Feb 21 13:30:43 2019 Tagged: no Form: none Pages: 2 Encrypted: no Page size: 1224.57 x 875.91 pts (rotated 0 degrees) MediaBox: 0.00 0.00 1224.57 875.91 CropBox: 0.00 0.00 1224.57 875.91 BleedBox: 8.50 8.50 1216.06 867.40 TrimBox: 17.01 17.01 1207.56 858.90 ArtBox: 0.00 0.00 1224.57 875.91 ``` Thanks Chris --- *By josch on 2019-03-08T12:27:17.588Z* --- Ah cool! Could you send me an example document implementing that? --- *By Chris G on 2019-03-08T13:48:00.446Z* --- Here you go: ``` pdfinfo -box test.pdf Producer: img2pdf 0.3.3 CreationDate: Fri Mar 8 13:39:33 2019 ModDate: Fri Mar 8 13:39:33 2019 Tagged: no Form: none Pages: 1 Encrypted: no Page size: 422.68 x 622.68 pts (rotated 0 degrees) MediaBox: 0.00 0.00 422.68 622.68 CropBox: 0.00 0.00 422.68 622.68 BleedBox: 8.50 8.50 414.17 614.17 TrimBox: 17.01 17.01 405.67 605.67 ArtBox: 0.00 0.00 422.68 622.68 File size: 256851 bytes Optimized: no PDF version: 1.3 ``` I added the correct boxes using [podofobox](http://podofo.sourceforge.net/tools.html) [test.pdf](/uploads/cda44b8f25390c540348a221e87e2beb/test.pdf) --- *By josch on 2019-03-08T14:16:37.866Z* --- I was not ware of the podofo tools. Thanks! --- *By josch on 2019-03-09T08:23:15.149Z* --- I'm wondering how to best implement this feature. I don't like the idea to let the user freely specify these boxes because img2pdf is supposed to be just for the use-case of converting images to pdf and not a fully fledged pdf editor. If one wants to set the boxes precisely, then there is podofobox. So I'm thinking about implementing this feature in the same way as the `--border` option was implemented. So instead of giving all four corners, one just gives the relative horizontal and vertical distance between the MediaBox. This would then also play nice with images of different sizes where each pdf page would have a different size. Would that satisfy your use-case or do you need precise control of each coordinate of the boxes? If yes, why? --- *By Chris G on 2019-03-09T09:15:58.389Z* --- That would definitely satisfy my use case and would be ideal. I'm sure there will be people out there who do need to control each coordinate, but I can't think of any obvious reason to do that and as you say if that's what you want then using podofobox is probably the right solution. --- *By josch on 2019-03-28T09:29:08.074Z* --- Mentioned in issue #61 --- *By josch on 2019-04-02T05:40:20.245Z* --- Hi, could you test the version from git? Commit ed6187d5 should implement the feature you need. Try using the new --crop-border, --bleed-border, --trim-border and --art-border options. --- *By josch on 2020-04-05T13:18:41.904Z* --- This should be fixed in version 0.3.4 --- *By josch on 2020-04-05T13:18:41.989Z* --- Status changed to closed
josch closed this issue 2021-04-25 19:58:23 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: josch/img2pdf#59
No description provided.