Print Page | Close Window

Some Pages of PDF File Rotated 180 degrees

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=3592
Printed Date: 22 Nov 24 at 7:39PM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: Some Pages of PDF File Rotated 180 degrees
Posted By: ysr
Subject: Some Pages of PDF File Rotated 180 degrees
Date Posted: 02 Aug 18 at 9:18AM
Hi,

I am using CapturePage and DrawCapturedPage to add margins to PDF files. On some PDF files and only for some pages the contents get rotated by 180 degrees. I have given the code I am using below. (Note I have removed any margins for clarity).

Any suggestions?


FOR lnCount = 1 TO loPDFLibrary.PageCount()
loPDFLibrary.SelectPage(1)
lnPageWidth = loPDFLibrary.PageWidth
lnPageHeight = loPDFLibrary.PageHeight
loPDFLibrary.NormalizePage(2)
capturedPageId = loPDFLibrary.CapturePage(1)

pageId = loPDFLibrary.NewPage()
loPDFLibrary.SelectPage(pageId)
loPDFLibrary.SetPageDimensions(lnPageWidth , lnPageHeight)
loPDFLibrary.SetOrigin(1)
ret = loPDFLibrary.DrawCapturedPage(capturedPageId, 0, 0, lnPageWidth, lnPageHeight)

ENDFOR



Replies:
Posted By: Ingo
Date Posted: 05 Aug 18 at 7:40PM
Hi ysr,

a NormalizePage before working on a selected page
will be the solution for you:
http://www.debenu.com/docs/pdf_library_reference/NormalizePage.php

Cheers and welcome here,
Ingo



-------------
Cheers,
Ingo



Posted By: ysr
Date Posted: 06 Aug 18 at 1:13AM
Thank you Ingo,

I changed my code to 

FOR lnCount = 1 TO loPDFLibrary.PageCount()
loPDFLibrary.SelectPage(1)
loPDFLibrary.NormalizePage(2)
lnPageWidth = loPDFLibrary.PageWidth
lnPageHeight = loPDFLibrary.PageHeight

capturedPageId = loPDFLibrary.CapturePage(1)

pageId = loPDFLibrary.NewPage()
loPDFLibrary.SelectPage(pageId)
loPDFLibrary.NormalizePage(2)
loPDFLibrary.SetPageDimensions(lnPageWidth , lnPageHeight)
loPDFLibrary.SetOrigin(1)
ret = loPDFLibrary.DrawCapturedPage(capturedPageId, 0, 0, lnPageWidth, lnPageHeight)

ENDFOR

But unfortunately it doesn't make any difference and those pages that gets rotated remains rotated.


Posted By: ysr
Date Posted: 06 Aug 18 at 2:07AM
A further update on this.

I just changed the code to capture and Draw only the second page. Still some pages in the rest of the document automatically gets rotated even though I haven't done any operations on those pages. 

Then I changed the code to only capture (no draw) on the second page. Still the rotation happens. 

It looks like the CapturePage on some pages, somehow affects the remaining pages. I also tried doing a CapturePageEx(2,1) for the second page and added a RemoveOpenAction() at the top. But no luck.

Any suggestions?



Posted By: Ingo
Date Posted: 07 Aug 18 at 9:27PM
The first part doesn't use the loop:
FOR lnCount = 1 TO loPDFLibrary.PageCount()
loPDFLibrary.SelectPage(1)
loPDFLibrary.NormalizePage(2)
...
Try it with:
FOR lnCount = 1 TO loPDFLibrary.PageCount()
loPDFLibrary.SelectPage(InCount)
loPDFLibrary.NormalizePage(2)


-------------
Cheers,
Ingo



Posted By: ysr
Date Posted: 17 Aug 18 at 4:08AM
Hi Ingo,

Once again, thank you very much for your reply. In the end we managed to find the problem and it is due to Shared Content Streams. Once we opened the file, if we use RemoveSharedContentStreams the issue is resolved.

I hope it helps someone.



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