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!
![]() |
How can i know if an image is drawn rotated |
Post Reply ![]() |
Author | |
bart_bender ![]() Beginner ![]() ![]() Joined: 04 Oct 11 Location: Spain Status: Offline Points: 17 |
![]() ![]() ![]() ![]() ![]() 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 |
|
![]() |
|
Ingo ![]() Moderator Group ![]() ![]() Joined: 29 Oct 05 Status: Offline Points: 3529 |
![]() ![]() ![]() ![]() ![]() |
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 |
|
![]() |
|
AndrewC ![]() Moderator Group ![]() ![]() Joined: 08 Dec 10 Location: Geelong, Aust Status: Offline Points: 841 |
![]() ![]() ![]() ![]() ![]() |
QP.PageRotation() returns the current orientation for the currently selected page.
Andrew.
|
|
![]() |
|
nothin ![]() Beginner ![]() Joined: 07 Mar 12 Status: Offline Points: 1 |
![]() ![]() ![]() ![]() ![]() |
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.
|
|
![]() |
|
Ingo ![]() Moderator Group ![]() ![]() Joined: 29 Oct 05 Status: Offline Points: 3529 |
![]() ![]() ![]() ![]() ![]() |
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 |
|
![]() |
|
edvoigt ![]() Senior Member ![]() ![]() Joined: 26 Mar 11 Location: Berlin, Germany Status: Offline Points: 111 |
![]() ![]() ![]() ![]() ![]() |
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 |
|
![]() |
Post Reply ![]() |
|
Tweet
|
Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |
Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. About — Contact — Blog — Support — Online Store