Using ( image = new (data_buffer, (uint)data_size)) Image_obj_stream.GetData(is_raw_data, (uint)data_size, data_buffer) IntPtr data_buffer = Marshal.AllocHGlobal(data_size) Int data_size = image_obj_stream.GetDataSize(is_raw_data) String saved_path = output_folder + saved_filename + image_file_ext String saved_filename = "pageimage_" + image_number PDFStream.Filter stream_filter = image_obj_stream.GetStreamFilter() Using (PDFStream image_obj_stream = image_obj.GetStream()) #Judge stream filter type to decide the image format and how to get image data. Using (ImageObject image_obj = graphics_obj.GetImageObject()) Position = current_graphics_objs.GetNextGraphicsObjectPosition(position, filter) GraphicsObject graphics_obj = current_graphics_objs.GetGraphicsObject(position) Long position = current_graphics_objs.GetFirstGraphicsObjectPosition(filter) Public static void SaveImageFromImageObject(GraphicsObjects current_graphics_objs, int page_index) Page.StartParse((int)_ParsePageNormal, null, false) If (error_code != ErrorCode.e_ErrSuccess)Ĭonsole.WriteLine("Library Initialize Error: ", input_pdf_path, error_code) public static int image_number = 0 ĮrrorCode error_code = Library.Initialize(sn, key) You can use Foxit PDF SDK to try to judge the appropriate image type for image objects in PDF files and extract them from PDF files. Here is some sample C# code which demonstrates how to go through each image object in a PDF file, judge the appropriate image type for each image object and save each image to disk. This can be tricky at times because some image formats such as PNG are not native to the PDF format so they are manipulated and stored in a modified form in the PDF. When this happens you’ll most likely want to save the image data back into the image format that it was originally in before it was added to the PDF. Sometimes it’s necessary to extract images from PDF files and save them to disk.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |