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!
![]() |
PDFs rotate unexpectedly |
Post Reply ![]() |
Author | |
chansw ![]() Beginner ![]() Joined: 17 Feb 12 Status: Offline Points: 3 |
![]() ![]() ![]() ![]() ![]() Posted: 17 Feb 12 at 4:53PM |
I have seen where loading PDFs from files into QPL and then saving them result in the pages being rotated by 90 degrees (CW or CCW).
Is there a best practice way to manage / eliminate this rotation? Thanks Jerry QP.LoadFromFile(origfile, "") QP.SetOrigin(1) Dim numpages as Integer = QP.PageCount For i = 1 to numpages QP.SelectPage(1) ' QP.NormalizePage(0) ' If uncommmented, I get blank pages pagewidth = QP.PageWidth() pageheight = QP.PageHeight() QP.NewPage() QP.SetPageDimensions(pagewidth, pageheight) capturepageid = QP.CapturePage(1) QP.DrawCapturedPage(capturepageid, 36, 36, pagewidth-72, pageheight-72) Next QP.SaveToFile("newfile.pdf") |
|
![]() |
|
edvoigt ![]() Senior Member ![]() ![]() Joined: 26 Mar 11 Location: Berlin, Germany Status: Offline Points: 111 |
![]() ![]() ![]() ![]() ![]() |
Hi Jerry,
sometimes it happens, that PDFs have inside a rotate-command. The best way is to ask for this. Look there: http://www.quickpdf.org/forum/drawcapturedpage-and-autorotation_topic2071_post8882.html?KW=landscape#8882 I did give an explanation about background and on the end a short solution. You may manage or eliminate it, as you want. Cheers, Werner |
|
![]() |
|
chansw ![]() Beginner ![]() Joined: 17 Feb 12 Status: Offline Points: 3 |
![]() ![]() ![]() ![]() ![]() |
Thanks Werner for your code sample that show how to use the PageRotation() and RotatePage() functions. For whatever reason however I had to apply the rotation AFTER the new page was drawn; the resulting page did NOT rotate when I placed the RotatePage() command as in your sample code.
Anyways, here's the code that worked for me. I added some subtle hacks (having to do with single vs multiple-page original files). I've added comments to explain when to execute NewPage() based on what I observed through trial-and-error, hopefully I got them right. Being a newb at QPL, I wish the official documentation (reference manuals, etc.) were a bit more comprehensive explaining the subtleties of how things actually work. Jerry -- QP.LoadFromFile(origfile, "") QP.SetOrigin(1) Dim numpages As Integer = QP.PageCount For i As Integer = 1 To numpages QP.SelectPage(1) Dim rotation As Integer = QP.PageRotation() pagewidth = QP.PageWidth() pageheight = QP.PageHeight() If numpages = 1 Then QP.NewPage() ' Extra page to allow capturepage() to execute for single page PDFs End If Dim capturedpageid As Integer = QP.CapturePage(1) ' Deletes page from document If numpages > 1 Then QP.NewPage() ' Page onto which the captured page will be drawn End If QP.SetPageDimensions(pagewidth, pageheight) QP.DrawCapturedPage(capturedpageid, ...) If rotation <> 0 Then QP.RotatePage(rotation) ' ***** ROTATE HERE TO MATCH ORIGINAL ***** End If Next QP.SaveToFile(newfile) Edited by chansw - 18 Feb 12 at 3:24AM |
|
![]() |
|
AndrewC ![]() Moderator Group ![]() ![]() Joined: 08 Dec 10 Location: Geelong, Aust Status: Offline Points: 841 |
![]() ![]() ![]() ![]() ![]() |
We have just found a bug with NormalizePage(0); This has been fixed in the 8.14 beta 5 just released yesterday. It can be download from here.
http://www.quickpdflibrary.com/blog/2012/02/quick-pdf-library-8-14-beta-5-released/ As a work around is to call QP.SetOrigin(0) before calling QP.NormalizePage(0); QP.SetOrigin(0); QP.NormalizePage(0); QP.SetOrigin(1); Andrew.
|
|
![]() |
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