Show / Hide Table of Contents

Class Flattener

Flattener is a utility class that can be used to create PDF's that render faster on devices with lower memory and speeds.

By using the FlattenMode::e_flatten option each page in the PDF will be reduced to a single background image, with the remaining text over top in vector format. Some text may still get flattened, in particular any text that is clipped, or underneath, other content that will be flattened.

On the other hand the FlattenMode::e_simple will not flatten simple content, such as simple straight lines, nor will it flatten Type3 fonts. Flattener is a optional PDFNet add-on that can be used to simplify and optimize existing PDF's to render faster on devices with lower memory and speeds.

PDF documents can frequently contain very complex page description (e.g. thousands of paths, different shadings, color spaces, blend modes, large images etc.) that may not be suitable for interactive viewing on mobile devices. Flattener can be used to speed-up PDF rendering on mobile devices and on the Web by simplifying page content (e.g. flattening complex graphics into images) while maintaining vector text whenever possible.

By using the FlattenMode::e_simple option each page in the PDF will be reduced to a single background image, with the remaining text over top in vector format. Some text may still get flattened, in particular any text that is clipped, or underneath, other content that will be flattened.

On the other hand the FlattenMode::e_fast will not flatten simple content, such as simple straight lines, nor will it flatten Type3 fonts.

Inheritance
object
Flattener
Implements
IDisposable
Inherited Members
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
Namespace: pdftron.PDF
Assembly: PDFNet.dll
Syntax
public class Flattener : IDisposable
Remarks

'Flattener' is available as a separately licensable add-on option to PDFNet core license.

Constructors

Flattener()

Flattener constructor

Declaration
public Flattener()

Methods

Dispose()

Releases all resources used by the Flattener

Declaration
public override sealed void Dispose()

Dispose(bool)

Declaration
[HandleProcessCorruptedStateExceptions]
protected virtual void Dispose(bool A_0)
Parameters
Type Name Description
bool A_0

~Flattener()

Declaration
protected ~Flattener()

Process(PDFDoc, FlattenMode)

Process each page in the PDF, flattening content that matches the mode criteria.

Declaration
public void Process(PDFDoc doc, Flattener.FlattenMode mode)
Parameters
Type Name Description
PDFDoc doc

the document to flatten.

Flattener.FlattenMode mode

indicates the criteria for which elements are flattened.

Process(Page, FlattenMode)

Process the given page, flattening content that matches the mode criteria.

Declaration
public void Process(Page page, Flattener.FlattenMode mode)
Parameters
Type Name Description
Page page

the page to flatten.

Flattener.FlattenMode mode

indicates the criteria for which elements are flattened.

SetDPI(uint)

The output resolution, from 1 to 1000, in Dots Per Inch (DPI) at which to render elements which cannot be directly converted. the default value is 96 Dots Per Inch

Declaration
public void SetDPI(uint dpi)
Parameters
Type Name Description
uint dpi

the resolution in Dots Per Inch

SetJPGQuality(uint)

Specifies the compression quality to use when generating JPEG images.

Declaration
public void SetJPGQuality(uint quality)
Parameters
Type Name Description
uint quality

the JPEG compression quality, from 0(highest compression) to 100(best quality).

SetMaximumImagePixels(uint)

Specifies the maximum image size in pixels.

Declaration
public void SetMaximumImagePixels(uint max_pixels)
Parameters
Type Name Description
uint max_pixels

the maximum number of pixels an image can have.

SetPathHinting(bool)

Enable or disable path hinting.

Declaration
public void SetPathHinting(bool path_hinting)
Parameters
Type Name Description
bool path_hinting

if true path hinting is enabled. Path hinting is used to slightly adjust paths in order to avoid or alleviate artifacts of hair line cracks between certain graphical elements. This option is turned on by default.

SetPreferJPG(bool)

Specifies whether to leave images in existing compression, or as JPEG.

Declaration
public void SetPreferJPG(bool jpg)
Parameters
Type Name Description
bool jpg

if true PDF will contain all JPEG images.

SetThreshold(Threshold)

Used to control how precise or relaxed text flattening is. When some text is preserved (not flattened to image) the visual appearance of the document may be altered.

Declaration
public void SetThreshold(Flattener.Threshold threshold)
Parameters
Type Name Description
Flattener.Threshold threshold

the threshold setting to use.

Implements

IDisposable
In This Article
Back to top Generated by DocFX