Do you own a Debenu Quick PDF Library 12/11/10/9/8/7? Upgrade to Debenu Quick PDF Library 13!

Foxit Quick PDF Library

Frequently Asked Question:

Return to FAQ Index

PDFRotatePage - Rotating in increments problem

Question

Hi, I scan in pages to a pdf. I allow the each page to be rotated by the user.

My initial program uses the same QuickPDF style as shown in the examples i.e. the file is not kept open. Open file do work, close file. So my rotate 90 degrees code is as follows:

private void btnViewScanRotateClockwise_Click(object sender, EventArgs e) {

DLL myDLL = new DLL("QuickPDFDLL0721.dll");
int InstanceID;
InstanceID = myDLL.QuickPDFCreateLibrary();
if (myDLL.QuickPDFUnlockKey(InstanceID, "trial key with lib here") == 1)
{
    System.Text.UTF8Encoding UTF8 = new System.Text.UTF8Encoding();
    Byte[] BytesMessage = UTF8.GetBytes(ScannedFile);
    myDLL.QuickPDFLoadFromFile(InstanceID, BytesMessage);
    myDLL.QuickPDFSelectPage(InstanceID, CurrentPageNo);
    myDLL.QuickPDFRotatePage(InstanceID, 90);
    myDLL.QuickPDFSaveToFile(InstanceID, BytesMessage);
    DisplayPage();
    myDLL.QuickPDFReleaseLibrary(InstanceID);
}

}

This works for the 1st rotation only. Further clicks of the button does not rotate it further. I now presume that the page is kept in the same orientation as created and contains information showing its rotation.

If this is the case "How can I find out its rotation?" Then I can increment it accordingly. Similar logic could then be used to code the anticlockwise rotations.

Regards

Answer

Having gone through the document page at a time it is straight forward. For clockwise:

    System.Text.UTF8Encoding UTF8 = new System.Text.UTF8Encoding();
    Byte[] BytesMessage = UTF8.GetBytes(ScannedFile);
    myDLL.QuickPDFLoadFromFile(InstanceID, BytesMessage);
    myDLL.QuickPDFSelectPage(InstanceID, CurrentPageNo);
    int theRotation = myDLL.QuickPDFPageRotation(InstanceID);
    if (theRotation == 270)
        theRotation = 0;
    else
        theRotation += 90;
    myDLL.QuickPDFRotatePage(InstanceID, theRotation);
    myDLL.QuickPDFSaveToFile(InstanceID, BytesMessage);

and then for anti clockwise

    System.Text.UTF8Encoding UTF8 = new System.Text.UTF8Encoding();
    Byte[] BytesMessage = UTF8.GetBytes(ScannedFile);
    myDLL.QuickPDFLoadFromFile(InstanceID, BytesMessage);
    myDLL.QuickPDFSelectPage(InstanceID, CurrentPageNo);
    int theRotation = myDLL.QuickPDFPageRotation(InstanceID);
    if (theRotation == 0)
        theRotation = 270;
    else
        theRotation -= 90;
    myDLL.QuickPDFRotatePage(InstanceID, theRotation);
    myDLL.QuickPDFSaveToFile(InstanceID, BytesMessage);

© 2015 Debenu & Foxit. All rights reserved. AboutBuyContactBlogNewsletterSupportFAQProduct UpdatesForum