Flatten PDF

Magick.NET is an object-oriented C# interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning Magick.NET
Post Reply
devyekov
Posts: 19
Joined: 2014-12-01T08:16:19-07:00
Authentication code: 6789

Flatten PDF

Post by devyekov » 2015-08-06T14:55:50-07:00

Hello,

How I do "Flatten" a pdf?

Convert PDF to PDF with flatten.

Use
Magick.NET 7.0.0.0007
With
C# fw2
Ghostscript 9.16


Regards.

devyekov
Posts: 19
Joined: 2014-12-01T08:16:19-07:00
Authentication code: 6789

Re: Flatten PDF

Post by devyekov » 2015-08-06T16:00:38-07:00

I found this

Code: Select all

MagickReadSettings settings = new MagickReadSettings();
settings.Density = new MagickGeometry(300);

using (MagickImageCollection images = new MagickImageCollection())
{
   images.Read("Snakeware.pdf", settings);  
    MagickImage image = images.Flatten();
    image.Write("SnakewareNew.pdf");
}
Now the question is, as I reduce the size / quality of the file, the result is as follows:
Original file: 4566KB
New file: 44950KB

Change the value of quality without result

Code: Select all

image.Quality = 15;
Regards

snibgo
Posts: 12431
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Flatten PDF

Post by snibgo » 2015-08-06T17:11:46-07:00

What do you mean by "flatten"?
snibgo's IM pages: im.snibgo.com

devyekov
Posts: 19
Joined: 2014-12-01T08:16:19-07:00
Authentication code: 6789

Re: Flatten PDF

Post by devyekov » 2015-08-10T13:54:42-07:00

Merge / join in layers. or how does it work in ImageMagick?

How I can reduce the size of PDF?

Thk
Regards

devyekov
Posts: 19
Joined: 2014-12-01T08:16:19-07:00
Authentication code: 6789

Re: Flatten PDF

Post by devyekov » 2015-08-13T15:07:25-07:00

Hi

For the problem of the size of the file, solve with

Code: Select all

image.CompressionMethod = CompressionMethod.JPEG;
but... I think the "flatten" of the ImageMagick is different Ghostscript, how do I indicate to GhostScript from ImageMagick apply flatten? This for pdf file.

Thk
Regards

User avatar
fmw42
Posts: 25761
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Flatten PDF

Post by fmw42 » 2015-08-13T15:14:19-07:00

I do not think GS does any flattening. IM does that. Though I could be wrong if you run GS standalone.

Flattening in IM will overlay every layer/page, etc. So if your PDF has no transparency, you will only see the top most (last) page.

Perhaps you mean something else by flatten? If so, please describe what you want to happen.

Post Reply