PDFsharp & MigraDoc Foundation
https://forum.pdfsharp.net/

Extract images from PDF
https://forum.pdfsharp.net/viewtopic.php?f=2&t=2455
Page 1 of 1

Author:  benfosterdev [ Thu May 16, 2013 9:58 pm ]
Post subject:  Extract images from PDF

Hey guys,

I'm attempting to extract images from a PDF previously generated with PDFSharp. I'm using the sample from the WIKI.

The example fails at this line:

string filter = image.Elements.GetName("/Filter");

The filter element is actually an PdfArray with the following values:

{[/Filter, [ /FlateDecode /DCTDecode ]]}

However, when I just process the image as a JPEG (the images that were added to the PDF originally were both JPEGs) the outputted files are corrupted and can not be opened.

Have you got a complete working example that I can download and test? There's plenty of examples of doing this for iTextSharp but since we're already using PDFSharp for generation I'd rather not have to resort to this.

Thanks
Ben

Author:  Thomas Hoevel [ Tue May 21, 2013 8:38 am ]
Post subject:  Re: Extract images from PDF

With "/Filter [/FlateDecode /DCTDecode]" you only have to call the decoder for "/FlateDecode" to get the JPEG file.

See also:
viewtopic.php?p=5635#p5635

Feel free to post a better sample here.

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/