PDFsharp & MigraDoc Foundation

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

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Tue Apr 08, 2014 6:39 am 
Offline

Joined: Mon Apr 07, 2014 9:46 pm
Posts: 1
Hi!

I use the PdfSharp library (1.32.2608.0) as part of a winforms-project to delete all images from a PdfPage.
When I save the document, the file-size has shrinked to a minimum (cool - that was what I tried to achieve) but when I open the document I get an error (or more an info) from the acrobat reader which tells me that there is an error on the page and that the page might not work correctly, although everything is displayed fine when I click the OK-button. Anyway, my customers shall not get that message when they open the document.

To identify the images on a page I used the code provided with the ExportImages Sample.
Before I start removing images I create a catalog with all images that are part of the whole document and a list of the pages were they get referenced.
Then I iterate all images of the page.
If the current image is not used on another page then I remove it:
Code:
PdfDictionary xObjects = resources.Elements.GetDictionary("/XObject");
...
PdfReference reference = item as PdfReference;
...
document.Internals.RemoveObject((PdfObject)reference.Value); // remove image from internal document table
xObjects.Elements.Remove(itemKey); // remove image from page resource


It seems that I somehow corrupt the pdf-file with my code.
If someone has a clean solution for this issue, it would be really cool!

Thx!


Top
 Profile  
Reply with quote  
PostPosted: Thu Oct 07, 2021 1:18 am 
Offline

Joined: Wed Oct 06, 2021 2:49 am
Posts: 1
I have this question also.
Could someone please help?


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 144 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