Click here to Skip to main content
15,885,278 members
Articles / Operating Systems / Windows
Alternative
Tip/Trick

How to Permanently Rotate a PDF file

Rate me:
Please Sign up or sign in to vote.
4.83/5 (3 votes)
10 Jul 2011CPOL 17.5K   1   2
This is an alternative solution on how to permanently rotate a PDF file

Have a look at the http://www.pdfclown.org[^] library (licensed under LGPL and can be interfaced from C#). It has support for rotating PDFs and seems very simple to handle. I was able to construct the following example quite easily without knowing the library:

C#
public bool Rotate()
{
    File file = new File(@"D:\sample.pdf");

    foreach (var page in file.Document.Pages)
    {
        page.Rotation = RotationEnum.Rightward;
    }

    file.Save();
    file.Dispose();
    return true;
}

In detail, this is about setting the "Rotate" key in each "Page" dictionary in the document which is a minimalistic change to the document. Saving the file however might do other changes (such as choosing other compression algorithms, removing unneeded objects from the PDF document, ...).

The most dominant problem I can see is that such libraries always lag behind the PDF standard and therefore will not work with all PDF documents. But it might work with documents from a specific source.

Another alternative might be the http://www.quickpdflibrary.com/[^] which is available in a free-to-use lite version.

There is also the http://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/[^] which comes with a ready to use tool for PDF rotation.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
Germany Germany
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralReason for my vote of 4 clear explanation, thanks Pin
BrandonSun24-Jul-11 22:37
BrandonSun24-Jul-11 22:37 
GeneralHave a 5. Thanks for the info. Why didn't you post those bef... Pin
Dr.Walt Fair, PE10-Jul-11 9:30
professionalDr.Walt Fair, PE10-Jul-11 9:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.