Do you own a Debenu Quick PDF Library 12/11/10/9/8/7? Upgrade to Debenu Quick PDF Library 13!

Foxit Quick PDF Library

Frequently Asked Question:

Return to FAQ Index

How can I programatically find out if text is inverted or rotated?

Question

How can I programatically find out if text is inverted or rotated?

Answer

The GetPageText(4) function returns each block of text as well as four set of co-ordinates.

The order of the four sets of co-ordinates are:

bottom left
bottom right
top right
top left

Let's look at a piece of text that is written normally:

"ATTHelv", #000000, 7.79, 359.4000, 576.0000, 384.1104, 
576.0000, 384.1104, 581.6862, 359.4000, 581.6862, "Invoice"

The first two pairs of co-ordinates are (359.4, 576) and (384.1, 576).

The second x co-ordinate is greater than the first x co-ordinate so this is not reversed text.

Let's look at a piece of reversed text:

"ATTHelv180us", #000000, 11.00, 589.8000, 742.2000, 
548.1760, 742.2000, 548.1760, 734.1810, 589.8000, 734.1810, "ECIOVNI"

Here the x co-ordinate of the second set of co-ordinates is less than the first x co-ordinate which indicates reversed text.

For rotated text a similar process can be done. If a line is imagined connecting the first point to the second point this could be see as a line drawn under the text.

If the y co-ordinates are the same and x2 > x1 then it is normal text.

If the x co-ordinates are the same and y2 > y1 then the text is rotated 90 degrees anti-clockwise.

If the x co-ordinates are the same and y2 < y1 then the text is rotated 90 degrees clockwise.


© 2015 Debenu & Foxit. All rights reserved. AboutBuyContactBlogNewsletterSupportFAQProduct UpdatesForum