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!
How to get "Bounding box" (inked area) |
Post Reply |
Author | |
ADev
Beginner Joined: 10 Feb 12 Status: Offline Points: 8 |
Post Options
Thanks(0)
Posted: 10 Feb 12 at 10:58AM |
Welcome,
I'm testing library v.8.13, Delphi, DCU. QP can get MediaBox,CropBox,BleedBox,TrimBox,ArtBox from PDF page. Any idea, how to get "Bounding box" (inked area) of PDF page without rasterizing? For example GhostScript can get this by: gs -dNOPAUSE -dBATCH -sDEVICE=bbox Result like this: %%BoundingBox: 14 37 570 719 %%HiResBoundingBox: 14.308066 37.547999 569.495061 718.319158 I'm try: 1. Detect Bounding box (?) 2. Crop page to Bounding box (crop to inked area, removing white margins) - by CapturePage,DrawCapturePage. How to detect Bounding box? Regards, Adam |
|
AndrewC
Moderator Group Joined: 08 Dec 10 Location: Geelong, Aust Status: Offline Points: 841 |
Post Options
Thanks(0)
|
QP.GetPageBox will allow you to get all the box values you need. SetRenderCropType will tell which box to crop when rendering. CapturePage will capture the entire PDF contents and it doesn't know how to crop white margins. You may have to reset the pages boxes manually to get the margin you need using QP.SetPageBox. Andrew. Andrew
|
|
ADev
Beginner Joined: 10 Feb 12 Status: Offline Points: 8 |
Post Options
Thanks(0)
|
Andrew, thank you for your answer.
In my pdf file (A3 page), GhostScript return: %%BoundingBox: 56 78 1119 772 %%HiResBoundingBox: 56.599100 78.070990 1118.497817 771.208992 QP results: page has only 1 box (QP.HasPageBox): MediaBox: 0,1191,842,1191,842,0 Pdf created by PdfCreator v. 1.2.3 (PdfCreator use GhostScript 9.04) BoundingBox from GhostScript has a good result. Any other ideas? Regards, Adam |
|
AndrewC
Moderator Group Joined: 08 Dec 10 Location: Geelong, Aust Status: Offline Points: 841 |
Post Options
Thanks(0)
|
I would need to see the PDF to make reasonable comment. It is a bit hard trying to guess without seeing the PDF file.
|
|
ADev
Beginner Joined: 10 Feb 12 Status: Offline Points: 8 |
Post Options
Thanks(0)
|
AndrewC
Moderator Group Joined: 08 Dec 10 Location: Geelong, Aust Status: Offline Points: 841 |
Post Options
Thanks(0)
|
If you open the PDF file in a text editor you will see that the only page box defined is the MediaBox.
4 0 obj <</Type/Page/MediaBox [0 0 842 1191] /Rotate 90/Parent 3 0 R /Resources<</ProcSet[/PDF /Text] /Font 8 0 R >> It is most likely that GhostScript is keeping track of the rendering process and is updating the bounding box as renders. Quick PDF Library doens't have this capability. It is impossible to calculate this value without parsing the full content stream which happens when you render the full file. You could get a very close approximation by rendering the PDF page to a Bitmap and then checking for pixels in all four directions until a non white pixel is found. Andrew. |
|
ADev
Beginner Joined: 10 Feb 12 Status: Offline Points: 8 |
Post Options
Thanks(0)
|
Ok Andrew,
thank you for your interest, I think, GS detect this bounduary by detect all bounduary objects (its faster an rasterizing complete objects), also with rasterizing fonts.. I can't use GS, the commercial problem exists for me. You are right, inked area is available after rasterizing all of page content. Im know about this topic But .. look in my first post : "Any idea, how to get "Bounding box" (inked area) of PDF page without rasterizing? " This is one of the key to my program. I can analyze bitmaps, but first I need to have the bitmap. Fast have .. My example file is small, but in reality I use large files (e.g. 900x2000 mm files, with raster and vector contents). Thank you for good intentions, I will seek further .. Edited by ADev - 12 Feb 12 at 10:48AM |
|
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