Print Page | Close Window

Is there a way to detect landscape pages?

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=2268
Printed Date: 29 Sep 24 at 1:13AM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: Is there a way to detect landscape pages?
Posted By: ExchangeViews
Subject: Is there a way to detect landscape pages?
Date Posted: 18 May 12 at 10:02AM
DrawRotatedText function is not working perfectly for landscape pages. Lib auto convert landscape pages to portrait and them use DrawRotatedText(....) and finally save as landscape. Can anybody help me in detecting landscape pages to set different angle for those pages? Question



Replies:
Posted By: edvoigt
Date Posted: 18 May 12 at 12:54PM
Hi,

I think, you are wrong. It seems, as you are working on existing PDF which contains inside a rotate-command.

For solution look at the end of my post:
http://www.quickpdf.org/forum/drawcapturedpage-and-autorotation_topic2071_post8885.html?KW=rotate+edvoigt#8885 - http://www.quickpdf.org/forum/drawcapturedpage-and-autorotation_topic2071_post8885.html?KW=rotate+edvoigt#8885

Remark: Landscape or portrait is first a question of relation between pagewidth and pageheigt, not of rotation.


Cheers,

Werner


Posted By: ExchangeViews
Date Posted: 19 May 12 at 7:52AM
Dear Werner, you are right, i am working on existing PDF which contains inside a rotate-command. So I used:
rotation := QP.PageRotation;
  if (rotation<>0)
  then begin
  Angle:=
Angle+rotation; (for angle 0 to 270)
  end;
and the code is working for landscape pages. Thanks for your help!!!!Clap


Posted By: edvoigt
Date Posted: 19 May 12 at 9:12AM
Hi,

here a small remark. Because on some place an anglevalue only from 0, 90, 180, 270 is accepted, use better:

Angle:= (Angle+rotation) mod 360; // sure inside 0..359

So at RotatePage the Reference Guide says:

PageRotation The number of degrees to rotate the page by. Must be a multiple of 90
degrees (90, 180 or 270)

So with mod you are more on sure side.


Cheers again,

Werner


Posted By: AndrewC
Date Posted: 21 May 12 at 3:06AM

It sounds like you may need to use QP.NormalizePage(0) to allow you to use the DrawText and DrawRotatedText.

  QP.LoadFromFile("page.pdf");
  for (int i=1;i<=QP.PageCount();i++)
  {
     QP.SelectPage(i);
     QP.NormalizePage(0);
  }

Andrew.


Posted By: ExchangeViews
Date Posted: 22 May 12 at 9:43AM
Originally posted by AndrewC AndrewC wrote:


It sounds like you may need to use QP.NormalizePage(0) to allow you to use the DrawText and DrawRotatedText.

  QP.LoadFromFile("page.pdf");
  for (int i=1;i<=QP.PageCount();i++)
  {
     QP.SelectPage(i);
     QP.NormalizePage(0);
  }

Andrew.


Dear Andrew,
Thanks. It is working perfectly for rotated pages but when I use the above code to draw text beneath the page content as below, it display just a blank page. If i comment QP.NormalizePage(0) function, program works fine but another issue occurs for rotated pages.
http://www.quickpdf.org/forum/settextmode-function-is-not-working-for-me-why_topic2261.html - http://www.quickpdf.org/forum/settextmode-function-is-not-working-for-me-why_topic2261.html

QP.LoadFromFile("page.pdf");
  for (int i=1;i<=QP.PageCount();i++)
  {
   QP.CapturePage
     QP.SelectPage(i);
     QP.NormalizePage(0);
     QP.SaveState;
   QP.SetTextMode(2)
     Watermark;
     QP.LoadState;       // as it was
     QP.DrawCaptured;
  }




Posted By: AndrewC
Date Posted: 22 May 12 at 11:55AM
I am just guessing but try this

QP.LoadFromFile("page.pdf");
  for (int i=1;i<=QP.PageCount();i++)
  {     
     QP.SelectPage(i);
     QP.NormalizePage(0);
     QP.CapturePage
     QP.SaveState;
   QP.SetTextMode(2)
     Watermark;
     QP.LoadState;       // as it was
     QP.DrawCaptured;
  }


Posted By: ExchangeViews
Date Posted: 22 May 12 at 12:29PM
Thanks a lot. Your idea is working fine. I am sorry to bother you. It was so easy.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.01 - http://www.webwizforums.com
Copyright ©2001-2014 Web Wiz Ltd. - http://www.webwiz.co.uk