C# FileOutputStream 等效项

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17866435/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-10 10:41:14  来源:igfitidea点击:

FileOutputStream equivalent

c#pdfitextsharpfileoutputstream

提问by MaylorTaylor

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.

我正在尝试将 pdf 旋转 180 度,并且我正在使用 ITextSharp 库来执行此操作。下面的代码取自他们网站的示例。但是,我似乎找不到正确的命名空间来导入以使“FileOutputStream”工作。

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

这是一个控制台应用程序,所以不确定 Java 的“FileOutpuStream”是否可以工作。

The PDFStamper() is structured like this:

PDFStamper() 的结构如下:

PdfStamper(PDFReader reader, Stream os)

PdfStamper(PDFReader阅读器,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();


        }

采纳答案by bebraham

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

尝试使用FileStream. 在里面System.IO

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