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 - PDFs rotate unexpectedly
  FAQ FAQ  Forum Search   Register Register  Login Login

PDFs rotate unexpectedly

 Post Reply Post Reply
Author
Message
chansw View Drop Down
Beginner
Beginner


Joined: 17 Feb 12
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote chansw Quote  Post ReplyReply Direct Link To This Post Topic: PDFs rotate unexpectedly
    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")


Back to Top
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 Posted: 17 Feb 12 at 8:47PM
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
Back to Top
chansw View Drop Down
Beginner
Beginner


Joined: 17 Feb 12
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote chansw Quote  Post ReplyReply Direct Link To This Post Posted: 18 Feb 12 at 3:20AM
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
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: 22 Feb 12 at 2:58PM
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.
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