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 the bounds of the visible page contents
  FAQ FAQ  Forum Search   Register Register  Login Login

How to get the bounds of the visible page contents

 Post Reply Post Reply
Author
Message
Z3R0 View Drop Down
Beginner
Beginner
Avatar

Joined: 14 Mar 19
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote Z3R0 Quote  Post ReplyReply Direct Link To This Post Topic: How to get the bounds of the visible page contents
    Posted: 07 Nov 19 at 4:33PM
Hello,

for our product we're using the Debenu PDF Library Version 13.12 with Delphi source code. We have implemented a viewer to render PDF files and some predefined zoom factor values (fit width, whole page, etc.) based on the page bounds.

We now want to implement functionality like "fit visible", as known from other pdf viewer software.

I read about a BBox value at some adobe related site, but it seems to be a calculated value only.

In the library reference i found some functions for TextBlocks, which I use to walk over all TextBlocks of the current page, get their bounds and calculate the min and max values to create a rectangle with this information. A draw test has been completed successfully. But this may consume a lot of performance depending on the count of TextBlocks. Especially if I have to handle images the same way.

Is there a way to get the needed information by the library directly?

Thanks in advance. Smile
Back to Top
Ingo View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 29 Oct 05
Status: Offline
Points: 3524
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ingo Quote  Post ReplyReply Direct Link To This Post Posted: 07 Nov 19 at 10:09PM
Hi Zero,

perhaps (because i don't use the function by myself) GetPageContentToString could feed your needs?
https://www.debenu.com/docs/pdf_library_reference/GetPageContentToString.php

The best start for unanswered questions is the central search here:
https://www.debenu.com/docs/pdf_library_reference/Search.php

Cheers and welcome here,
Ingo



Edited by Ingo - 07 Nov 19 at 10:11PM
Cheers,
Ingo

Back to Top
Z3R0 View Drop Down
Beginner
Beginner
Avatar

Joined: 14 Mar 19
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote Z3R0 Quote  Post ReplyReply Direct Link To This Post Posted: 12 Nov 19 at 11:17AM
Hello Ingo,

thanks for your reply.

I looked at the suggested function and tested its output. Like the name says, it returns the raw pdf data for the selected content stream, so it have to be parsed completely. This will need a complete pdf parser.

A cropped example output for a content stream via GetContentStreamToString:


BT
/P <</MCID 0 >>BDC
/CS0 cs 0  scn
/TT0 1 Tf
-0.002 Tc 0.001 Tw 9.96 0 0 9.96 72 710.76 Tm
[(i)3(nc)-8(or)-6(por)-6(a)-12(t)-1(ed )-12(b)-12(y)16( r)-18(ef)-13(er)-6(enc)-8(e i)-9(n t)-1(h)-12(i)3(s)-8( E)2(U)-3(L)-12(A)2(.)]TJ
0 Tc 0 Tw 17.518 0 Td
( )Tj
EMC
/P <</MCID 1 >>BDC
-17.518 -1.157 Td
( )Tj
EMC

Another solution could not be found within the reference. So I think we have to use TextBlock-functions to get the needed information. For example GetTextBlockBound returns the bounding boxes for any text element, so min and max values can be calculated over all the bound values of the whole text content for a page.

Example output of my test function for a single text element via GetTextBlockBound:

TopLeft: (X: 72, Y: 71,22024)
TopRight: (X: 249,24816, Y: 71,22024)
BottomLeft: (X: 72, Y: 84,477)
BottomRight: (X: 249,24816, Y: 84,477)


We will process the other possible visible elements like images or form fields the same way and calculate the visible area over all the content bounds.

I hoped for a simpler solution approach.

Thanks anyway. Smile
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