How can I change flattening behaviour when converting from PDF to SVG?


I’m converting from PDF to SVG with flattening off, and the conversion is inaccurate. If I set the flatten option to fast or simple, the converted page is correct but the pixelization is unacceptably bad. So I can’t use flattening.


One solution may be for you to use Flattener beforehand, flattening from the source PDF to a flattened PDF (which could then be converted to SVG). That would allow you to control the flattening options to get high-quality output (such as SetDPI, SetMaximumImagePixels, or SetThreshold):

For example, you could “pre-flatten” a PDF document with the following code (from

using (PDFDoc doc = new PDFDoc(@“G:\995.pdf”))

Flattener fl = new Flattener();

// The following lines can increase the resolution of background
// images.

// This line can be used to output Flate compressed background
// images rather than DCTDecode compressed images which is the default

// In order to adjust thresholds for when text is Flattened
// the following function can be used.

// We use e_fast option here since it is usually preferable
// to avoid Flattening simple pages in terms of size and
// rendering speed. If the desire is to simplify the
// document for processing such that it contains only text and
// a background image e_simple should be used instead.

doc.Save(@“G:\995_pre_flattened.pdf”, SDFDoc.SaveOptions.e_linearized);

After converting the pre-flattened PDF document to SVG, the output appears quite legible.