I have a PDF I am trying to open up and alter slightly (just changing the ViewerPreferences) but can't seem to work out the exact usage of iTextSharp. The file that gets saved at the end is corrupt. Any ideas?
PdfReader reader = new PdfReader(@"C:\4803.pdf");
using (var stream = new MemoryStream())
{
PdfStamper stamper = new PdfStamper(reader, stream);
stamper.ViewerPreferences = PdfWriter.AllowPrinting | PdfWriter.PrintScalingNone;
stream.Position = 0;
byte[] output = LoadFromStream(stream); // Convert it to a byte array
SaveToFile(output, @"C:\4803_out.pdf"); // Save it to a file
stamper.Close();
}