PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Thu Mar 28, 2024 4:59 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: ExtractImages sample
PostPosted: Mon Sep 07, 2009 10:39 pm 
Offline

Joined: Mon Sep 07, 2009 10:26 pm
Posts: 3
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


Top
 Profile  
Reply with quote  
 Post subject: Re: ExtractImages sample
PostPosted: Tue Sep 08, 2009 7:47 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3095
Location: Cologne, Germany
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.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
 Post subject: Re: ExtractImages sample
PostPosted: Wed Sep 09, 2009 3:37 am 
Offline

Joined: Mon Sep 07, 2009 10:26 pm
Posts: 3
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


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: Bing [Bot] and 198 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group