public static void Main(string[] args) { // The path to the documents directory. string dataDir = Path.GetFullPath("../../../Data/"); string input = dataDir + @"input.pdf"; using (Document pdfDocument = new Document(input)) { foreach (Field field in pdfDocument.Form) { SignatureField sf = field as SignatureField; if (sf != null) { string outFile = dataDir + @"output.jpg"; using (Stream imageStream = sf.ExtractImage()) { if (imageStream != null) { using (System.Drawing.Image image = Bitmap.FromStream(imageStream)) { image.Save(outFile, System.Drawing.Imaging.ImageFormat.Jpeg); } } } } } } }
public static void Run() { // ExStart:ExtractingImage // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdf_SecuritySignatures(); string input = dataDir + @"ExtractingImage.pdf"; using (Document pdfDocument = new Document(input)) { foreach (Field field in pdfDocument.Form) { SignatureField sf = field as SignatureField; if (sf != null) { string outFile = dataDir + @"output_out.jpg"; using (Stream imageStream = sf.ExtractImage()) { if (imageStream != null) { using (System.Drawing.Image image = Bitmap.FromStream(imageStream)) { image.Save(outFile, System.Drawing.Imaging.ImageFormat.Jpeg); } } } } } } // ExEnd:ExtractingImage }