當前位置: 首頁>>代碼示例>>C#>>正文


C# RandomAccessFileOrArray.ReOpen方法代碼示例

本文整理匯總了C#中iTextSharp.text.pdf.RandomAccessFileOrArray.ReOpen方法的典型用法代碼示例。如果您正苦於以下問題:C# RandomAccessFileOrArray.ReOpen方法的具體用法?C# RandomAccessFileOrArray.ReOpen怎麽用?C# RandomAccessFileOrArray.ReOpen使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在iTextSharp.text.pdf.RandomAccessFileOrArray的用法示例。


在下文中一共展示了RandomAccessFileOrArray.ReOpen方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: CloseIt

 protected void CloseIt() {
     for (int k = 0; k < readers.Count; ++k) {
         readers[k].RemoveFields();
     }
     for (int r = 0; r < readers.Count; ++r) {
         PdfReader reader = readers[r];
         for (int page = 1; page <= reader.NumberOfPages; ++page) {
             pageRefs.Add(GetNewReference(reader.GetPageOrigRef(page)));
             pageDics.Add(reader.GetPageN(page));
         }
     }
     MergeFields();
     CreateAcroForms();
     for (int r = 0; r < readers.Count; ++r) {
             PdfReader reader = readers[r];
             for (int page = 1; page <= reader.NumberOfPages; ++page) {
                 PdfDictionary dic = reader.GetPageN(page);
                 PdfIndirectReference pageRef = GetNewReference(reader.GetPageOrigRef(page));
                 PdfIndirectReference parent = root.AddPageRef(pageRef);
                 dic.Put(PdfName.PARENT, parent);
                 Propagate(dic, pageRef, false);
             }
     }
     foreach (KeyValuePair<PdfReader, IntHashtable> entry in readers2intrefs) {
         PdfReader reader = entry.Key;
         try {
             file = reader.SafeFile;
             file.ReOpen();
             IntHashtable t = entry.Value;
             int[] keys = t.ToOrderedKeys();
             for (int k = 0; k < keys.Length; ++k) {
                 PRIndirectReference refi = new PRIndirectReference(reader, keys[k]);
                 AddToBody(PdfReader.GetPdfObjectRelease(refi), t[keys[k]]);
             }
         }
         finally {
             try {
                 file.Close();
                 // TODO: Removed - the user should be responsible for closing all PdfReaders.  But, this could cause a lot of memory leaks in code out there that hasn't been properly closing things - maybe add a finalizer to PdfReader that calls PdfReader#close() ??            	
                 //reader.Close();
             }
             catch  {
                 // empty on purpose
             }
         }
     }
     pdf.Close();
 }
開發者ID:,項目名稱:,代碼行數:48,代碼來源:

示例2: PdfStamperImp

 /** Creates new PdfStamperImp.
 * @param reader the read PDF
 * @param os the output destination
 * @param pdfVersion the new pdf version or '\0' to keep the same version as the original
 * document
 * @param append
 * @throws DocumentException on error
 * @throws IOException
 */
 internal PdfStamperImp(PdfReader reader, Stream os, char pdfVersion, bool append)
     : base(new PdfDocument(), os)
 {
     if (reader.Tampered)
         throw new DocumentException("The original document was reused. Read it again from file.");
     reader.Tampered = true;
     this.reader = reader;
     file = reader.SafeFile;
     this.append = append;
     if (append) {
         if (reader.IsRebuilt())
             throw new DocumentException("Append mode requires a document without errors even if recovery was possible.");
         if (reader.IsEncrypted())
             crypto = new PdfEncryption(reader.Decrypt);
         pdf_version.SetAppendmode(true);
         file.ReOpen();
         byte[] buf = new byte[8192];
         int n;
         while ((n = file.Read(buf)) > 0)
             this.os.Write(buf, 0, n);
         file.Close();
         prevxref = reader.LastXref;
         reader.Appendable = true;
     }
     else {
         if (pdfVersion == 0)
             base.PdfVersion = reader.PdfVersion;
         else
             base.PdfVersion = pdfVersion;
     }
     base.Open();
     pdf.AddWriter(this);
     if (append) {
         body.Refnum = reader.XrefSize;
         marked = new IntHashtable();
         if (reader.IsNewXrefType())
             fullCompression = true;
         if (reader.IsHybridXref())
             fullCompression = false;
     }
     initialXrefSize = reader.XrefSize;
 }
開發者ID:hjgode,項目名稱:iTextSharpCF,代碼行數:51,代碼來源:PdfStamperImp.cs

示例3: ReadCffFont

 /**
 * If this font file is using the Compact Font File Format, then this method
 * will return the raw bytes needed for the font stream. If this method is
 * ever made public: make sure to add a test if (cff == true).
 * @return  a byte array
 * @since   2.1.3
 */
 protected internal byte[] ReadCffFont()
 {
     RandomAccessFileOrArray rf2 = new RandomAccessFileOrArray(rf);
     byte[] b = new byte[cffLength];
     try {
         rf2.ReOpen();
         rf2.Seek(cffOffset);
         rf2.ReadFully(b);
     }
     finally {
         try {
             rf2.Close();
         }
         catch {
             // empty on purpose
         }
     }
     return b;
 }
開發者ID:bmictech,項目名稱:iTextSharp,代碼行數:26,代碼來源:TrueTypeFont.cs

示例4: GetFullFont

 protected byte[] GetFullFont()
 {
     RandomAccessFileOrArray rf2 = null;
     try {
         rf2 = new RandomAccessFileOrArray(rf);
         rf2.ReOpen();
         byte[] b = new byte[rf2.Length];
         rf2.ReadFully(b);
         return b;
     }
     finally {
         try {if (rf2 != null) rf2.Close();} catch {}
     }
 }
