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!

Debenu Quick PDF Library - PDF SDK Community Forum Homepage
Forum Home Forum Home > For Users of the Library > I need help - I can help
  New Posts New Posts RSS Feed - How to get "Bounding box" (inked area)
  FAQ FAQ  Forum Search   Register Register  Login Login

How to get "Bounding box" (inked area)

 Post Reply Post Reply
Author
Message
ADev View Drop Down
Beginner
Beginner


Joined: 10 Feb 12
Status: Offline
Points: 8
Post Options Post Options   Thanks (0) Thanks(0)   Quote ADev Quote  Post ReplyReply Direct Link To This Post Topic: How to get "Bounding box" (inked area)
    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
Back to Top
AndrewC View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 08 Dec 10
Location: Geelong, Aust
Status: Offline
Points: 841
Post Options Post Options   Thanks (0) Thanks(0)   Quote AndrewC Quote  Post ReplyReply Direct Link To This Post Posted: 10 Feb 12 at 12:01PM

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
Back to Top
ADev View Drop Down
Beginner
Beginner


Joined: 10 Feb 12
Status: Offline
Points: 8
Post Options Post Options   Thanks (0) Thanks(0)   Quote ADev Quote  Post ReplyReply Direct Link To This Post Posted: 10 Feb 12 at 1:28PM
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
Back to Top
AndrewC View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 08 Dec 10
Location: Geelong, Aust
Status: Offline
Points: 841
Post Options Post Options   Thanks (0) Thanks(0)   Quote AndrewC Quote  Post ReplyReply Direct Link To This Post Posted: 10 Feb 12 at 1:45PM
I would need to see the PDF to make reasonable comment.  It is a bit hard trying to guess without seeing the PDF file.

Back to Top
ADev View Drop Down
Beginner
Beginner


Joined: 10 Feb 12
Status: Offline
Points: 8
Post Options Post Options   Thanks (0) Thanks(0)   Quote ADev Quote  Post ReplyReply Direct Link To This Post Posted: 10 Feb 12 at 2:27PM
Thanks,
sample file (zip packed) is in:
Test pdf file
Back to Top
AndrewC View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 08 Dec 10
Location: Geelong, Aust
Status: Offline
Points: 841
Post Options Post Options   Thanks (0) Thanks(0)   Quote AndrewC Quote  Post ReplyReply Direct Link To This Post Posted: 11 Feb 12 at 2:22AM
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.


Back to Top
ADev View Drop Down
Beginner
Beginner


Joined: 10 Feb 12
Status: Offline
Points: 8
Post Options Post Options   Thanks (0) Thanks(0)   Quote ADev Quote  Post ReplyReply Direct Link To This Post Posted: 11 Feb 12 at 5:06PM
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
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.01
Copyright ©2001-2014 Web Wiz Ltd.

Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. AboutContactBlogSupportOnline Store