public static int Main(string[] args) { string file = args[0]; Reader reader = new Reader(); reader.SetFileName(file); bool ret = reader.Read(); if (!ret) { return(1); } File f = reader.GetFile(); DataSet ds = f.GetDataSet(); Tag tencapsulated_stream = new Tag(0x0042, 0x0011); // Encapsulated Document if (!ds.FindDataElement(tencapsulated_stream)) { return(1); } // else DataElement de = ds.GetDataElement(tencapsulated_stream); ByteValue bv = de.GetByteValue(); uint len = bv.GetLength(); byte[] encapsulated_stream = new byte[len]; bv.GetBuffer(encapsulated_stream, len); // Write out the decompressed bytes //System.Console.WriteLine(image.toString()); using (System.IO.Stream stream = System.IO.File.Open(@"/tmp/dd.pdf", System.IO.FileMode.Create)) { System.IO.BinaryWriter writer = new System.IO.BinaryWriter(stream); writer.Write(encapsulated_stream); } return(0); }