I'm trying to reorder several pages in a PDF file. I found some code in a blog but couldn't get it to work. I have a two page pdf, and I want to get the last page to appear as first. I always get an exception saying that page number has to match with order. When I checked the document object, it shows 0 pages. But the PDF passed into has two pages.
public void reOrder(string inputFile)
{
Document document = new Document();
FileStream fs = new FileStream(inputFile, FileMode.Open);
PdfWriter writer = PdfWriter.GetInstance(document, fs);
document.AddDocListener(writer);
writer.SetLinearPageMode();
int[] order = {2,1};
writer.ReorderPages(order);
}