当前位置: 首页>>代码示例>>C#>>正文


C# Document.AddDocListener方法代码示例

本文整理汇总了C#中iTextSharp.text.Document.AddDocListener方法的典型用法代码示例。如果您正苦于以下问题:C# Document.AddDocListener方法的具体用法?C# Document.AddDocListener怎么用?C# Document.AddDocListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在iTextSharp.text.Document的用法示例。


在下文中一共展示了Document.AddDocListener方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ExtractPages

        public void ExtractPages(string inputFile, string outputFile,
            List<int> extractPages, System.Windows.Forms.ProgressBar progres)
        {
            if (inputFile == outputFile)
            {
                System.Windows.Forms.MessageBox.Show("Nie możesz użyć pliku wejściowego jako wyjściowego do zapisu.");
            }

            PdfReader inputPDF = new PdfReader(inputFile);

            Document doc = new Document();
            PdfReader reader = new PdfReader(inputFile);
            progres.Maximum = reader.NumberOfPages;

            using (MemoryStream memoryStream = new MemoryStream())
            {
                PdfWriter writer = PdfWriter.GetInstance(doc, memoryStream);
                doc.Open();
                doc.AddDocListener(writer);
                for (int i = 1; i <= reader.NumberOfPages; i++)
                {
                    progres.Value = i;
                    if (extractPages.FindIndex(s => s == i) == -1) continue;
                    doc.SetPageSize(reader.GetPageSize(i));
                    doc.NewPage();
                    PdfContentByte cb = writer.DirectContent;
                    PdfImportedPage pageImport = writer.GetImportedPage(reader, i);
                    int rot = reader.GetPageRotation(i);
                    if (rot == 90 || rot == 270)
                    {
                        cb.AddTemplate(pageImport, 0, -1.0F, 1.0F, 0, 0, reader.GetPageSizeWithRotation(i).Height);
                    }
                    else
                    {
                        cb.AddTemplate(pageImport, 1.0F, 0, 0, 1.0F, 0, 0);
                    }
                }
                reader.Close();
                doc.Close();
                try
                {
                    File.WriteAllBytes(outputFile, memoryStream.ToArray());
                }
                catch
                {
                    throw new Exception("Błąd przy próbie zapisu do pliku. Upewnij się iż żaden inny proces obecnie go nie używa.");
                }
            }
        }
开发者ID:daralbrecht,项目名称:PDFAsystent,代码行数:49,代码来源:PDFStripper.cs

示例2: RtfWriter2

 /**
 * Constructs a new RtfWriter that listens to the specified Document and
 * writes its output to the Stream.
 * 
 * @param doc The Document that this RtfWriter listens to
 * @param os The Stream to write to
 */
 protected RtfWriter2(Document doc, Stream os) : base(doc, os) {
     doc.AddDocListener(this);
     rtfDoc = new RtfDocument();
 }
开发者ID:nicecai,项目名称:iTextSharp-4.1.6,代码行数:11,代码来源:RtfWriter2.cs

示例3: PdfCopy

 /**
 * Constructor
 * @param document
 * @param os outputstream
 */
 public PdfCopy(Document document, Stream os)
     : base(new PdfDocument(), os)
 {
     document.AddDocListener(pdf);
     pdf.AddWriter(this);
     indirectMap = new Dictionary<PdfReader,Dictionary<RefKey,IndirectReferences>>();
 }
开发者ID:boecko,项目名称:iTextSharp,代码行数:12,代码来源:PdfCopy.cs

示例4: GetInstance

 /**
 * Use this method to get an instance of the <CODE>PdfWriter</CODE>.
 *
 * @return a new <CODE>PdfWriter</CODE>
 * @param document The <CODE>Document</CODE> that has to be written
 * @param os The <CODE>Stream</CODE> the writer has to write to.
 * @param listener A <CODE>DocListener</CODE> to pass to the PdfDocument.
 * @throws DocumentException on error
 */
 public static PdfWriter GetInstance(Document document, Stream os, IDocListener listener)
 {
     PdfDocument pdf = new PdfDocument();
     pdf.AddDocListener(listener);
     document.AddDocListener(pdf);
     PdfWriter writer = new PdfWriter(pdf, os);
     pdf.AddWriter(writer);
     return writer;
 }
开发者ID:karino2,项目名称:wikipediaconv,代码行数:18,代码来源:PdfWriter.cs

示例5: PdfCopy

 /**
 * Constructor
 * @param document
 * @param os outputstream
 */
 public PdfCopy(Document document, Stream os) : base(new PdfDocument(), os) {
     document.AddDocListener(pdf);
     pdf.AddWriter(this);
     indirectMap = new Hashtable();
 }
开发者ID:pusp,项目名称:o2platform,代码行数:10,代码来源:PdfCopy.cs

示例6: open

 /**
  * @Method open a existing pdf file
  * @Param path path of pdfFile
  * @Return returns true if the file was opened or false if file couldn't be opened
  */
 private bool open(DocumentData pdfDoc)
 {
     String path;
     pdfDoc.Docsignedpath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)+ "\\"+ pdfDoc.Idoperation + "\\signed\\" + pdfDoc.Docname;
     if (pdfDoc.documentHasBeenSigned())
     {
         path = pdfDoc.Docpath + "-signed.pdf";
         //signedpath =
     }
     else
     {
         path = pdfDoc.Docpath;
     }
     if (File.Exists(pdfDoc.Docpath))
     {
         doc = new Document();
         reader = new PdfReader(path);
         fos = new FileStream(pdfDoc.Docsignedpath, FileMode.Create, FileAccess.Write);
         writer = PdfWriter.GetInstance(doc, fos);
         doc.Open();
         doc.AddDocListener(writer);
         return true;
     }
     return false;
 }
开发者ID:jcgarciagrupocmc,项目名称:O2Sign-WacomPad,代码行数:30,代码来源:PDFController.cs


注:本文中的iTextSharp.text.Document.AddDocListener方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。