Drawings SDK Developer Guide > Getting Started with Drawings SDK > Using Sample Applications >
Exporting a Drawing File to a .pdf File

Summary

ODA Product: Drawings SDK
Sample Name: OdPdfExportEx
Categories: C++ / Working with .dwg files / Android, iOS, macOS, Linux, Windows
Location: <INSTALL_DIR>/Drawing/Examples/OdPdfExportEx

Description

OdPdfExportEx is a simple console application used for reading a .dwg or .dxf file and saving it to a .pdf file with specified export options. It illustrates the usage of Kernel/Exports/PdfExport functionality.

Run Sample Application

To run the OdPdfExportEx sample application, please do the following:

  1. Open the terminal and go to the directory where the sample binary file is built:
    • For Windows: <INSTALL_DIR>\exe\<PLATFORM_NAME>\
    • For Non-Windows OS: <INSTALL_DIR>/bin/<PLATFORM_NAME>/
    <INSTALL_DIR> is a directory where you unpacked the Drawings SDK archive.
    To determine your <PLATFORM_NAME> parameter, please see the ODA Platform Naming Conventions section in the Downloading Drawings SDK topic.
  2. Run the sample with appropriate arguments:
    OdPdfExportEx <source file> <target file> <exportflags> [options]
source file A full path to a .dwg or .dxf file to read data from.
target file A full path to a .pdf to write data to.
exportflags Export flags determining a set of export parameters. Flags are implemented as a bit mask represented with an integer value:
  • Bit 0 — Export in monochrome mode (supported for Windows only).
  • Bit 1 — Export all layouts, otherwise exports only active layout.
  • Bits 2 and 3 — Export solid non-gradient hatches:
    • 0 — export solid, non-gradient hatches as bitmaps.
    • 1 — export solid, non-gradient hatches using vectorizers.
    • 2 — export solid, non-gradient hatches as PDF paths.
  • Bit 4 — Export other types of hatches using vectorizers, otherwise hatches are exported as bitmaps.
  • Bit 5 — Set zoom to extents parameter.
  • Bit 6 — Use embedded TTF fonts.
  • Bit 7 — Use embedded optimized TTF fonts.
  • Bit 8 — Convert TTF as geometry.
  • Bit 9 — Convert SHX as geometry.
  • Bit 10 — Enable layer support.
  • Bit 11 — Add invisible layers to the output .pdf file.
  • Bit 12 — Add extents bounding box.
  • Bit 13 — Enable encoding (smaller size of the output .pdf file).
  • Bit 14 — Enable ASCII hex encoding.
  • Bit 15 — Use hidden line removal algorithm.
  • Bit 16 — Make TTF text searchable. Available only if TTF text is exported as geometry ("Convert TTF as a geometry" bit is set).
  • Bit 17 — Make SHX text searchable. Available only if SHX text is exported as geometry ("Convert SHX as a geometry" bit is set).
  • Bit 18 — Enable hyperlinks export.
  • Bit 19 — Export to a web .pdf file using the linearization algorithm.
  • Bit 20 — Export to a .pdf file using the measuring scale.
options Export options:
  • --paper PSValue — Paper size (works only if zoom to extents flag is enabled). PSValue can be one of the following:
    • A4
    • Letter
    • Custom
  • --paper-width XX — Custom paper width of XX millimeters.
  • --paper-height YY — Custom paper height of YY millimeters.
  • --geom-res YY — Vector resolution is YY dpi.
  • --bw-res YY — Resolution of monochrome raster images is YY dpi.
  • --color-policy CPValue — Color policy for the export process. CPValue can be one of the following:
    • AsIs (default).
    • MonoPlotstyle (supported in Windows only).
    • Mono.
    • Gray.
  • --archived ArchValue — Version of the archive .pdf format the origin drawing will be exported. ArchValue can be one of the following:
    • None — The orgin drawing is exported to usual .pdf format.
    • 1b — The orgin drawing is exported to PDF/A-1 format.
    • 2b — The orgin drawing is exported to PDF/A-2 format.

If the application executed properly, you will see the source file loading progress and a message informing you that the database conversion is completed. In case you get the "usage" message, check the parameters. An error message indicates problems with the source file.

See also:

Using the Sample Code

Copyright © 2002 – 2021. Open Design Alliance. All rights reserved.