開發者ID:bmictech,項目名稱:iTextSharp,代碼行數:14,代碼來源:TrueTypeFont.cs

示例5: PdfStamperImp

 /** Creates new PdfStamperImp.
 * @param reader the read PDF
 * @param os the output destination
 * @param pdfVersion the new pdf version or '\0' to keep the same version as the original
 * document
 * @param append
 * @throws DocumentException on error
 * @throws IOException
 */
 protected internal PdfStamperImp(PdfReader reader, Stream os, char pdfVersion, bool append)
     : base(new PdfDocument(), os)
 {
     if (!reader.IsOpenedWithFullPermissions)
         throw new BadPasswordException(MessageLocalization.GetComposedMessage("pdfreader.not.opened.with.owner.password"));
     if (reader.Tampered)
         throw new DocumentException(MessageLocalization.GetComposedMessage("the.original.document.was.reused.read.it.again.from.file"));
     reader.Tampered = true;
     this.reader = reader;
     file = reader.SafeFile;
     this.append = append;
     if (append) {
         if (reader.IsRebuilt())
             throw new DocumentException(MessageLocalization.GetComposedMessage("append.mode.requires.a.document.without.errors.even.if.recovery.was.possible"));
         if (reader.IsEncrypted())
             crypto = new PdfEncryption(reader.Decrypt);
         pdf_version.SetAppendmode(true);
         file.ReOpen();
         byte[] buf = new byte[8192];
         int n;
         while ((n = file.Read(buf)) > 0)
             this.os.Write(buf, 0, n);
         file.Close();
         prevxref = reader.LastXref;
         reader.Appendable = true;
     }
     else {
         if (pdfVersion == 0)
             base.PdfVersion = reader.PdfVersion;
         else
             base.PdfVersion = pdfVersion;
     }
     base.Open();
     pdf.AddWriter(this);
     if (append) {
         body.Refnum = reader.XrefSize;
         marked = new IntHashtable();
         if (reader.IsNewXrefType())
             fullCompression = true;
         if (reader.IsHybridXref())
             fullCompression = false;
     }
     initialXrefSize = reader.XrefSize;
 }
開發者ID:mapo80,項目名稱:iTextSharp-Monotouch,代碼行數:53,代碼來源:PdfStamperImp.cs

示例6: WriteFont

        /** Outputs to the writer the font dictionaries and streams.
         * @param writer the writer for this document
         * @param ref the font indirect reference
         * @param parms several parameters that depend on the font type
         * @throws IOException on error
         * @throws DocumentException error in generating the object
         */
        internal override void WriteFont(PdfWriter writer, PdfIndirectReference piref, Object[] parms)
        {
            Hashtable longTag = (Hashtable)parms[0];
            AddRangeUni(longTag, true, subset);
            ArrayList tmp = new ArrayList();
            foreach (object o in longTag.Values) {
                tmp.Add(o);
            }
            Object[] metrics = tmp.ToArray();
            Array.Sort(metrics, this);
            PdfIndirectReference ind_font = null;
            PdfObject pobj = null;
            PdfIndirectObject obj = null;
            // sivan: cff
            if (cff) {
                RandomAccessFileOrArray rf2 = new RandomAccessFileOrArray(rf);
                byte[] b = new byte[cffLength];
                try {
                    rf2.ReOpen();
                    rf2.Seek(cffOffset);
                    rf2.ReadFully(b);
                } finally {
                    try {
                        rf2.Close();
                    } catch  {
                        // empty on purpose
                    }
                }
                if (subset || subsetRanges != null) {
                    CFFFontSubset cffs = new CFFFontSubset(new RandomAccessFileOrArray(b),longTag);
                    b = cffs.Process( (cffs.GetNames())[0] );
                }

                pobj = new StreamFont(b, "CIDFontType0C");
                obj = writer.AddToBody(pobj);
                ind_font = obj.IndirectReference;
            } else {
                byte[] b;
                if (subset || directoryOffset != 0) {
                    TrueTypeFontSubSet sb = new TrueTypeFontSubSet(fileName, new RandomAccessFileOrArray(rf), longTag, directoryOffset, false, false);
                    b = sb.Process();
                }
                else {
                    b = GetFullFont();
                }
                int[] lengths = new int[]{b.Length};
                pobj = new StreamFont(b, lengths);
                obj = writer.AddToBody(pobj);
                ind_font = obj.IndirectReference;
            }
            String subsetPrefix = "";
            if (subset)
                subsetPrefix = CreateSubsetPrefix();
            PdfDictionary dic = GetFontDescriptor(ind_font, subsetPrefix);
            obj = writer.AddToBody(dic);
            ind_font = obj.IndirectReference;

            pobj = GetCIDFontType2(ind_font, subsetPrefix, metrics);
            obj = writer.AddToBody(pobj);
            ind_font = obj.IndirectReference;

            pobj = GetToUnicode(metrics);
            PdfIndirectReference toUnicodeRef = null;
            if (pobj != null) {
                obj = writer.AddToBody(pobj);
                toUnicodeRef = obj.IndirectReference;
            }

            pobj = GetFontBaseType(ind_font, subsetPrefix, toUnicodeRef);
            writer.AddToBody(pobj, piref);
        }
開發者ID:hjgode,項目名稱:iTextSharpCF,代碼行數:78,代碼來源:TrueTypeFontUnicode.cs


注:本文中的iTextSharp.text.pdf.RandomAccessFileOrArray.ReOpen方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。