Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FileOutputStream equivalent

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();


        }
like image 483
MaylorTaylor Avatar asked Jul 25 '13 18:07

MaylorTaylor


People also ask

What is the difference between Fileinputstream and FileOutputStream?

InputStream − This is used to read (sequential) data from a source. OutputStream − This is used to write data to a destination.

What is the difference between FileWriter and FileOutputStream?

FileWriter vs FileOutputStreamFileWriter writes streams of characters while FileOutputStream is meant for writing streams of raw bytes.

What is new FileOutputStream?

Creates a file output stream to write to the file represented by the specified File object. If the second argument is true , then bytes will be written to the end of the file rather than the beginning. A new FileDescriptor object is created to represent this file connection.

What is the function of FileOutputStream?

FileOutputStream is an outputstream for writing data/streams of raw bytes to file or storing data to file. FileOutputStream is a subclass of OutputStream. To write primitive values into a file, we use FileOutputStream class.


1 Answers

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

PdfStamper stamper = new PdfStamper(reader, new FileStream(inputFile, FileMode.Create));
like image 79
bebraham Avatar answered Oct 25 '22 20:10

bebraham