public static void Test_PdfExportDeflatedStream_02(String pdfFile, int objectId, string streamFile) { Writer w = null; _tr.WriteLine("export stream object {0} pdf file \"{1}\" to \"{2}\"", objectId, pdfFile, streamFile); PB_Pdf.PdfReader pr = new PB_Pdf.PdfReader(pdfFile); try { IPdfObject obj = ReadPdfObject(pr, objectId, "Object"); if (obj.deflatedStream == null) { _tr.WriteLine("no stream"); return; } _tr.WriteLine("read data"); //IPdfInstruction[] instructions = PdfDataReader.PdfReadAll(obj.deflatedStream); PdfDataReader pdr = new PdfDataReader(obj.deflatedStream); //pdr.Trace += new TraceDelegate(_tr.WriteLine); IPdfInstruction[] instructions = pdr.ReadAll(); _tr.WriteLine("{0} instructions", instructions.Length); //var q = from instruction in instructions select instruction.opeString; //foreach (string opeString in q.Distinct().OrderBy(opeString => opeString)) //{ // _tr.WriteLine(opeString); //} w = new Writer(streamFile, FileMode.Create); foreach (IPdfInstruction instruction in instructions) { //_tr.WriteLine(instruction); //w.WriteLine(instruction.ToString()); instruction.Export(w); } } finally { if (w != null) { w.Close(); } pr.Close(); } }
public static void Test_PdfExportDeflatedStream_02(String pdfFile, int objectId, string streamFile) { Writer w = null; _tr.WriteLine("export stream object {0} pdf file \"{1}\" to \"{2}\"", objectId, pdfFile, streamFile); PB_Pdf.PdfReader pr = new PB_Pdf.PdfReader(pdfFile); try { IPdfObject obj = ReadPdfObject(pr, objectId, "Object"); if (obj.deflatedStream == null) { _tr.WriteLine("no stream"); return; } _tr.WriteLine("read data"); //IPdfInstruction[] instructions = PdfDataReader.PdfReadAll(obj.deflatedStream); PdfDataReader pdr = new PdfDataReader(obj.deflatedStream); //pdr.Trace += new TraceDelegate(_tr.WriteLine); IPdfInstruction[] instructions = pdr.ReadAll(); _tr.WriteLine("{0} instructions", instructions.Length); //var q = from instruction in instructions select instruction.opeString; //foreach (string opeString in q.Distinct().OrderBy(opeString => opeString)) //{ // _tr.WriteLine(opeString); //} w = new Writer(streamFile, FileMode.Create); foreach (IPdfInstruction instruction in instructions) { //_tr.WriteLine(instruction); //w.WriteLine(instruction.ToString()); instruction.Export(w); } } finally { if (w != null) w.Close(); pr.Close(); } }