PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Fri Mar 29, 2024 2:26 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Image replacement
PostPosted: Thu Jan 23, 2014 10:53 pm 
Offline

Joined: Thu Jan 23, 2014 10:34 pm
Posts: 1
I am looking to export images, change image quality and format, and then replace the image. I have been able to write a method with limited functionality to export the images. I've also been able to change the images from /FlateDecode to /DCTDecode.

But if I export the image, convert it to a PNG or even a BMP, the PDF document is not useable.

What other parameters do I need to set? I've tried :
-adjusting the image.Elements.SetInteger(PdfImage.Keys.Length, (int)buffer.GetLength())
-setting the BitsPerComponent
-setting the ColorSpace to Indexed8

is this an issue where i need to define a color palette? Is this do-able or should I explore trying to delete and then redraw the images?

Code:
   
        public void ReplaceImage(PdfDictionary image, Bitmap optimizedImage)
        {
            using (var ms = new MemoryStream())
            {
                optimizedImage.Save(ms, ImageFormat.Bmp);
                image.Stream.Value = ms.GetBuffer();
            }
        }


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

All times are UTC


Who is online

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