/////////////////////////////////////////////////////////////////////////////// // Copyright (C) 2002-2025, Open Design Alliance (the "Alliance"). // All rights reserved. // // This software and its documentation and related materials are owned by // the Alliance. The software may only be incorporated into application // programs owned by members of the Alliance, subject to a signed // Membership Agreement and Supplemental Software License Agreement with the // Alliance. The structure and organization of this software are the valuable // trade secrets of the Alliance and its suppliers. The software is also // protected by copyright law and international treaty provisions. Application // programs incorporating this software must include the following statement // with their copyright notices: // // This application incorporates Open Design Alliance software pursuant to a license // agreement with Open Design Alliance. // Open Design Alliance Copyright (C) 2002-2025 by Open Design Alliance. // All rights reserved. // // By use of this software, its documentation or related materials, you // acknowledge and accept the above terms. /////////////////////////////////////////////////////////////////////////////// #ifndef _PDFEXPORTPARAMS_INCLUDED_ #define _PDFEXPORTPARAMS_INCLUDED_ /*!DOM*/ #include "PdfExportDef.h" #include "Gs/GsPageParams.h" #include "DbBaseDatabase.h" #include "OdStreamBuf.h" #include "PrcContextForPdfExport.h" #include "Pdf/Pdf3dEnums.h" #include "Pdf/PdfVersion.h" #include "Pdf/PdfDbWrapper.h" #include "UInt32Array.h" #include "SSet.h" class OdGsBaseVectorizer; /** \details The namespace contains declarations related to exporting to the PDF format functionality. */ namespace TD_PDF_2D_EXPORT { /** \details A set of parameters for adding a watermark annotation to the output PDF file. */ struct Watermark { /** \details Enumerates fonts, which can be used in a watermark annotation. */ enum WatermarkFonts { /** Times Roman font set.*/ kTimesRoman, /** Helvetica font set.*/ kHelvetica, /** Courier monospace font set.*/ kCourier, /** Symbol font set.*/ kSymbol, /** Bold Times font set.*/ kTimesBold, /** Bold Helvetica font set.*/ kHelveticaBold, /** Bold Courier monospace font set.*/ kCourierBold, /** Zapf Dingbats font set.*/ kZapfDingbats, /** Times italic font set.*/ kTimesItalic, /** Helvetica oblique font set.*/ kHelveticaOblique, /** Courier oblique font set.*/ kCourierOblique, /** Times bold and italic font set.*/ kTimesBoldItalic, /** Helvetica bold and oblique font set.*/ kHelveticaBoldOblique, /** Courier bold and oblique font set.*/ kCourierBoldOblique, /** Font selected from system installed TTF fonts*/ kSystemTTFFont = -1 }; /** \details Enumerates available positions for the watermark annotation. */ enum WatermarkPosition { /** From left to right in the page's center.*/ kLeftToRight, /** From the upper-left corner to the lower-right corner of the page.*/ kUpperLeftToLowerRight, /** From the lower-left corner to the upper-right corner of the page.*/ kLowerLeftToUpperRight, /** The upper-left corner of the page.*/ kUpperLeft, /** The upper-right corner of the page.*/ kUpperRight, /** The lower-right corner of the page.*/ kLowerRight, /** The lower-left corner of the page.*/ kLowerLeft, /** The upper-middle position of the page.*/ kUpperMiddle, /** The lower-middle position of the page.*/ kLowerMiddle, /** The left position in the page center.*/ kLeftMiddle, /** The right position in the page center.*/ kRightMiddle }; /** Watermark text. If image is used as watermark, text is not used*/ OdString text; /** Watermark text color (default value is black).*/ ODCOLORREF color; /** Watermark text font size (default value is 48).*/ OdUInt16 fontSize; /** The level of the watermark's opacity (in percents from 0 to 100; the default value is 50).*/ OdUInt16 opacity; /** Watermark text font (default value is kTimesRoman).*/ WatermarkFonts font; /** Watermark text direction (default value is kLeftToRight).*/ WatermarkPosition position; /** The fit to page flag. The flag determines whether the watermark is scaled to fit the page. Font size is recalculated (default value is false).*/ bool scaleToPage; /** An offset from the watermark position in millimeters.*/ OdGePoint2d offset; /** The rotation angle in radians (counterclockwise).*/ double rotation; /** The index of the page that contains the watermark (default value is -1: add watermark on every page).*/ int pageIndex; /** The type name of a particular TTF font to use in case when the watermark text font name equals the kSystemTTFFont value.*/ OdString fontName; /** A path to an image file to use for the watermark. If an image is used as a watermark, the watermark text is not displayed.*/ OdString imagePath; /** A watermark image width in millimeters.*/ OdUInt16 imageWidth; /** A watermark image height in millimeters.*/ OdUInt16 imageHeight; /** \details Creates a new watermark annotation object with default parameters. */ Watermark() : color(0) , fontSize(48) , opacity(50) , font(kTimesRoman) , position(kLeftToRight) , scaleToPage(false) , rotation(0.) , pageIndex(-1) , imageWidth(0) , imageHeight(0) {}; }; /** \details An abstract class that provides an interface of a reactor to handle .pdf export actions on the level of the calling subroutine. A reactor can be used, for example, to calculate surface tolerance, which should be used by ACIS for tessellation. */ class PdfExportReactor { public: /** \details Destroys the reactor object. */ virtual ~PdfExportReactor() {}; /** \details Starts the vectorization of the specified client view. \param vect [in] An OdGsBaseVectorizer object. */ virtual void beginViewVectorization(OdGsBaseVectorizer& vect) = 0; /** \details Ends the vectorization process. \param vect [in] An OdGsBaseVectorizer object. */ virtual void endViewVectorization(OdGsBaseVectorizer& vect) = 0; }; /** \details A base class that implements storing and handling the PDF export parameters. */ class PDFExportBaseParams { public: /** \details Destroys the set of export parameters. */ virtual ~PDFExportBaseParams() {} /** \details Sets a database to be exported. \param pDb [in] A raw pointer to the database object to be exported. */ void setDatabase(OdDbBaseDatabase* pDb) { m_pDb = pDb; } /** \details Retrieves the database to be exported. \returns A raw pointer to a database object to be exported. */ OdDbBaseDatabase* database() const { return m_pDb; } /** \details Sets a selection set array to be exported. \param pSSets [in] An array of selection set objects. \remarks To export data from several databases or several layouts, the size of the selection set array must be equal to the size of the array with names of layouts to be exported. */ void setSelectionSetsArray(const OdArray& pSSets) { m_pSSets = pSSets; } /** \details Retrieves the array of selection set objects. \returns The array of selection set objects. */ const OdArray& getSelectionSetsArray() const { return m_pSSets; } /** \details Sets an array of drawing layouts to be exported to PDF. \param layouts [in] A string array with names of layouts to be exported. \param pDbArray [in] A raw pointer to an array of smart pointers to OdRxObject instances that represent the drawings to which the exported layouts belong. \remarks If the array size is equal to zero, only the active layout is exported. Use the second parameter to specify drawing databases the exported layouts belong to, which is necessary when you want to export layouts from different drawings. In this case, pass two arrays with the same size: each layout name in the first array must correspond to a smart pointer to a drawing database object that the exported layout belongs to in the second array. When exporting data from a single drawing, do not pass the second parameter to the method. \sa * Export Several Drawings to one PDF File * Export Selected Entities to PDF * Export Layouts and Set Page Parameters for PDF */ void setLayouts(const OdArray& layouts, const OdRxObjectPtrArray* pDbArray = 0) { if (!pDbArray || !layouts.size()) { m_layouts = layouts; m_Databases.clear(); } else if (layouts.size() == pDbArray->size()) { m_layouts = layouts; m_Databases = *pDbArray; } } /** \details Retrieves the array of drawing layouts to be exported to PDF. \returns An array of OdString objects that contain layout names. \remarks This is an obsolete method, which will be removed later. Consider using of this method. \sa * Export Selected Entities to PDF * Export Layouts and Set Page Parameters for PDF * Export Several Drawings to one PDF File */ OdStringArray& layouts() { return m_layouts; } /** \details Adds the specified layout to the layout array to export. \param s [in] A string that contains the name of the layout to be exported. \sa * Export Selected Entities to PDF * Export Layouts and Set Page Parameters for PDF */ void addLayout(const OdString& s) { m_layouts.push_back(s); } /** \details Retrieves the array of drawing layouts to be exported to PDF. \returns An array of OdString objects that contain layout names. \remarks If the array size is equal to zero, only the active layout is exported. \sa * Export Selected Entities to PDF * Export Layouts and Set Page Parameters for PDF * Export Several Drawings to one PDF File */ const OdStringArray& layouts() const { return m_layouts; } /** \details Retrieves the array of databases to be exported to PDF. \returns An array of smart pointers to OdRxObject instances that refer to the databases containing data to export. \remarks If the array size is equal to zero, only content from the current drawing database is exported. Each element in the returned array corresponds to an element in the array with names of exported layouts (you can request this array via the method) and refers to the drawing database that contains the layout. \sa * Export Several Drawings to One PDF File */ const OdRxObjectPtrArray& databases() const { return m_Databases; } /** \details Retrieves the array of databases to be exported to PDF. \returns An array of smart pointers to OdRxObject instances that refer to the databases containing data to export. \remarks This is an obsolete method, which will be removed later. Consider using of this method. */ OdRxObjectPtrArray& databases() { return m_Databases; } /** \details Clears the multiple database settings (array of databases and array of indexes). */ void clearMultipleDbSettings() { m_Databases.clear(); m_layouts.clear(); m_pDb = 0; } protected: /** \details Creates a new set of export parameters with default values. */ PDFExportBaseParams() : m_pDb(0) { } PDFExportBaseParams(const PDFExportBaseParams& other) { m_pDb = other.m_pDb; m_pSSets = other.m_pSSets; m_layouts = other.m_layouts; m_Databases = other.m_Databases; } OdDbBaseDatabase* m_pDb; // Pointer to the database for export. OdArray m_pSSets; //Selection set to export (there can be several set for several databases) OdStringArray m_layouts; // Layouts to export. If zero size array, active layout will be exported. // For allowing export of layouts from multiple databases to 1 multi-sheet pdf file) OdRxObjectPtrArray m_Databases; // One entry for each database containing layouts to be exported. }; /** \details A class that implements storing and handling parameters for export to a PRC stream. */ class PRCExportParams : public virtual PDFExportBaseParams { public: /** \details PRC export support enumeration. */ enum PRCSupport { /** Export to PRC is disabled.*/ kDisabled = 0, /** Exports PRC is supported as Boundary representation.*/ kAsBrep = 1, /** Exports PRC is supported as Mesh representation.*/ kAsMesh = 2 }; /** \details Creates a new set of export parameters with default values. */ PRCExportParams() : PDFExportBaseParams() , m_PRCMode(kDisabled) , m_PRCCompressionLevel(0) , m_PRCContext() , m_PRCAmbientColorBehavior(PDF3D_ENUMS::kExportNotInited) { } /** \details Destroys the set of export parameters. */ ~PRCExportParams() override {}; /** \details Sets a new value of the "export to PRC" flag. \param flags [in] A new flag value to be set. */ virtual void setPRCMode(PRCSupport flags) { m_PRCMode = flags; } /** \details Retrieves the PRC mode option (the "export to PRC" flag value). \returns A Boolean value that is equal to true if the export to PRC option is enabled; otherwise, the method returns false. */ PRCSupport getPRCMode(void) const { return m_PRCMode; } /** \details Retrieves the current PRC export context. \returns A raw pointer to the PRC export context object that is applied to the set of parameters. \remarks You can use the returned pointer to modify the context object. \sa * Export to PDF using PRC topic in Drawings SDK documentation. */ OdPrcContextForPdfExport* getPRCContext(void) { return (OdPrcContextForPdfExport*)m_PRCContext.get(); } /** \details Retrieves the current PRC export context. \returns A raw pointer to the PRC export context object that is applied to the set of parameters. \remarks Please note that the method returns context object in read-only mode. \sa * Export to PDF using PRC topic in Drawings SDK documentation. */ const OdPrcContextForPdfExport* getPRCContext(void) const { return (OdPrcContextForPdfExport*)m_PRCContext.get(); } /** \details Sets the PRC export context. \param pContext [in] A raw pointer to an OdRxObject that represents the context that is used for exporting to a PRC file. \sa * Export to PDF using PRC topic in Drawings SDK documentation. */ void setPRCContext(OdRxObject* pContext) { m_PRCContext = pContext; } /** \details Retrieves the current compression level for B-Rep within PRC content. \param compressionLev [out] A placeholder for the compression level value. \returns A Boolean value that is equal to true if B-Rep compression of PRC content is enabled; otherwise, the method returns false. \remarks The method fills the passed value of the PDF3D_ENUMS::PRCCompressionLevel enumeration with the current compression level and returns it to a calling subroutine. */ bool hasPrcBrepCompression(PDF3D_ENUMS::PRCCompressionLevel& compressionLev) const { if ((m_PRCCompressionLevel & 0x00000004) != 0) { // apply mask compressionLev = (PDF3D_ENUMS::PRCCompressionLevel)(m_PRCCompressionLevel & 0x00000003); return true; } return false; } /** \details Retrieves whether the tessellation compression for PRC content is enabled. \returns A Boolean value that is equal to true if tessellation compression for PRC content is enabled; otherwise, the method returns false. */ bool hasPrcTessellationCompression() const { return ((m_PRCCompressionLevel & 0x00000008) != 0); } /** \details Set the compression options for output PRC objects. \param compressionLevel [in] Compression level (depends on the used algorithm) that is applied during the export process. \param bCompressBrep [in] B-Rep data compression flag. If the value is equal to true, B-Rep data is compressed. \param bCompressTessellation [in] Tessellation data compression flag. If the value is equal to true, tessellation data is compressed. */ void setPRCCompression(PDF3D_ENUMS::PRCCompressionLevel compressionLevel, bool bCompressBrep, bool bCompressTessellation) { if ((!bCompressBrep) && (!bCompressTessellation)) { SETBIT_0(m_PRCCompressionLevel, 0x00000004); SETBIT_0(m_PRCCompressionLevel, 0x00000008); return; } m_PRCCompressionLevel = compressionLevel; SETBIT(m_PRCCompressionLevel, 0x00000004, bCompressBrep); SETBIT(m_PRCCompressionLevel, 0x00000008, bCompressTessellation); } /** \details Retrieves the current PRC behavior option for exporting ambient color components to PRC within the texture export. \returns A value of the PDF3D_ENUMS::PrcExportColorComponentBehavior enumeration that represents the current behavior when exporting color components to PRC. */ PDF3D_ENUMS::PrcExportColorComponentBehavior getPrcExportAmbientColorBehavior() const { return m_PRCAmbientColorBehavior; } /** \details Sets the PRC behavior option for exporting ambient color components to PRC within the texture export. \param value [in] A new default behavior option for the export of color components to a PRC value. \remarks The PrcExportColorComponentBehavior enumeration contains the following values: * kExportAsIs - The ambient color component is exported as is. The rendering of the model in Adobe Reader may differ from the rendering of the original when using ODA SDKs. * kExportWhite - The ambient color component is exported as white. Rendering the model in Adobe Reader is closest to rendering the original drawing when using ODA SDKs and the OpenGL device. * kExportNotInited - The ambient color component is exported as a united color. Rendering the model in Adobe Reader is closest to rendering the original drawing when using ODA SDKs and the OpenGL ES2 device. */ void setPrcExportAmbientColorBehavior(PDF3D_ENUMS::PrcExportColorComponentBehavior value) { m_PRCAmbientColorBehavior = value; } protected: PRCExportParams(const PRCExportParams& other) { m_PRCMode = other.m_PRCMode; m_PRCContext = other.m_PRCContext; m_PRCCompressionLevel = other.m_PRCCompressionLevel; m_PRCAmbientColorBehavior = other.m_PRCAmbientColorBehavior; } //PRC related params PRCSupport m_PRCMode; OdUInt32 m_PRCCompressionLevel; //PRCCompressionLevel and 0x00000004 is bCompressBrep and 0x00000008 is bCompressTessellation OdRxObjectPtr m_PRCContext; //User-defined PRC context PDF3D_ENUMS::PrcExportColorComponentBehavior m_PRCAmbientColorBehavior; //Behavior when exporting ambient colour to PRC }; /** \details A class that implements storing and handling parameters for exporting to the 3D PDF format. */ class PDFExport3DParams : public PRCExportParams { public: /** \details Retrieves the PRC background option. \returns A Boolean value that is equal to true if the PRC background color is set; otherwise, the method returns false. */ bool hasPrcBackground(void) const { return m_prcHasBackground; } /** \details Retrieves the background color for the PRC content. \returns An ODCOLORREF value that represents the currently set color of PRC background. */ ODCOLORREF getPrcBackground(void) const { return m_prcBackground; } /** \details Sets a new PRC background color. \param bacgr [in] An ODCOLORREF value that represents the default background color in the output PRC file. */ void setPrcBackground(ODCOLORREF bacgr) { m_prcHasBackground = true; m_prcBackground = bacgr; } /** \details Clears the PRC background color. */ void clearPrcBackground() { m_prcHasBackground = false; } /** \details Retrieves the current rendering mode for PRC content. \returns A value of the PRCRenderingMode enumeration that represents the current rendering mode for PRC content. */ PDF3D_ENUMS::PRCRenderingMode getPrcRenderingMode() { return m_PRCRenderMode; } /** \details Sets the PRC rendering mode. \param renderMode [in] A new default rendering mode value. */ void setPrcRenderingMode(PDF3D_ENUMS::PRCRenderingMode renderMode) { m_PRCRenderMode = renderMode; } protected: //PRC related params bool m_prcHasBackground; //True => Prc backgrounds should be enabled ODCOLORREF m_prcBackground; //Default background color for PRC. Default: white. PDF3D_ENUMS::PRCRenderingMode m_PRCRenderMode; /** \details Creates a new set of export parameters with default values. */ PDFExport3DParams() : PRCExportParams() { init(); } /** \details Creates a new set of export parameters with default values. */ PDFExport3DParams(const PRCExportParams& prc_export_params) : PRCExportParams(prc_export_params) { init(); } virtual void init() { m_prcHasBackground = false; m_prcBackground = ODRGB(255, 255, 255); m_PRCRenderMode = PDF3D_ENUMS::kDefaultMode; } }; /** \details A class that implements storing and handling the export parameters for an output PDF document. */ class PDFExportDocumentParams { public: /** \details Enumerates access permission flags for a PDF document. */ enum PDFAccessPermissionsFlags { /** Allows copying or other ways of extracting text and graphics from the document.*/ kAllowExtract = 1, /** Allows inserting, rotating, and deleting pages from a document, creating bookmarks, and creating thumbnail images, even when the kAllowModifyOther flag is not set.*/ kAllowAssemble = 2, /** Allows adding and modifying annotations (comments), filling interactive form fields, and when the kAllowModifyOther flag is switched on, creating and modifying interactive form fields (including signature fields).*/ kAllowAnnotateAndForm = 4, /** Allows filling of existing interactive form fields (including signature fields), even if the kAllowAnnotateAndForm flag is switched off.*/ kAllowFormFilling = 8, /** Allows modifying document contents by using operations that are not controlled by the following flags: * kAllowAssemble * kAllowAnnotateAndForm * kAllowFormFilling */ kAllowModifyOther = 16, /** Allows printing a document to a representation from which an exact digital copy of the PDF content could be generated.*/ kAllowPrintAll = 32, /** Allows printing a document with possibly a lower quality level. Ignored if the kAllowPrintAll flag is switched on.*/ kAllowPrintLow = 64, /** The default flag combination.*/ kDefaultPermissions = kAllowExtract | kAllowFormFilling | kAllowPrintAll }; /** \details PDF/A format mode enumeration. */ enum PDF_A_mode { /** PDF/A format is not supported*/ kPDFA_None = 0, /**PDF/A-1b version*/ kPDFA_1b, /**PDF/A-2b version*/ kPDFA_2b, /**PDF/A-3b version*/ kPDFA_3b }; /** \details Destroys the set of output PDF document parameters. */ virtual ~PDFExportDocumentParams() {} /** \details Sets a new value for the version parameter of the output PDF file. \param version [in] A new value of the PDF version parameter. */ void setVersion(OdPDF::PDFFormatVersions version) { m_ver = version; } /** \details Retrieves the version of the output PDF file. \returns A value of the PDFFormatVersions enumeration that represents the version for the output PDF file. */ OdPDF::PDFFormatVersions version() const { return m_ver; } /** \details Sets a new PDF/A mode value. \param mode [in] An instance of PDF/A mode to be set. */ void setArchived(PDF_A_mode mode) { m_pdfAMode = mode; } /** \details Retrieves the current value of the PDF/A mode. \returns A value of the PDF_A_mode enumeration that represents the current value of PDF/A mode. */ PDF_A_mode archived() const { return m_pdfAMode; } /** \details Sets a new array of page parameters to be used during the export. \param pageParams [in] A new page parameters array to be set. \remarks Page parameters contain such options as paper size, margins. All the values are measured in mm. */ void setPageParams(const OdArray& pageParams) { m_pageParams = pageParams; } /** \details Retrieves the array of page parameters to be used during the export. \returns An array of OdGsPageParams objects that contains page parameters. \remarks Page parameters contain such options as paper size, margins. All the values are measured in mm. */ OdArray& pageParams() { return m_pageParams; } /** \details Sets a new title for the output PDF document. \param sTitle [in] A new value for the output document's title. */ void setTitle(const OdString& sTitle) { m_Title = sTitle; } /** \details Retrieves the current title for the output PDF document. \returns An OdString object that contains the current PDF document title. */ OdString title() const { return m_Title; } /** \details Sets a new value of the author of the output PDF document. \param sAuthor [in] A new value of the author of the output document. */ void setAuthor(const OdString& sAuthor) { m_Author = sAuthor; } /** \details Retrieves the author of the output PDF document. \returns An OdString object that contains the author of the output PDF document. */ OdString author() const { return m_Author; } /** \details Sets a new value of the output PDF document subject. \param sSubject [in] A new value for the subject. */ void setSubject(const OdString& sSubject) { m_Subject = sSubject; } /** \details Retrieves a value of the output PDF document subject. \returns An OdString object that contains the subject of the output PDF document. */ OdString subject() const { return m_Subject; } /** \details Sets keywords associated with the output PDF document. \param sKeywords [in] A new keywords string to be set. */ void setKeywords(const OdString& sKeywords) { m_Keywords = sKeywords; } /** \details Retrieves keywords associated with the output PDF document. \returns An OdString object that contains keywords associated with the output PDF document. */ OdString keywords() const { return m_Keywords; } /** \details Sets a new value of the output PDF document creator. \param sCreator [in] A new value of the creator. \remarks If the output document was converted to PDF from another format, the name of the application (for example, Adobe FrameMaker) that created the original document from which it was converted. */ void setCreator(const OdString& sCreator) { m_Creator = sCreator; } /** \details Retrieves the output PDF document creator. \returns An OdString object that contains the output PDF document creator. \remarks If the output document was converted to PDF from another format, the name of the application (for example, Adobe FrameMaker) that created the original document from which it was converted. */ OdString creator() const { return m_Creator; } /** \details Sets a new value of the output PDF document producer. \param sProducer [in] A new value of the producer to be set. \remarks If the document was converted to PDF from another format, the name of the application (for example, Acrobat Distiller) that converted it to PDF. If the specified name is null or is empty, the document producer name becomes equal to the string "ODA PDF Export vX.X". */ void setProducer(const OdString& sProducer) { m_Producer = sProducer; } /** \details Retrieves the output PDF document producer. \returns An OdString object that contains the output PDF document producer. \remarks If the document was converted to PDF from another format, the name of the application (for example, Acrobat Distiller) that converted it to PDF. If the producer data was not specified, the document producer name becomes equal to the string "ODA PDF Export vX.X". */ OdString producer() const { return m_Producer; } /** \details Sets a new user password for the output PDF document. \param sUserPassword [in] A string that contains a new value for the output document's user password. \remarks *Password protection functionality is supported only for PDF versions 1.3 and higher.* There are two types of passwords: * User password (Document Open Password) is required to open a PDF document. * Owner password is required to gain full access to the document (owner access). Owner access gives permissions for changing passwords and access permissions for the document. When a password of at least one of these two types is specified, the PDF export module creates an encrypted output document. The type of encryption depends on the PDF version. The following rules apply for granting access to PDF document content depending on which passwords and access permissions were specified: * When only the user password is set, Adobe® Acrobat® Reader® requires this password to view the document. If the entered password is correct, full access to the document is granted. Access permissions are ignored. Other applications that read PDF documents take the access permissions into account. This means that if the entered user password is correct, the document is opened for viewing (read mode). Other operations can proceed only if the appropriate access permissions are granted. * When only the owner password is specified (the user password is not set), the PDF document can be opened for viewing without entering a password. Other operations are available only if the respective access permissions are granted, and the owner password is required to proceed with any of the allowed operations. * When the owner password is specified and it is not equal to the user password (the user password is also set), the PDF document can be opened for viewing by entering any of the passwords. If the user enters the owner password, full access to the document is granted. If the user enters the user password, other operations are allowed only if the respective access permissions are granted. To proceed with any of these operations, the owner password is required. * When both passwords are equal, full access is granted when the entered password is correct. */ void setUserPassword(const OdString& sUserPassword) { m_UserPassword = sUserPassword; } /** \details Retrieves the current user password for the output PDF document. \returns An OdString object that contains the current PDF document user password. \remarks *Password protection functionality is supported only for PDF versions 1.3 and higher.* There are two types of passwords: * User password (Document Open Password) is required to open a PDF document. * Owner password is required to gain full access to the document (owner access). Owner access gives permissions for changing passwords and access permissions for the document. When a password of at least one of these two types is specified, the PDF export module creates an encrypted output document. The type of encryption depends on the PDF version. The following rules apply for granting access to PDF document content depending on which passwords and access permissions were specified: * When only the user password is set, Adobe® Acrobat® Reader® requires this password to view the document. If the entered password is correct, full access to the document is granted. Access permissions are ignored. Other applications that read PDF documents take the access permissions into account. This means that if the entered user password is correct, the document is opened for viewing (read mode). Other operations can proceed only if the appropriate access permissions are granted. * When only the owner password is specified (the user password is not set), the PDF document can be opened for viewing without entering a password. Other operations are available only if the respective access permissions are granted, and the owner password is required to proceed with any of the allowed operations. * When the owner password is specified and it is not equal to the user password (the user password is also set), the PDF document can be opened for viewing by entering any of the passwords. If the user enters the owner password, full access to the document is granted. If the user enters the user password, other operations are allowed only if the respective access permissions are granted. To proceed with any of these operations, the owner password is required. * When both passwords are equal, full access is granted when the entered password is correct. */ OdString userPassword() const { return m_UserPassword; } /** \details Sets a new owner password for the output PDF document. \param sOwnerPassword [in] A string that contains a new value for the output document's owner password. \remarks *Password protection functionality is supported only for PDF versions 1.3 and higher.* There are two types of passwords: * User password (Document Open Password) is required to open a PDF document. * Owner password is required to gain full access to the document (owner access). Owner access gives permissions for changing passwords and access permissions for the document. When a password of at least one of these two types is specified, the PDF export module creates an encrypted output document. The type of encryption depends on the PDF version. The following rules apply for granting access to a PDF document content depending on which passwords and access permissions were specified: * When only the user password is set, Adobe® Acrobat® Reader® requires this password to view the document. If the entered password is correct, full access to the document is granted. Access permissions are ignored. Other applications that read PDF documents take the access permissions into account. THis means that if the entered user password is correct, the document is opened for viewing (read mode). Other operations can proceed only if the appropriate access permissions are granted. * When only the owner password is specified (the user password is not set), the PDF document can be opened for viewing without entering a password. Other operations are available only if the respective access permissions are granted, and the owner password is required to proceed with any of the allowed operations. * When the owner password is specified and it is not equal to the user password (the user password is also set), the PDF document can be opened for viewing by entering any of the passwords. If the user enters the owner password, full access to the document is granted. If the user enters the user password, other operations are allowed only if the respective access permissions are granted. To proceed with any of these operations, the owner password is required. * When both passwords are equal, full access is granted when the entered password is correct. */ void setOwnerPassword(const OdString& sOwnerPassword) { m_OwnerPassword = sOwnerPassword; } /** \details Retrieves the current owner password for the output PDF document. \returns An OdString object that contains the current PDF document owner password. \remarks *Password protection functionality is supported only for PDF version 1.3 and higher.* There are two types of passwords: * User password (Document Open Password) is required to open a PDF document. * Owner password is required to gain full access to the document (owner access). Owner access gives permissions for changing passwords and access permissions for the document. When a password of at least one of these two types is specified, the PDF export module creates an encrypted output document. The type of encryption depends on the PDF version. The following rules apply for granting access to PDF document content depending on which passwords and access permissions were specified: * When only the user password is set, Adobe® Acrobat® Reader® requires this password to view the document. If the entered password is correct, full access to the document is granted. Access permissions are ignored. Other applications that read PDF documents take the access permissions into account. This means that if the entered user password is correct, the document is opened for viewing (read mode). Other operations can proceed only if the appropriate access permissions are granted. * When only the owner password is specified (the user password is not set), the PDF document can be opened for viewing without entering a password. Other operations are available only if the respective access permissions are granted, and the owner password is required to proceed with any of the allowed operations. * When the owner password is specified and it is not equal to the user password (the user password is also set), the PDF document can be opened for viewing by entering any of the passwords. If the user enters the owner password, full access to the document is granted. If the user enters the user password, other operations are allowed only if the respective access permissions are granted. To proceed with any of these operations, the owner password is required. * When both passwords are equal, full access is granted when the entered password is correct. */ OdString ownerPassword() const { return m_OwnerPassword; } /** \details Sets new access permission flags for the output PDF document. \param flags [in] Value of the to be set. */ void setAccessPermissionFlags(const PDFAccessPermissionsFlags flags) { m_AccessPermissionFlags = flags; } /** \details Retrieves the current value of the . \returns A value of the data type that represents the current access permission flags. */ PDFAccessPermissionsFlags accessPermissionFlags() const { return m_AccessPermissionFlags; } /** \details Adds a new watermark. \param wm [in] A watermark object to be added. */ void addWatermark(const Watermark& wm) { m_Watermarks.append(wm); }; /** \details Retrieves the array of watermarks. \returns An array of Watermarks objects associated with the set of the export parameters. */ const OdArray& watermarks() const { return m_Watermarks; }; /** \details Clears the Watermarks array. */ void clearWatermarks() { m_Watermarks.clear(); }; protected: /** \details Creates a new set of export parameters with default values. */ PDFExportDocumentParams() : m_ver(OdPDF::kPDFAuto) , m_pdfAMode(kPDFA_None) , m_AccessPermissionFlags(kDefaultPermissions) { } OdPDF::PDFFormatVersions m_ver; // PDF format version. OdArray m_pageParams; // Page parameters: paper size, margins, in mm. // All next fields are optional (can be ""). If Producer is null, it will be "ODA PDF Export vX.X". OdString m_Title; // The document title. OdString m_Author; // The name of the person who created the document. OdString m_Subject; // The subject of the document. OdString m_Keywords; // Keywords associated with the document. OdString m_Creator; // If the document was converted to PDF from another format, the name of the application (for example, Adobe FrameMaker) that created the original document from which it was converted. OdString m_Producer; // If the document was converted to PDF from another format, the name of the application (for example, Acrobat Distiller) that converted it to PDF. //PDF/A is not compatible with PRC at all (by ISO standard) so the error will be returned if both modes are set //Optimized TTF fonts aren't supported yet, so this flag will be unset if PDF/A mode is chosen //For more details, see documentation PDF_A_mode m_pdfAMode; //PDF/A mode - default value None PDFAccessPermissionsFlags m_AccessPermissionFlags; //Access permissions flags for the PDF document OdString m_UserPassword; //User password for the PDF document OdString m_OwnerPassword; //Owner password for the PDF document OdArray m_Watermarks; //PDF watermarks (requires version 1.6) }; /** \details A class that implements storing and handling parameters for exporting to 2D PDF. */ class PDFExport2DParams : public virtual PDFExportBaseParams { public: /** \details PDF export flags enumeration that can be used for handling the export process. */ enum PDFExportFlags { /** All flags disabled.*/ kZeroFlag = 0, /** Enable embedding of True Type font program to PDF file. The whole True Type font file will be embedded (huge .pdf size).*/ kEmbededTTF = 1, /** Enable True Type font text to geometry conversion.*/ kTTFTextAsGeometry = 2, /** Enable SHX font text to geometry conversion.*/ kSHXTextAsGeometry = 4, /** Enable simple geometry optimization (separated segments to one polyline, Bezier curve control points).*/ kSimpleGeomOptimization = 8, /** If enabled, layer support will be added to .pdf file (1.5 version required).*/ kEnableLayers = 16, /** If enabled, invisible layers will be added to .pdf file (1.5 version required).*/ kIncludeOffLayers = 32, /** Enable embedding of True Type font program to .pdf file. The True Type font will be reduced by removing unused parts (smaller .pdf file size, but limited editing).*/ kEmbededOptimizedTTF = 64, /** Determines whether software uses vector hidden-line removal for corresponding viewports.*/ kUseHLR = 128, /** Enable compression of internal PDF streams.*/ kFlateCompression = 256, /** Enable ASCIIHex encoding of internal PDF streams.*/ kASCIIHexEncoding = 512, /** Enable hyperlinks export.*/ kExportHyperlinks = 1024, /** If enabled, layout geometry will be zoomed to paper size, else layout settings will be applied. Note: Z2E mode works like Layout settings: "Plot Area" - "Extents", "Fit to Paper", "Center the plot" applied to specified paper size and orientation, but some settings like "Plot lineweight", "Plot style" are still applying from Layout settings.*/ kZoomToExtentsMode = 2048, /** Create linearized .pdf file.*/ kLinearized = 4096, /** Enable merging the colors of crossing lines.*/ kMergeLines = 8192, /** Enable measuring scale in pdf.*/ kMeasuring = 16384, /** Default flag combination.*/ kDefault = kTTFTextAsGeometry | kSHXTextAsGeometry | kFlateCompression | kASCIIHexEncoding | kZoomToExtentsMode }; /** \details Hatch export types. */ enum ExportHatchesType { /** Exports hatch as a bitmap.*/ kBitmap = 0, /** Exports hatch as a set of triangles (vectorizer).*/ kDrawing = 1, /** Exports hatch as a PDF path (solid hatches only).*/ kPdfPaths = 2, /** Exports hatch as a polygon (solid hatches only).*/ kPolygons = 3 }; /** \details Searchable text types. */ enum SearchableTextType { /** No searchable text.*/ kNoSearch = 0, /** Only text displayed with SHX font is searchable.*/ kSHX = 1, /** Only text displayed with TTF font is searchable.*/ kTTF = 2 }; /** \details Export color policy. Determines how colors from an original drawing are exported to a PDF file. */ enum ColorPolicy { /** No color policy. A drawing is exported with its native color palette (as is).*/ kNoPolicy = 0, /** Drawing is exported to a monochrome PDF file.*/ kMono = 1, /** Drawing is exported to a grayscale PDF file. Native colors are converted to grayscale.*/ kGrayscale = 2 }; /** \details Shaded viewport export policy */ enum PDFShadedViewportExportMode { /** Shaded viewports are exported as a one-piece image with low resolution.*/ kExportOnePiece = 0, /** Shaded viewports are exported as tiled images according to the vector resolution (geometry DPI).*/ kExportAsTiles = 1, /** Shaded viewports are exported as striped images according to the vector resolution (geometry DPI). This mode has better performance for PDF viewers than tiled mode, but it can provide some issues on old graphics cards if hardware rendering is used (OpenGL ES2, for example).*/ kExportAsStrips = 2 }; /** \details Enumerates measuring types for a PDF document. */ enum PDFMeasuringType { /** Rectilinear coordinate system (by default).*/ kRL = 0, /** Geospatial coordinate system.*/ kGEO = 1 }; /** \details Creates a new set of export parameters with default values. */ PDFExport2DParams() : PDFExportBaseParams() { init(); } /** \details Destroys the set of export parameters. */ ~PDFExport2DParams() override {} /** \details Sets a new export flags value. \param flags [in] An instance of PDF export flags to be set. */ void setExportFlags(PDFExportFlags flags) { m_flags = flags; } /** \details Retrieves the current PDF export flags. \returns A value of the PDFExportFlags data type that represents the current value of PDF export flags. */ PDFExportFlags exportFlags() const { return m_flags; } /** \details Sets a new searchable text type value. \param type [in] A new value of text search type to be set. */ void setSearchableTextType(SearchableTextType type) { m_searchableTextType = type; } /** \details Retrieves the current value of the searchable text type. \returns A value of the SearchableTextType enumeration that represents the current value of the searchable text type. */ SearchableTextType searchableTextType() const { return m_searchableTextType; } /** \details Sets a new export color policy value. \param policy [in] color policy to be set. */ void setColorPolicy(ColorPolicy policy) { m_colorPolicy = policy; } /** \details Retrieves the color policy. \returns A value of the ColorPolicy enumeration that represents the current value of the color policy. */ ColorPolicy colorPolicy() const { return m_colorPolicy; } /** \details Sets a new value of the background color for the output PDF document. \param background [in] A new value for background color. \remarks Default background color is white. */ void setBackground(ODCOLORREF background) { m_background = background; } /** \details Retrieves the current value of the background color for the output PDF document. \returns An ODCOLORREF value that represents the background color for the output PDF document. \remarks Default background color is white. */ ODCOLORREF background() const { return m_background; } /** \details Sets a new palette to be used during the exporting. \param pPalette [in] A new palette to be set. \remarks If pPalette is equal to NULL, one of two default palettes will be used depending on background color value. */ void setPalette(const ODCOLORREF* pPalette) { m_pPalette = pPalette; } /** \details Retrieves the palette to be used during the exporting. \returns A raw pointer to an ODCOLORREF value that represents the used palette. \remarks If the returned pointer is equal to NULL, one of the two default palettes will be used depending on background color value. */ const ODCOLORREF* palette() const { return m_pPalette; } /** \details Sets a new value for vector resolution. \param dpi [in] A new value for vector resolution to be set (in dots per inch, dpi). \remarks Standard values are: 72, 150, 200, 300, 400, 600, 720, 1200, 2400 and 4800 DPI. Default value is 600 DPI. */ void setGeomDPI(OdUInt16 dpi) { if (dpi >= 72 && dpi <= 40000) m_VectorResolution = dpi; }; /** \details Retrieves the currently used vector resolution (in dots per inch, dpi). \returns An unsigned 16-bit integer value that contains the current resolution \remarks Standard values are: 72, 150, 200, 300, 400, 600, 720, 1200, 2400 and 4800 DPI. Default value is 600 DPI. */ OdUInt16 getGeomDPI() const { return m_VectorResolution; }; /** \details Sets a new value of the resolution for images created as a result of hatch export. \param dpi [in] A new value of the resolution to be set (in dots per inch, dpi). \remarks Hatch resolution value is used when the hatch entity is exported as a bitmap. */ void setHatchDPI(OdUInt16 dpi) { m_hatchDPI = dpi; } /** \details Retrieves the current value of the resolution for images created as a result of hatch export (in dots per inch, dpi). \returns An unsigned 16-bit integer value that contains the current resolution. \remarks Hatch resolution value is used when the hatch entity is exported as a bitmap. */ OdUInt16 hatchDPI() const { return m_hatchDPI; } /** \details Sets a new value of the resolution for color and grayscale images. \param dpi [in] A new value of the resolution to be set (in dots per inch, dpi). \remarks The resolution value cannot exceed the vector resolution value. */ void setColorImagesDPI(OdUInt16 dpi) { if (dpi >= 72 && dpi <= m_VectorResolution) m_colorImagesDPI = dpi; } /** \details Retrieves the current value of the resolution for color and grayscale images (in dots per inch, dpi). \returns An unsigned 16-bit integer value that contains the current resolution. \remarks The resolution value cannot exceed the vector resolution value. */ OdUInt16 colorImagesDPI() const { return m_colorImagesDPI; } /** \details Sets a new value of the resolution for monochrome images in the output PDF document. \param dpi [in] A new value of the resolution for monochrome images (in dots per inch, dpi). \remarks The resolution value cannot exceed the vector resolution value. */ void setBWImagesDPI(OdUInt16 dpi) { if (dpi >= 72 && dpi <= m_VectorResolution) m_bwImagesDPI = dpi; } /** \details Retrieves the current value of the resolution for monochrome images in the output PDF document (in dots per inch, dpi). \returns An unsigned 16-bit integer value that contains the current resolution. \remarks The resolution value cannot exceed the vector resolution value. */ OdUInt16 bwImagesDPI() const { return m_bwImagesDPI; } /** \details Sets the type of solid hatches export. \param type [in] A new value of the solid hatches export type. \remarks There are 3 types of exporting to PDF for solid hatches: * Bitmap (type = kBitmap); * Vectorizer (type = kDrawing); * PDF path (type = kPdfPaths); */ void setSolidHatchesExportType(ExportHatchesType type) { m_solidHatchesExportType = type; } /** \details Retrieves the current type of solid hatches export. \returns A value of the ExportHatchesType enumeration that represents the current type of solid hatches export. \remarks There are 3 types of exporting to PDF for solid hatches: * Bitmap (type = kBitmap); * Vectorizer (type = kDrawing); * PDF path (type = kPdfPaths); */ ExportHatchesType solidHatchesExportType() const { return m_solidHatchesExportType; } /** \details Sets the type of gradient hatches export. \param type [in] A new value of the gradient hatches export type. \remarks For gradient hatches, the following types of PDF export are available: * Bitmap (type = kBitmap); * Vectorizer (type = kDrawing); */ void setGradientHatchesExportType(ExportHatchesType type) { m_gradientHatchesExportType = type == kBitmap ? kBitmap : kDrawing; } /** \details Retrieves the type of gradient hatches export. \returns A value of the ExportHatchesType enumeration that represents the current type of gradient hatches export. \remarks For gradient hatches, the following types of PDF export are available: * Bitmap (type = kBitmap); * Vectorizer (type = kDrawing); */ ExportHatchesType gradientHatchesExportType() const { return m_gradientHatchesExportType; } //Deprecated, will be removed in one of the future releases void setOtherHatchesExportType(ExportHatchesType) { /*Do nothing*/ } //Deprecated, will be removed in one of the future releases ExportHatchesType otherHatchesExportType() const { return gradientHatchesExportType(); } /** \details Retrieves whether the image cropping option is enabled. \returns A Boolean value that is equal to true if the image cropping option is enabled; otherwise, the method returns false. */ bool imageCropping() const { return m_bCropImages; } /** \details Sets a new value of the image cropping option. \param bEnable [in] A new option value to be set. \remarks The option value is equal to true if the image cropping option is enabled; otherwise, the option value is equal to false. */ void setImageCropping(bool bEnable) { m_bCropImages = bEnable; } /** \details Retrieves the currently used quality of DCT compression. \returns An unsigned 16-bit integer value that represents the compression quality level. */ OdUInt16 dctQuality() const { return m_DCTQuality; } /** \details Sets a new value of the quality of DCT compression. \param quality [in] A quality value to be set. */ void setDCTQuality(OdUInt16 quality) { if (quality > 100) m_DCTQuality = 100; else if (quality < 10) m_DCTQuality = 10; else m_DCTQuality = quality; } /** \details Retrieves whether 1bpp images are exported as a transparency mask. \returns The true value if 1bpp images are exported as a transparency mask; otherwise, the method returns false. */ bool monoImagesAsMask() const { return m_bMonoImagesAsMask; } /** \details Sets a new value of the "MonoImagesAsMask" flag. The "MonoImagesAsMask" flag determines whether 1bpp images are exported as a transparency mask (equal to true) or not (equal to false). \param bAsMask [in] A new flag value. */ void setMonoImagesAsMask(bool bAsMask) { m_bMonoImagesAsMask = bAsMask; } /** \details Retrieves the current value of the "720DPI adaptive mode" flag. The "720DPI adaptive mode" flag determines whether the 720DPI adaptive mode is switched on (if equal to true) or off (equal to false). \returns The true value if 720DPI adaptive mode is enabled; otherwise, the method returns false. */ bool get720DPIMode() const { return m_b720DPImode; } /** \details Sets the new value of the "720DPI adaptive mode" flag. The "720DPI adaptive mode" flag determines whether the 720DPI adaptive mode is switched on (equal to true) or off (equal to false). \param bMode [in] A new flag value. */ void set720DPIMode(bool bMode) { m_b720DPImode = bMode; } /** \details Retrieves whether the extents calculation mode is enabled. \returns A Boolean value that is equal to true if the extents calculation mode is enabled; otherwise, the method returns false. */ bool useViewExtents() const { return m_useViewExtents; } /** \details Sets the extents calculation mode value. \param bViewExtents [in] A flag value that determines whether the extents calculation mode is switched on (if it is equal to true) or off (if it is equal to false). */ void setUseViewExtents(bool bViewExtents) { m_useViewExtents = bViewExtents; } /** \details Retrieves whether the DCT compression option is enabled. \returns A Boolean value that is equal to true if the DCT compression option is enabled; otherwise, the method returns false. */ bool dctCompression() const { return m_bDCTCompression; } /** \details Sets the DCT compression option. \param bEnable [in] An option value. If its value is equal to true, the DCT compression is enabled. */ void setDCTCompression(bool bEnable) { m_bDCTCompression = bEnable; } /** \details Retrieves whether the DCT compression option for shaded viewports is enabled. \returns A Boolean value that is equal to true if the DCT compression option for shaded viewports is enabled; otherwise, the method returns false. */ bool dctCompressionShadedViewports() const { return m_bDCTCompressionShadedVP; } /** \details Sets the DCT compression option for shaded viewports. \param bEnable [in] An option value. If its value is equal to true, the DCT compression for shaded viewports is enabled. */ void setDCTCompressionShadedViewports(bool bEnable) { m_bDCTCompressionShadedVP = bEnable; } /** \details Retrieves whether the upscaling option is enabled. \returns A Boolean value that is equal to true if the upscale option is enabled; otherwise, the method returns false. */ bool upscaleImages() const { return m_bUpscaleImages; } /** \details Sets the upscaling option. \param bEnable [in] An option value. If its value is equal to true, the upscaling is enabled. */ void setUpscaleImages(bool bEnable) { m_bUpscaleImages = bEnable; } /** \details Sets a new value of the shaded views transparency option. \param bEnable [in] A new option value to be set. \remarks The option determines whether backgrounds of shaded views exported with a GS device are transparent. The true value means transparency; the false value represents opaqueness. */ void setTransparentShadedVpBg(bool bEnable) { m_TransparentShadedVpBg = bEnable; }; /** \details Retrieves the transparency for shaded views option value. \returns A Boolean value that is equal to true if transparency for shaded views is enabled; otherwise, the method returns false. \remarks The option determines whether backgrounds of shaded views exported with a GS device are transparent. The true value means transparency; the false value represents opaqueness. */ bool transparentShadedVpBg() const { return m_TransparentShadedVpBg; }; /** \details Sets a new value of the disable GS device for shaded views option. \param bDisable [in] A new option value to be set. \remarks If the option value is equal to true the GS device is disabled; otherwise (by default) the GS device is enabled. If GS device is disabled, shaded viewports will be exported as geometry, using pdf device, otherwise they will be exported as bitmap pictures */ void setForceDisableGsDevice(bool bDisable) { m_ForceDisableGsDevice = bDisable; }; /** \details Retrieves the current value of the disable gs device for shaded views option. \returns A Boolean value that is equal to true if the disable gs device for shaded views option is set; otherwise, the method returns false. */ bool forceDisableGsDevice() const { return m_ForceDisableGsDevice; }; /** \details Sets a new value of the shaded viewports export mode. \param mode [in] A new option value to be set. */ void setShadedVpExportMode(PDFShadedViewportExportMode mode) { m_ShadedVpExportMode = mode; }; /** \details Retrieves the current value of the shaded viewports export mode. \returns A PDFShadedViewportExportMode enumeration value that represents the current value of the shaded viewports export mode. */ PDFShadedViewportExportMode shadedVpExportMode() const { return m_ShadedVpExportMode; }; /** \details Retrieves whether XObjects are exported. \returns A Boolean value that is equal to true if XObjects are exported; otherwise, the method returns false. \remarks This method is used for internal use only. It is strictly recommended do NOT use it in your custom source code. */ bool export2XObject() const { return m_Export2XObject; } /** \details Retrieves the current value of the GsCache usage flag. The GsCache usage flag determines whether the GsCache is used during the export process (if it is equal to true) or not (if it is equal to false). \returns A Boolean value that is equal to true if GsCache is enabled; otherwise, the method returns false. */ bool useGsCache() const { return m_useGsCache; } /** \details Sets the GsCache usage flag. The GsCache usage flag determines whether the GsCache is used during the export process (if it is equal to true) or not (if it is equal to false). \param bEnable [in] A new flag value to be set. */ void setUseGsCache(bool bEnable) { m_useGsCache = bEnable; } /** \details Retrieves the current value of the parallel vectorization flag. The parallel vectorization flag determines whether multi-threaded vectorization is used during the export process. If the flag is equal to true, multi-threaded vectorization is enabled; otherwise, the flag is equal to false. \returns A Boolean value that is equal to true if multi-threaded vectorization is enabled, or false otherwise. */ bool isParallelVectorization() const { return m_bParallelVectorization; } /** \details Sets the parallel vectorization flag value. The parallel vectorization flag determines whether multi-threaded vectorization is used during the export process. If the flag is equal to true, multi-threaded vectorization is enabled; otherwise, the flag is equal to false. \param bOn [in] A new value of the multi-threaded vectorization flag to be set. */ void setParallelVectorization(bool bOn) { m_bParallelVectorization = bOn; } /** \details Sets the usage of PDF blocks. \param bOn [in] A value of the PDF blocks usage flag. \remarks If the PDF blocks usage flag value equals true, the use of PDF blocks during the export process is enabled; when the flag value equals false, PDF blocks are not used. */ void setUsePdfBlocks(bool bOn) { m_bPdfBlocks = bOn; } /** \details Retrieves the current value of the PDF blocks usage option. \returns A Boolean value that is equal to true if using PDF blocks is enabled; otherwise, the method returns false. */ bool isUsePdfBlocks() const { return m_bPdfBlocks; } /** \details Sets the flag that handles the exporting of external references as PDF blocks. When the value equals true, external references are exported as PDF blocks. \param bOn [in] A new value of the flag to be set. */ void setXrefsAsPdfBlocks(bool bOn) { m_bXRefBlocks = bOn; } /** \details Retrieves the current value of the "Xrefs as PDF blocks" usage option. This option defines whether external references are exported as PDF blocks (when equal to true). \returns A Boolean value that is equal to true if external references are exported as PDF blocks, or false otherwise. */ bool isXrefsAsPdfBlocks() const { return m_bXRefBlocks; } /** \details Determines whether searchable text is exported as invisible text. \returns A Boolean value that is equal to true if searchable text is exported as invisible text; otherwise, the method returns false. */ bool searchableTextAsHiddenText() const { return m_bSearchableTextAsHiddenText; } /** \details Determines whether searchable text is exported from rendered views. \returns A Boolean value that is equal to true if searchable text is exported from rendered views; otherwise, the method returns false. */ bool searchableTextInRenderedViews() const { return m_bSearchableTextInRenderedViews; } /** \details Sets a new value of the invisible text flag. The invisible text flag defines whether the searchable text is exported as invisible text (if equals to true). \param bOn [in] A new flag value to be set. */ void setSearchableTextAsHiddenText(bool bOn) { m_bSearchableTextAsHiddenText = bOn; } /** \details Sets a new value of the export from rendered views flag. The export from rendered views flag defines whether the searchable text is exported from rendered views (if equals to true) or not (if equals to false). \param bOn [in] A new flag value to be set. */ void setSearchableTextInRenderedViews(bool bOn) { m_bSearchableTextInRenderedViews = bOn; } /** \details Determines whether TrueType fonts are exported as geometry. \returns A Boolean value that is equal to true if TrueType fonts are exported as geometry; otherwise, the method returns false. */ bool isTTFTextAsGeometry() const { return GETBIT(exportFlags(), PDFExport2DParams::kTTFTextAsGeometry); } /** \details Determines whether SHX fonts are exported as geometry. \returns A Boolean value that is equal to true if SHX fonts are exported as geometry; otherwise, the method returns false. */ bool isSHXTextAsGeometry() const { return GETBIT(exportFlags(), PDFExport2DParams::kSHXTextAsGeometry); } /** \details Sets a new value of the bookmark creation flag. \param bEnable [in] A new flag value to be set. \remarks The flag value equals true if the support of bookmark creation is enabled; otherwise, the flag value equals to false. */ void enableBookmarks(bool bEnable) { m_bBookmarks = bEnable; } /** \details Retrieves whether the bookmark creation is enabled. \returns The true value if the bookmark creation is enabled; otherwise, the method returns false. */ bool bookmarksEnabled() const { return m_bBookmarks; } /** \details Retrieves the array of layout names to use as bookmarks/thumbnails names. \returns An array of OdString objects that contain layout names. */ OdStringArray& layoutNames() { return m_LayoutNames; } /** \details Sets the array of layout names to use as bookmarks/thumbnails names. \param layoutNames [in] A new array of layout names to be set. \remarks * The array size must be equal to the size of exported layouts. * If the array of exported layouts is not set (it assumes that only an active layout is exported), the array of layout names must contain only one element. */ void setLayoutNames(const OdStringArray& layoutNames) { m_LayoutNames = layoutNames; } /** \details Sets a new measuring type for the output PDF document. \param type [in] A value of the to be set. \remarks The rectilinear coordinate system is used as a measuring type by default. */ void setMeasuringType(const PDFMeasuringType type) { m_MeasuringType = type; } /** \details Retrieves the current value of the . \returns A value of the data type that represents the current measuring type. \remarks The rectilinear coordinate system is used as a measuring type by default. */ PDFMeasuringType measuringType() const { return m_MeasuringType; } protected: /** \details Creates a new set of export parameters with default values. */ PDFExport2DParams(const PDFExport2DParams& other) { m_background = other.m_background; m_pPalette = other.m_pPalette; m_hatchDPI = other.m_hatchDPI; m_VectorResolution = other.m_VectorResolution; m_colorImagesDPI = other.m_colorImagesDPI; m_bwImagesDPI = other.m_bwImagesDPI; m_solidHatchesExportType = other.m_solidHatchesExportType; m_gradientHatchesExportType = other.m_gradientHatchesExportType; m_flags = other.m_flags; m_searchableTextType = other.m_searchableTextType; m_colorPolicy = other.m_colorPolicy; m_bCropImages = other.m_bCropImages; m_bDCTCompression = other.m_bDCTCompression; m_bDCTCompressionShadedVP = other.m_bDCTCompressionShadedVP; m_DCTQuality = other.m_DCTQuality; m_bUpscaleImages = other.m_bUpscaleImages; m_bMonoImagesAsMask = other.m_bMonoImagesAsMask; m_b720DPImode = other.m_b720DPImode; m_useViewExtents = other.m_useViewExtents; m_Export2XObject = other.m_Export2XObject; m_ForceDisableGsDevice = other.m_ForceDisableGsDevice; m_TransparentShadedVpBg = other.m_TransparentShadedVpBg; m_ShadedVpExportMode = other.m_ShadedVpExportMode; m_useGsCache = other.m_useGsCache; m_bParallelVectorization = other.m_bParallelVectorization; m_bPdfBlocks = other.m_bPdfBlocks; m_bXRefBlocks = other.m_bXRefBlocks; m_bSearchableTextAsHiddenText = other.m_bSearchableTextAsHiddenText; m_bSearchableTextInRenderedViews = other.m_bSearchableTextInRenderedViews; m_bBookmarks = other.m_bBookmarks; m_LayoutNames = other.m_LayoutNames; m_MeasuringType = other.m_MeasuringType; m_reserved1 = other.m_reserved1; } ODCOLORREF m_background; // Background color. Default: white. const ODCOLORREF* m_pPalette; // Palette to be used. If NULL, one of two default palettes will be used depending on background color. OdUInt16 m_hatchDPI; // PdfExport exports hatch entity as bitmap. This value controls DPI resolution for images created during hatch export. //OdUInt16 view3dDPI; // 3d viewports exported as images if bUseHLR set to true. This value controls DPI of such inages. OdUInt16 m_VectorResolution; // Used for vector resolution. Standard values are 72, 150, 200, 300, 400, 600, 720, 1200, 2400 and 4800 DPI. Default value is 600 DPI OdUInt16 m_colorImagesDPI;//Used for control resolution for color and grayscale images. Cannot exceed m_VectorResolution value OdUInt16 m_bwImagesDPI;//Used for control resolution for monochrome images. Cannot exceed m_VectorResolution value ExportHatchesType m_solidHatchesExportType; ExportHatchesType m_gradientHatchesExportType; PDFExportFlags m_flags; // PDF export flag combination used for export. SearchableTextType m_searchableTextType;//can be used if SHX or TTF text exported as geometry ColorPolicy m_colorPolicy; bool m_bCropImages; // Enable bitmap cropping(crop invisible parts of bitmaps) bool m_bDCTCompression; // DCT compression for raster images bool m_bDCTCompressionShadedVP; // DCT compression for shaded viewports. To use DCT compression for shaded viewports DCT compression for raster images should also be set OdUInt16 m_DCTQuality; // Quality of DCT compression bool m_bUpscaleImages; // Upscale images if they resolution is lower than settled image resolution. Default: false //The parameters below have been added to provide possibility to avoid a couple of Adobe Acrobat issues bool m_bMonoImagesAsMask; /*1bpp images with transparent background can be exported as image + transparency mask (false) or as transparency mask itself (true). Adobe Acrobat Reader displays black/white images with masks different from images-masks. Default value: false*/ bool m_b720DPImode; /*If this flag is set, the drawing will be exported with resolution about 720DPI, but without using scaling matrix. Adobe Acrobat Reader displays the lineweights of geometry in pdf files without scaling matrices, brighter than in ones with such matrices, even if scaled lineweight is equal to unscaled one. Default value - false*/ ////////////////////////////////////////////////////////////////////////// bool m_useViewExtents; // Use view extents instead of plot extents (default) for calculation of drawing extents bool m_Export2XObject; bool m_ForceDisableGsDevice; //Force disable Gs device to export shaded views. Default value - false bool m_TransparentShadedVpBg; //Make background of shaded views, exported with Gs device, transparent. Default value - false PDFShadedViewportExportMode m_ShadedVpExportMode; //Shaded viewport export policy bool m_useGsCache; //Use GsCache for pdf export. Default value - false bool m_bParallelVectorization; //Do MT vectorization when Gs cache is enabled. Default value - false bool m_bPdfBlocks; //Export drawing blocks as pdf blocks when Gs cache is enabled. Default value - false bool m_bXRefBlocks; //Export Xrefs as pdf blocks when Gs cache is enabled. Default value - false bool m_bSearchableTextAsHiddenText; //When text is exported as geometry, and searchable text is required, export it as hidden text available for Ctrl+F search. Default value - false bool m_bSearchableTextInRenderedViews; //Text in render views exported as a hidden one behind a bitmap, available for Ctrl+F search. Default value - false bool m_bBookmarks; //Layouts and named views as bookmarks OdStringArray m_LayoutNames; // Layout names to use as bookmarks/thumbnails names. PDFMeasuringType m_MeasuringType; //Measuring type flag. Rectilinear by default virtual void init() { m_background = ODRGB(255, 255, 255); m_pPalette = 0; m_flags = kDefault; m_hatchDPI = 72; m_solidHatchesExportType = kBitmap; m_gradientHatchesExportType = kBitmap; m_VectorResolution = 600; m_colorImagesDPI = 400; m_bwImagesDPI = 400; m_searchableTextType = kNoSearch; m_colorPolicy = kNoPolicy; m_bCropImages = true; m_bDCTCompression = false; m_bDCTCompressionShadedVP = false; m_DCTQuality = 50; m_useViewExtents = false; m_reserved1 = 0; m_Export2XObject = true; m_ForceDisableGsDevice = false; m_TransparentShadedVpBg = false; m_ShadedVpExportMode = kExportOnePiece; m_bUpscaleImages = false; m_useGsCache = false; m_bParallelVectorization = false; m_bSearchableTextAsHiddenText = false; m_bSearchableTextInRenderedViews = false; m_bPdfBlocks = false; m_bXRefBlocks = false; m_bBookmarks = false; m_MeasuringType = kRL; m_bMonoImagesAsMask = false; m_b720DPImode = false; } public: /** Reserved parameter: bit 1 - ZoomToExtents auxiliary flag - default value 0 [ExactExtents]. For internal use only. It is strongly NOT recommended to use it in your code!*/ OdUInt16 m_reserved1; }; /** \details A class that implements storing and handling the full set of PDF export parameters. */ class PDFExportParams : public PDFExportDocumentParams, public PDFExport2DParams, public PDFExport3DParams { public: /** \details Creates a new set of export parameters with default values. */ PDFExportParams() { init(); } /** \details Destroys the set of export parameters. */ ~PDFExportParams() override {} /** \details Sets a new output stream object for writing the output PDF file. \param output [in] A reference to a smart pointer to an OdStreamBuff object that represents the stream to be used for writing data into the PDF file. */ void setOutput(const OdStreamBufPtr& output) { m_outputStream = output; } /** \details Retrieves the output stream that is used for writing the output PDF file. \returns A smart pointer to an OdStreamBuf object that represents the stream for writing the output PDF file. */ OdStreamBufPtr output() const { return m_outputStream; } /** \details Retrieves the current export reactor. \returns A raw pointer to the object. \remarks This method is used for internal use only. It is strictly recommended do NOT use it in your custom source code. */ PdfExportReactor* exportReactor() const { return m_exportReactor; } /** \details Sets a new object. \param reactor [in] A raw pointer to the reactor object. \remarks This method is used for internal use only. It is strictly recommended do NOT use it in your custom source code. */ void setExportReactor(PdfExportReactor* reactor) { m_exportReactor = reactor; } /** \details Sets a new value of the "export to PRC" flag. This flag determines whether exporting to the PRC format is supported (value is equal to true) or not (value is equal to false). \param flags [in] A new flag value to be set. */ void setPRCMode(PRCSupport flags) override { if (kDisabled != flags) { m_flags = (PDFExportFlags)(m_flags & ~kUseHLR); } PRCExportParams::setPRCMode(flags); } /** \details Sets a new value of the error handling flag. The error handling flag determines whether the PDF export stops if an error occurs while exporting any of the layouts from the origin database and cancels all the work that was previously done (value is equal to true). If the flag value is equal to false, the erroneous layout is skipped, and the export process continues with the next layout if it exists. \param bFlag [in] A new value of the error handling flag. \sa * Exporting to a PDF File * Export Several Drawings to One PDF File */ void setStopOnError(bool bFlag) { m_bStopOnError = bFlag; } /** \details Retrieves the current value of the error handling flag. The error handling flag determines whether the PDF export stops if an error occurs while exporting any of the layouts from the origin database and cancels all the work that was previously done (the value is equal to true). If the flag value is equal to false, the erroneous layout is skipped, and the export process continues with the next layout if it exists. \returns A Boolean value that contains the current value of the flag. \sa * Exporting to a PDF File * Export Several Drawings to One PDF File */ bool stopOnError() const { return m_bStopOnError; } private: friend class PdfExporter; PDFExportParams(const PRCExportParams& prc_export_params) : PDFExportBaseParams(prc_export_params) , PDFExport3DParams(prc_export_params) { init(); } PDFExportParams(const PDFExport2DParams& export_2D_params) : PDFExportBaseParams(export_2D_params) , PDFExport2DParams(export_2D_params) , m_bStopOnError(true) , m_exportReactor(nullptr) { } void init() override { m_exportReactor = nullptr; m_Export2XObject = false; m_bStopOnError = true; } OdStreamBufPtr m_outputStream; // Pointer to the stream buffer for PDF export implementation. bool m_bStopOnError; // Error handling for multipages export, if false - try to proceed in case of error, true - stop export. Default value - true. PdfExportReactor* m_exportReactor; //Reactor to handle pdf export actions on caller level. }; } #endif //_PDFEXPORTPARAMS_INCLUDED_