What dimensions do the coordinates in PDF cropbox refer to?

家住魔仙堡 提交于 2019-12-07 01:15:43

问题


If one has, for example, a pdf with the wrong page size specified one can crop away the unwanted portions of the document with ghostscript and the command parameter /CropBox. My question is, what do the numbers in the command refer to? I know they are point units (72nds of an inch) but what are their origins and axes?

By dint of trail and error from this example I've come up with following to keep an area approximately 6"x4" from the top left corner of a 11"x8.5" page (example source pdf). I'd like to do the math though and get my numbers precise instead of approximate (my final page needs to be landscape A6, 5.83"x4.13").

gswin64c ^
-o fixed-A6.pdf ^
-sDEVICE=pdfwrite ^
-c "[/CropBox [0 315 420 610] /PAGES pdfmark" ^
-f landscape-letter-size.pdf

Also, are the brackets [ ] supposed to be unbalanced? The opening [/Crop... doesn't have a corresponding close.


回答1:


They have the same origin as the other boxes defined in the Page object (eg default to units in Points with the origin to the lower left corner. You can see the PDF 1.7 documentation for further reference. There are some commands that can reside on higher level objects (Pages) that change the coordinate system by the way but those are rare (and when you create your PDF yourself with ghostscript you would know)..

Each number is referenced from the bottom left corner margin. So from the example 0 315 means 0pt from the left and 315pt above the bottom, and 420 610 is the opposite corner of the rectangle, from the same origin. [0 315 420 610] = rectangle (left bottom right top)

     ****************************************************
 610 ----------------------X 420,610                    *
     |                     |                            *
     |                     |                            *
     |                     |                            *
     |                     |                            *
     |                     |                            *
     |                     |                            *
     |                     |                            *
     |0,315                |                            *
 315 X----------------------                            *
     *                                                  *
     *                                                  *
     *                                                  *
     *                                                  *
     *                                                  *
     *                                                  *
     *                                                  *
     *                                                  *
   0 ****************************************************
     0                    420


来源:https://stackoverflow.com/questions/8158295/what-dimensions-do-the-coordinates-in-pdf-cropbox-refer-to

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!