Page Orientation
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=1405
Printed Date: 07 May 25 at 5:40PM Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com
Topic: Page Orientation
Posted By: Jimeni
Subject: Page Orientation
Date Posted: 09 Apr 10 at 6:40AM
Hi all, This is my first post.
I am having an issue when using DrawText and DrawRotatedText with certain PDFs. How does the tool determine the page orientation? With certain PDFs its drawing the text in the wrong place, it seems to think that a landscape image is portrait and so draws the text that should be along the bottom along the left hand side.
I've checked the PDF and I cant see what is different in it that might be causing this. Out of five images two have placed the text in the incorrect rotation and position.
Anyone have any ideas why this might be? How does it calculate what the bottom of the image is?
I'd post examples but unfortunately I'm working with classified documents.
Thanks in advance,
Jim
|
Replies:
Posted By: Jimeni
Date Posted: 09 Apr 10 at 6:42AM
I'm not sure its a code issue as it works fine in most PDFs but my code is below:
$qp->SetMeasurementUnits(1); /* Set as measured in mm */ echo $r = $qp->LoadFromFile($FilePath);
$intPageCount = 1; for ( $qp->SelectPage($intPageCount); $intPageCount <= $qp->PageCount; $intPageCount ++) { /* Loop through all pages in doc */ $qp->SelectPage($intPageCount); $pageheight = $qp->PageHeight; $pagewidth = $qp->PageWidth; $myheight = (($pageheight/2) - ($pageheight * .05)); /* Define center - 5% of height to accomodate angle */ $mywidth = ($pagewidth/2); $WatermarkSize = ( ($myheight + $mywidth) / strLen($Watermark) ); /* This should calc the correct text size relative to the document and amount of text */ $EPCNTextSize = ( ($myheight + $mywidth) / 60 ); $qp->SetTextAlign(1);/* Align text center */ $qp->SetTransparency(70); $qp->SetTextSize($WatermarkSize); echo $r = $qp->DrawRotatedText($mywidth, $myheight, 45, $Watermark); /* Draw Watermark at center */ $qp->SetTextAlign(2); /* Align text right */ $qp->SetTransparency(0); $qp->SetTextSize($EPCNTextSize); echo $r = $qp->DrawText($pagewidth -20, 1, "Open EPCN Number: " . $EPCN); /* Draw EPCN at bottom right with 20 padding */
}
$result = $qp->SaveToFile($OutputPath); if ($result == 1) { header("Location: /Output/MyTest2.pdf"); } else { echo "File could not be saved to disk."; echo "<br /><br />"; } $qp = null;
|
Posted By: Ingo
Date Posted: 09 Apr 10 at 6:59AM
Hi!
You should use SetOrigin to tell the system where you want to begin (top left, bottom right, ...). A document can be created in portrait-format and later changed to landscape (then it's rotated). Then you begin to draw in this document and all positions are the other way round (you must change your thinking in this case ;-) If you want to write on a document rotated with 180 degree your top left should be top right and so on ... Even if you don't understand my "german english" you should understand now where's the problem in this case ;-) Here's the complete user reference: http://www.quickpdflibrary.com/help/quickpdf/FunctionGroups.php Please read my post in the general section (...the first steps...).
Cheers and welcome here, Ingo
|
Posted By: Jimeni
Date Posted: 09 Apr 10 at 7:13AM
Ingo thanks for your help.
You've pointed me in the right direction. It turns out the pages have been rotated and saved, the program is picking out the original orientation rather than the current view.
I can see how much they have been rotated using the PageRotation function and then find a way to correct the problem.
Once again thanks for your help and your English is great, so no problems there!
Regards
Jim
|
|