FileOutputStream equivalent

MaylorTaylor picture MaylorTaylor · Jul 25, 2013 · Viewed 22.8k times · Source

I am trying to rotate a pdf 180 degrees and I am using the ITextSharp library to do so. The code below is taken from their site's examples. However, I can't seem to find the right namespace to import to get the "FileOutputStream" to work.

This is a console app, so not sure if Java's "FileOutpuStream" will work.

The PDFStamper() is structured like this:

PdfStamper(PDFReader reader, Stream os)

public void rotatePDF(string inputFile)
        {
            // get input document

         PdfReader reader = new PdfReader(inputFile);         
         PdfName pdfName = new PdfName(inputFile);
         int n = reader.NumberOfPages;
         int rot;
         PdfDictionary pageDict;
         for (int i = 1; i <= n; i++)
         {
             rot = reader.GetPageRotation(i);
             pageDict = reader.GetPageN(i);
             pageDict.Put(PdfName.ROTATE, new PdfNumber(rot + 180));
         }

         PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(inputFile));
         stamper.closer();
         reader.Close();


        }

Answer

bebraham picture bebraham · Jul 25, 2013

Try using a FileStream. It's in System.IO

PdfStamper stamper = new PdfStamper(reader, new FileStream(inputFile, FileMode.Create));