It is probable that I just don't understand PageBox/CropBox operations, but the results I get just don't make complete sense to me.
Pretty clearly, there are (or may be) "CropBox"es in a pdf file. If I load a file, select a page, set CropBox, save to file, -- something reasonable is set in the file, and Acrobat DOES respond sensibly to it, and subsequent QuickPDF load/render operations are sensible.
Also, pretty clearly, if I take that modified file, load it and select a page, a "GetPageBox" of type 2 (CropBox), does NOT return the modified page box, but does return a (0,0,w,h) type of box which seems to reflect what the first cropping operation did (effectively reducing the visible page size).
Taking the modified file and applying another cropbox operation to it and saving the file produces a significantly odd result of cropping the modified box, rather than re-cropping the original file page. This means that once cropped in the file, it can never be "uncropped" -- the window can only get smaller and smaller with subsequent file operations.
Specific problems: 1. I have not been able to set any pagebox on any page, save to file and then fetch any page box and see the modified values. Something does appear to be written to the file, I just can't fetch it back. 2. Since I can't retrieve the values from the file, I can't theorize what is happening, but a second, or subsequent load/setpagebox/save operation produces extremely odd results. 3. I can not find any sequence of operations that allow me to "un-crop" a page.
Some assumptions I am making (which may not be relevant) I'm using v15.11 library with Delphi 7, Windows 7 & 10.
1. "CropBox" is the same as "PageBox" type 2 (and use is interchangeable). I am not making that assumption during this testing, but I wonder if it is valid.
2. The various "boxes" are windows into the pdf file page, rather than actual cropping operations which would remove things that are not visible. 3. There are (or may be) each of those various boxes on each page. 4. I'm being very careful not to mix DA and non-DA operations. 5. I use a TopLeft origin, but none of my symptoms seem related to that.
6. I have not seriously tested the DA functions to see if they cause the same problems - had problems early in that line of testing and have not followed up.
Related oddities. 1. SetPageBox and DASetPageBox have different call sequences - the non-DA uses Left,Top,Width,Height and the DA uses X1,Y1,X2,Y2: which seems odd.
Footnote:
Kludge work-around. If I absolutely have to, I can keep a set of master pdf files and create copies, setting a CropBox in the copy. If I want to change the CropBox, I could copy the master file and set the cropbox to the different value. This would do what I need to do, but it doesn't seem "right". The "first" cropbox operation produces a sensible result, but modifying that resulting file does not work sensibly.
|