ODA Product: | ODA PRC SDK |
Sample Name: | OdPdfExportWithPrc |
Categories: | C++ / Beginner / Working with .prc files / Android, iOS, macOS, Linux, Windows |
Source Code Location: | CommonApplications/Prc/Examples/OdPdfExportWithPrc |
A sample console application that exports a .dwg/.dxf file to a .pdf file with PRC format support.
The example creates a drawing database, fills it with one or several entities, and exports the drawing contents to a specified .pdf file as a PRC mesh or boundary representation. The quantity of entities and type of PRC content depends on the first application argument.
To run the OdPdfExportWithPrc
sample application, please do the following:
<PRC_DIR>\exe\<version>
<PRC_DIR>/bin/<version>
<PRC_DIR>
is a directory where you unpacked the PRC SDK archive.
To determine your <version>
parameter, please see the
appropriate section
in the Download ODA PRC SDK topic.
OdPdfExportWithPrc <export case> <target file>
export case
|
Name of an export case to execute.
The export case determines export parameters and options. The following
export cases are available:
|
target file
|
Full path to the output .pdf file that will contain all exported content. |
If the application executed properly, you will see the following console window:
If an error occurs during the application execution, you will see an appropriate error message in the console window. For example, the following picture illustrates the program output in the case when it was called with wrong arguments:
The sample application creates a new PDF file with specified name that can be open with any available PDF viewer with support of PRC format.
The main() function checks the input arguments, creates a custom services instance (a MyServices object), initializes the ODA Platform and makes other actions that are typical for console samples based on ODA Platform. When the initial actions are complete, the OdPdfExportWithPrcStart() function is called.
Below is the functions call schema:
main()
|
|-->OdPdfExportWithPrcStart()
|
|-->OdPdfExportWithPrc(OdDbHostAppServices, OdString)
| |
| |-->OdPdfExportWithPrc(OdDbHostAppServices, OdString, PDFExportParams::PRCSupport, bool, void (*fillerfunc)(OdDbDatabasePtr&))
| |
| |-->fillDatabase()
|
|-->OdPdfExportWithPrcSeveralEntities()
| |
| |-->OdPdfExportWithPrc(OdDbHostAppServices, OdString, PDFExportParams::PRCSupport, bool, void (*fillerfunc)(OdDbDatabasePtr&))
| |
| |-->fillDatabaseWithSeveralEntities()
|
|-->OdPdfPrcFilterExample()
|
|-->fillDatabase() in OdPdfPrcFilterExample.cpp
| |
| |-->fillDatabaseWithSeveralEntities()
| |
| |-->addFrame()
| |
| |-->addLayer()
| |
| |-->fillpoly()
|
|-->setupFilters()
|
|-->fillPdfExportParams()
Runs the OdPdfExportWithPrc(OdDbHostAppServices&, OdString) function.
Input parameters:
export
case
input argument.Module: OdPdfExportWithPrcStart.cpp
The sample application contains two overrides of the OdPdfExportWithPrc function:
This function does the following:
There are two fillDatabase() functions in different modules:
Creates a new drawing database, adds to it a red box, green cylinder, blue cone and magenta torus (see the fillDatabaseWithSeveralEntities() function) and exports it to a .pdf file with PRC format support.
Input parameters:
This function calls the OdPdfExportWithPrc() function, specifying the pointer to the fillDatabaseWithSeveralEntities() function as the last parameter.
Module: OdPdfExportWithPrcStart.cpp
Creates a red box, green cylinder, blue cone, and magenta torus, and appends these entities to the specified database.
Input parameter:
Module: OdPdfPrcFilterExample.cpp
Does the following:
Input parameters:
Module: OdPdfPrcFilterExample.cpp
Creates four squares centered at the origin (for creating each polyline the fillpoly() function is called):
Input parameter:
Module: OdPdfPrcFilterExample.cpp
Adds a new layer to a specified drawing:
Input parameters:
Module: OdPdfPrcFilterExample.cpp
Creates a square centered at the origin by adding vertexes to a specified polyline. Newly created vertices have the following coordinates (x, y), (x, y2), (x2, y2), (x, y).
Input parameters:
Registers the PrcLayerFilter class in the ODA Platform environment.
The PrcLayerFilter class implements filtering functionality. For additional information, see PrcLayerFilter class and entity filtering implementation.
Sets .pdf file export parameters:
Input parameters:
PrcLayerFilter overrides the shouldExportAsPRC() method to determine whether a graphical entity should be exported to PRC format.
Input parameters of the shouldExportAsPRC() method:
Therefore, the squares created in the addFrame() function that are located on the "Frame" layer will be exported to a .pdf page, not to a PRC view.
ODA PRC SDK Sample Applications
Copyright © 2002 – 2020. Open Design Alliance. All rights reserved.
|