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 can i know if an image is drawn rotated
  FAQ FAQ  Forum Search   Register Register  Login Login

How can i know if an image is drawn rotated

 Post Reply Post Reply
Author
Message Reverse Sort Order
edvoigt View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 Mar 11
Location: Berlin, Germany
Status: Offline
Points: 111
Post Options Post Options   Thanks (0) Thanks(0)   Quote edvoigt Quote  Post ReplyReply Direct Link To This Post Topic: How can i know if an image is drawn rotated
    Posted: 10 Mar 12 at 3:25PM
Hi,

You have to distinguish two kinds of rotation.

First is the rotation of a page. It takes the full content of a page. To determine it, there is PageRotation in QPL. It's result is what you find inside the "headdata" of an page-object in a PDF. But it is no solution for you.

How much an image is rotated is a fully other question. At now for this there is no QPL-function to get the needed info.

So we build our own PDF with a rotated image in it.

  QP.SetMeasurementUnits(1);                // unit mm
  QP.SetPageDimensions(210, 297);           // A4
  QP.SetOrigin(0); // Bottomleft
  QP.AddImageFromFile('blueFolder.bmp', 0);
  QP.DrawRotatedImage(105,105, 100,50, 90); // rotate around the pagecenter 90°
  QP.SaveToFile('rotatedimage.pdf');

Now we look inside:
There are some objects inside. We are interested only in
obj 2 - the page object, consisting at most of
obj 7 - our image under the name  /QuickPDFImb9288b05
obj 5 - the PDF-operations, which build the pagecontent

So we see in obj 5
q
0 1 -1 0  297.6378 297.6378 cm
283.4646 0 0 141.7323 0 0 cm
/QuickPDFImb9288b05 Do
Q

The answer to your question is inside the both cm-operators. They contain data to be concatenated with transformation matrix and are the key. In the PDF-Specs (chapter 4.2.3) from Adobe you find a explanation of this matrix. From this you may find who describes a rotation. This may only such cm's are, where the first four values are of the kind c s -s c. That's because they are sinus und cosinus-values of an angle which is used for clounterclockwise rotation. There we find a sinus of 1.0 (90°) and its cosinus with 0.

But it is a little bit more difficult, because in one operation is more than only rotation possible. In one matrix may be rotation, scaling, skewing and translation. So it depends on the producer of the PDF, how he constructs his cm-operators and how difficult to get the angle-info back.

At the end you have to mix your knowledge about the angle under which the image is drawn and a possible pagerotation, which may be important too.


Cheers,
Werner
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 Mar 12 at 11:29PM
Hi Nothin!
 
You can try any sample here or from the official support pages.
After LoadFromFile you should try PageCount and then a loop
with SelectPage.
Inside the loop you can use PageRotation.
No, you can't use it with FDF.
 
Cheers and welcome here,
Ingo
 


Edited by Ingo - 07 Mar 12 at 11:30PM
Back to Top
nothin View Drop Down
Beginner
Beginner


Joined: 07 Mar 12
Status: Offline
Points: 1
Post Options Post Options   Thanks (0) Thanks(0)   Quote nothin Quote  Post ReplyReply Direct Link To This Post Posted: 07 Mar 12 at 11:21PM
Andrew,
Can you give an example of how you would use the PageRotation() function in a PDF file?
 
Can this be used in an FDF file? Can it be used to find what the page rotation is in whatever document the FDF file is imported into?
 
Thanks.
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: 26 Oct 11 at 3:09AM
QP.PageRotation() returns the current orientation for the currently selected page.

Andrew.
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: 25 Oct 11 at 8:52PM
Hi Bart!

QuickPDF offers functions to set these properties but not to get these values.
You can do it by your own.
Read the real content of your pdf-document into a stream and search for "rotate".
In my sample i've found the following pdf-code:
<<
/Type /Page
/Parent 5 0 R
/MediaBox [0 0 592.3 839]
/Resources <<
/Font <<
/F1 6 0 R /F2 7 0 R /F3 8 0 R >>
/XObject <<
/I1 9 0 R /I2 10 0 R /I3 11 0 R /I4 12 0 R /I5 13 0 R >>
/ProcSet 2 0 R >>
/Contents 3 0 R
/Rotate 90
>>
endobj
9 0 obj <<

... a 90 degrees rotation ;-)
The direct pdf-content is readable.
Try to open a pdf with Notepad and search for "rotate".
Normally you'll find a "/Rotate 0" ...

Cheers, Ingo



Edited by Ingo - 25 Oct 11 at 8:52PM
Back to Top
bart_bender View Drop Down
Beginner
Beginner
Avatar

Joined: 04 Oct 11
Location: Spain
Status: Offline
Points: 17
Post Options Post Options   Thanks (0) Thanks(0)   Quote bart_bender Quote  Post ReplyReply Direct Link To This Post Posted: 25 Oct 11 at 11:06AM
Hello.

I'm trying duplicate a PDF image with a OCR layer.
When extract the image from the document, this is rotated 90º (i see this in the width and height properties)

How can i know if an image is drawn rotated in the original file for to use the FitImage method with rotation property?

Thanks in advance
Best Regards


Edited by bart_bender - 25 Oct 11 at 11:07AM
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