Print Page | Close Window

How to get the bounds of the visible page contents

Printed From: Debenu Quick PDF Library - PDF SDK Community Forum
Category: For Users of the Library
Forum Name: I need help - I can help
Forum Description: Problems and solutions while programming with the Debenu Quick PDF Library and Debenu PDF Viewer SDK
URL: http://www.quickpdf.org/forum/forum_posts.asp?TID=3760
Printed Date: 22 Nov 24 at 7:43PM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: How to get the bounds of the visible page contents
Posted By: Z3R0
Subject: How to get the bounds of the visible page contents
Date 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



Replies:
Posted By: Ingo
Date 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



-------------
Cheers,
Ingo



Posted By: Z3R0
Date 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



Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.01 - http://www.webwizforums.com
Copyright ©2001-2014 Web Wiz Ltd. - http://www.webwiz.co.uk