Do you own a Debenu Quick PDF Library version 7, 8, 9, 10, 11, 12, 13 or iSEDQuickPDF license? Upgrade to Debenu Quick PDF Library 14 today!
![]() |
Cropping pages with QuickPDF Library |
Post Reply ![]() |
Author | |
Richard Langin ![]() Beginner ![]() ![]() Joined: 18 Mar 17 Location: Rome Status: Offline Points: 4 |
![]() ![]() ![]() ![]() ![]() Posted: 18 Mar 17 at 12:00PM |
I’m quite sure I’ve carefully perused QuickPDF’s documentation, examples, references (both developer’s and functions’), yet I could find neither a simple explanation nor an example of a simple and straightforward operation: cropping pages. I’ve read the definition of methods like SetCropBox and SetRenderCropType, still I couldn’t understand how actually cropping is performed, where “actually cropping” trivially means, e.g. : “QuickPDF, take page three in the document loaded into the library and crop it with these top, left, height, width parameters I’m giving you”. I assume this must be a very simple operation, hence I think / hope helping me will be easy and requiring a very short reply. Thank you very much. |
|
![]() |
|
tfrost ![]() Senior Member ![]() Joined: 06 Sep 10 Location: UK Status: Offline Points: 437 |
![]() ![]() ![]() ![]() ![]() |
Adding a crop box to a page does not change the underlying page, or delete any part of it from the file. As the documentation says, SetCropBox simply defines what part you want to be visible when you later display or print it. So there is no visible evidence that a crop box exists until you actually render the page to screen or file, or print it. That's how PDF cropping is done. Does that explanation help?
|
|
![]() |
|
Richard Langin ![]() Beginner ![]() ![]() Joined: 18 Mar 17 Location: Rome Status: Offline Points: 4 |
![]() ![]() ![]() ![]() ![]() |
First, thank you for your reply.
That’s the problem: I do understand that the crop box is an “invisible” setting, yet I can’t put it to work effectively. I tried to set a crop box in a document, but after closing the application supposed to change this box, I opened the document back in Acrobat Reader and could see no change in the pages. Getting straight to the point, may I ask you any example (or just a code snippet) which is supposed to actually crop the page, so that the document appears cropped next time I open it in a reader? Thank you for your attention & support.
|
|
![]() |
|
tfrost ![]() Senior Member ![]() Joined: 06 Sep 10 Location: UK Status: Offline Points: 437 |
![]() ![]() ![]() ![]() ![]() |
Sorry, though I have worked with crop boxes I do not have to hand an example which does just what you need, and at the moment do not have time to create one specially. If you are able to post a very simple piece of your own code, to load, apply a crop, and save a file, then someone here may be able to spot what is causing it not to achieve the result you expect.
|
|
![]() |
|
ukobsa ![]() Senior Member ![]() Joined: 29 May 06 Location: Germany Status: Offline Points: 115 |
![]() ![]() ![]() ![]() ![]() |
Richard,
here's a very simple sample:
But please be aware that visually you will see only a change, when crop box is inside or equal media box (simplified said). More general: what you see on screen is the intersection of Crop and Media box. HTH, Uli |
|
![]() |
|
tfrost ![]() Senior Member ![]() Joined: 06 Sep 10 Location: UK Status: Offline Points: 437 |
![]() ![]() ![]() ![]() ![]() |
If you see only the intersection, that is exactly what I would expect. Is it not what you expect? Here is an explanation from an Adobe manual I have (for PDF 1.7, dated 2008):
"The page object dictionary specifies these boundaries in the MediaBox, CropBox, BleedBox, TrimBox, and ArtBox entries, respectively (see Table 30). All of them are rectangles expressed in default user space units. The crop, bleed, trim, and art boxes shall not ordinarily extend beyond the boundaries of the media box. If they do, they are effectively reduced to their intersection with the media box. Figure 86 illustrates the relationships among these boundaries. (The crop box is not shown in the figure because it has no defined relationship with any of the other boundaries.)"
|
|
![]() |
|
tfrost ![]() Senior Member ![]() Joined: 06 Sep 10 Location: UK Status: Offline Points: 437 |
![]() ![]() ![]() ![]() ![]() |
I should add that your code works for me. I tried it on an A4 PDF and got a PDF 174.6mm by 261.8mm, with the edge strips of the original document missing.
|
|
![]() |
|
Richard Langin ![]() Beginner ![]() ![]() Joined: 18 Mar 17 Location: Rome Status: Offline Points: 4 |
![]() ![]() ![]() ![]() ![]() |
I haven’t applied your advice yet; in the meanwhile let me thank you all (Ukobsa
first) for your help. Gratefully.
|
|
![]() |
|
HNRSoftware ![]() Senior Member ![]() Joined: 13 Feb 11 Location: Washington, USA Status: Offline Points: 88 |
![]() ![]() ![]() ![]() ![]() |
I know this is a bit late, but I needed to do some "cropping" work and based it on ukobsa's example. I have discovered a few less-than-obvious things.
First is that the example code only changes the first page. It is necessary to use a page selection loop to change all of the pages -- that seems to work fine. Second - this does not actually "crop" anything out of the file -- all of the existing data on each page is still there and the file remains about the same size. I am guessing that the "SetCropBox" call just adds a small thing to each page telling it where the "useful" data is. Adobe Acrobat does recognize the "CropBox" and does more or less what you would expect. I'm not sure of exactly how it treats the cropbox on printing, but it is at least reasonable. Thanks - Howard Edited by HNRSoftware - 07 Apr 18 at 2:59PM |
|
![]() |
Post Reply ![]() |
|
Tweet
|
Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |
Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. About — Contact — Blog — Support — Online Store