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


C# Reader.Close方法代码示例

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


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

示例1: Test_PdfImportStream_01

        public static void Test_PdfImportStream_01(string inputPdfFile, string outputPdfFile, string streamFile)
        {
            _tr.WriteLine("import stream for object TPL1 of pdf file \"{0}\" from \"{1}\" and save pdf to \"{2}\"", inputPdfFile, streamFile, outputPdfFile);
            PB_Pdf.PdfReader pr = null;
            Reader r = null;
            PB_Pdf.PdfWriter pw = null;
            try
            {
                pr = new PB_Pdf.PdfReader(inputPdfFile);
                //IPdfObject obj = ReadPdfObject(pr, idObject, "Object");
                r = new Reader(streamFile);
                //obj.stream = r.ReadBytes((int)r.Length);
                //PdfNValue length = obj.value["Length"];
                //if (length == null || !length.value.isInt()) throw new PBException("error wrong /Length of object {0}", idObject);
                //length.value.valueInt = obj.stream.Length;

                pw = new PB_Pdf.PdfWriter(outputPdfFile, FileMode.Create);
                pw.reader = pr;
                IPdfObject info = ReadPdfObject(pr, pr.Trailer["Info"].value.valueObjectId, "Info");
                pw.WriteObject(info, "Info");
                IPdfObject root = ReadPdfObject(pr, pr.Trailer["Root"].value.valueObjectId, "Root");
                pw.WriteObject(root, "Root");

                IPdfObject pages = ReadPdfObject(pr, root.value["Pages"].value.valueObjectId, "Pages");
                pw.WriteObject(pages);

                IPdfObject page1 = ReadPdfObject(pr, pages.value["Kids"].value[0].valueObjectId, "Page 1");
                pw.WriteObject(page1);

                IPdfObject page1Content = ReadPdfObject(pr, page1.value["Contents"].value.valueObjectId, "Contents page 1");
                pw.WriteObject(page1Content);

                IPdfObject page1Ressource = ReadPdfObject(pr, page1.value["Resources"].value.valueObjectId, "Resources page 1");
                pw.WriteObject(page1Ressource);

                IPdfObject page1Ressource_01 = ReadPdfObject(pr, page1Ressource.value["XObject"].value["TPL1"].value.valueObjectId, "Resources page 1 /TPL1");

                // import stream from file
                page1Ressource_01.stream = r.ReadBytes((int)r.Length);
                PdfNValue length = page1Ressource_01.value["Length"];
                if (length == null || !length.value.isInt()) throw new PBException("error wrong /Length of object {0}", page1Ressource_01.id);
                length.value.valueInt = page1Ressource_01.stream.Length;

                pw.WriteObjectWithChilds(page1Ressource_01);
            }
            finally
            {
                if (pr != null) pr.Close();
                if (r != null) r.Close();
                if (pw != null) pw.Close();
            }
        }
开发者ID:labeuze,项目名称:source,代码行数:52,代码来源:Test_iTextSharp_f.cs

示例2: Test_PdfUpdateStream_01

 public static void Test_PdfUpdateStream_01(string pdfFile, int objectId, string streamFile)
 {
     _tr.WriteLine("update stream for object {0} with \"{1}\" of pdf file \"{2}\"", objectId, streamFile, pdfFile);
     PB_Pdf.PdfWriter pw = null;
     Reader r = null;
     try
     {
         pw = new PB_Pdf.PdfWriter(pdfFile, updatePdf: true);
         IPdfObject obj = pw.reader.ReadObject(objectId);
         r = new Reader(streamFile);
         obj.stream = r.ReadBytes((int)r.Length);
         PdfNValue length = obj.value["Length"];
         if (length == null || !length.value.isInt()) throw new PBException("error wrong /Length of object {0}", obj.id);
         length.value.valueInt = obj.stream.Length;
         pw.UpdateObject(obj);
     }
     finally
     {
         if (r != null) r.Close();
         if (pw != null) pw.Close();
     }
 }
开发者ID:labeuze,项目名称:source,代码行数:22,代码来源:Test_iTextSharp_f.cs


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