Hatch Types and Exporting to PDF

Sergey Sherstnev
July 25, 2017

Tags: export rendering

Sometimes ODA members ask about exporting hatches and why a resulting .pdf file is very slow to open or why the quality of exported hatches is poor. This article explains a few things about hatches and exporting them to PDF.

There are three main types of hatches in .dwg files:

image1

Solid hatches have a solid fill, gradients have one or two gradient colors, and other hatches are filled with a pattern.

There are three ways to export hatches to PDF:

enum ExportHatchesType
{
  kBitmap =   0, //Exports hatches as a bitmap.
  kDrawing =  1, //Exports hatches as a drawing (vectorizer).
  kPdfPaths = 2  //Exports hatches as a PDF path.
};

The kBitmap type just creates a bitmap picture from the hatch and puts it into the .pdf file. kDrawing and kPdfPaths both use a vectorizer to export with an important difference between them: kDrawing exports hatches as a polygon set and kPdfPaths exports the outer loop of the hatch only and fills that loop with color. This means that kPdfPaths can only be applied to solid hatches and not to gradient or pattern hatches, and for gradient and pattern hatches will be automatically changed to the kBitmap way of exporting. kBitmap and kPdfPaths can be used for exporting all hatch types.

About the quality of hatches in .pdf files. Because kDrawing and kPdfPaths export hatches via a vectorizer using packs of polygons or outer hatch loops for rendering, the quality of the resulting .pdf file will be determined by the vector resolution parameter:

void     setGeomDPI(OdUInt16 dpi);

Other quality parameters do not impact these two ways of exporting hatches. The setGeomDPI parameter is also meaningful for the bitmap export type when a hatch has a complicated border. When exporting hatches as a bitmap, the quality can also be customized using the following parameter:

void setHatchDPI(OdUInt16 dpi)

This parameter determines the resolution of the resulting bitmap image.

Hopefully this article helps to export hatches correctly and avoid errors.

All posts