PDFsharp & MigraDoc Foundation
http://forum.pdfsharp.com/

ExtractImages sample
http://forum.pdfsharp.com/viewtopic.php?f=2&t=861
Page 1 of 1

Author:  jaredhite1 [ Mon Sep 07, 2009 10:39 pm ]
Post subject:  ExtractImages sample

Hello-
First, thanks to all the contributors of PDFSharp...The API is well thought out and intuitive, deployment is easy, the license isn't very restrictive, and everything works pretty much exactly like I would expect it to. In other words, it's nothing like all the other open-source projects out there. :-) PDFSharp has solved several big problems for me and the company I work for.

I have two questions:
1. On http://www.pdfsharp.net/wiki/ExportImages-sample.ashx, it appears that the ExportImage method is missing, which I think is rather important to the Export Image sample. :-) Does anybody know what the ExportImages method looks like? I have some guesses but I'd rather see something from somebody who knows what they're doing.

2. I was looking at that sample to see if there was a way I could swap out one image for another in an existing PDF. Right now I am overwriting the old image with my new one, but it seems like there might be a more elegant solution out there somewhere. Does anybody know if this is possible? Alternatively, simply deleting the old image altogether would work for me too.

Thanks!
Jared

Author:  Thomas Hoevel [ Tue Sep 08, 2009 7:47 am ]
Post subject:  Re: ExtractImages sample

Hi, Jared!

Re 1: The ExportImages method was missing in the Wiki - but it's all open source anyway (it's in the Wiki now).

Re 2: Not my area of expertise, but I'd try to replace the stream of the existing image.

Author:  jaredhite1 [ Wed Sep 09, 2009 3:37 am ]
Post subject:  Re: ExtractImages sample

Thanks for the reply Thomas. I tried to replace the image by replacing the Stream.Value property with a File.ReadAllBytes(jpegImageFilename). When I opened the PDF, I got an error like "Insufficient data for an image." So I tried to remove the image altogether by removing it using a number of loops and such that boils down to something like page.Elements.GetDictionary("/Resources").Elements.GetDictionary("/XObject").Elements.Remove(imageKey) along with a Document.Internals.RemoveObject(imagePdfDictionary). Again, this successfully removed the element but I got an error when opening the PDF in Acrobat. That time the error was more generic, "This PDF document has errors, contact the author of the PDF" kind of thing. I suspect there is something out there that Any ideas?

Thanks!
Jared

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