PDF and PRC Questions

  1. FAQ

How to create a point cloud in PRC?

There is a "OdPrcPointSet" class. Example code can be found here : Prc\Examples\OdPrcCreate\RepresentationItemExample.cpp see OdPrcRepresentationItemPtr CreatePointSet(OdPrcFileStructure &newStructure).

Also you can start OdaPrcApp.exe; and few steps:

  • File/New
  • Tool/Load Applications
  • load OdPrcExCommands.tx
  • Edit/Registered Commands/Prc create example/RepresentationItemPointSet
  • Vectorize it

Is there a maximum of OdPrcPointSetPtr that can be created in the PRC to export it to 3D PDF?

The number of points in each OdPrcPointSet object is limited to UINT_MAX. The number of OdPrcPointSet objects is limited only by the size of the address space.

Opening files with huge number of objects can be very slow. It will depend on your hardware.

While exporting a drawing from dwg to pdf having white hatched polylines, the hatch color will be inverted to black color. Is there any way to generate pdf without this color inversion?

Yes, you can set background color, for example

Code:


PDFExportParams params;
params.setBackground(ODRGB(127, 127, 127));

The result will be gray background.pdf.

I am trying to download PdfModuleVI (VI-PDF …) module, but receive message, that I have insufficient permissions to access this page or file.

VI PDF support has been discontinued.

There is another pdf module, coming for free, which is part of Kernel archives (TD_Pdfium.dll). You can read about versions in which it appears here.

Can we receive text search enabled .pdf using Publish SDK?

ODA SDK can provide pdf with texts as pdf fonts and even if you export texts as geometry primitives, there is the option to make them searchable using pdf annotations.

I am using the OdPdfExportEx.exe to export dwg to pdf. Is layer extraction supported for 3D dwg files (especially in shaded mode)?

If you want to export a drawing (not the export using PRC), export in shaded mode produces just picture and layers are disabled, which lies in pdf file.
There is no way to provide layers support if we export drawing as picture.

Is it possible to edit existing .pdf file with Publish SDK?

Publish SDK have no possibility to edit existing pdf files. You can only create new pdf using it.

I am converting DWG file with the OdPdfExportEx sample. The resulting PDF is different in terms of coloring, color shades and missing some structures in the Layouts and as for the Model page, it is not rendering any of the structures inside.

That's because of you export the Model space in ZoomToExtents mode (even if you don't, there is the "Extents" plot area in PlotSettings. To change this, you should set the correct plot settings, like plot area - "Display", and do not use ZoomToExtents flag in pdf export flags.

You can check the drawing in the OdaMfcApp - we export the drawing as we render it. When we render it in OdaMfcApp we don't see the bricks on the walls, wood on the floor and other details. The pdf export in case of "shaded" visual style (or "realistic") is going via the rendering into picture, so the issue looks more like rendering issue and pdf export itself has no deal with it.

Is there way to change the "paper" size or make it automatically adapt the size to the geometry in the block table record?

Right now the size (and mostly also the position) does not represent the exported geometry.

You can calculate the extents of the entities on the Model Space and try to set the paper size for the Paper Space according to them. But the paper sizes set can also contain no paper to represent your geometry correctly.

Or you can set the following plot settings:

OdDbPlotSettings *pPlotSettings = pLayout.get();
OdDbPlotSettingsValidatorPtr pValidator = pPlotSettings->database()->appServices()->plotSettingsValidator();
 
pValidator->setStdScaleType(pPlotSettings, OdDbPlotSettings::kScaleToFit);
pValidator->setPlotType(pPlotSettings, OdDbPlotSettings::kExtents);
//and optional
pValidator->setPlotCentered(pPlotSettings, true);

so your geometry will be scaled to fit the chosen paper size.

to change paper size you can use:

pPlotValidator->setCanonicalMediaName(pPlotSettings, OD_T("ISO_A1_(841.00_x_594.00_MM)"));

"ISO_A1_(841.00_x_594.00_MM)" - it is one of the many possible sizes.

Is it possible to set the annotation scale to an OdPrcMarkupTessBufText object?

In prc you can manage OdPrcMarkupTessBufText positioning only by:

Face View Mode, OdPrcMarkupTessBufFaceView
In this mode, all the drawing entities are parallel to the screen (billboard). The point given in the doubles corresponds to the origin of the new coordinate system in which entries are drawn parallel to the screen.

Frame Draw Mode, OdPrcMarkupTessBufFrame
In this mode, all the drawing entities are given in 2‐dimensional space. The point given in the doubles corresponds to a 3D point projected onto the screen, providing the origin of the 2‐dimensional coordinate system in which to draw (viewport).

Fixed Size Mode, OdPrcMarkupTessBufFixedSize
In this mode, all the drawing entities are drawn at a fixed size, independent of zoom. The point given in the doubles corresponds to the origin of the new coordinate system in which to draw at fixed size. (Adobe has porblems with supporting this mode).

Matrix Mode, OdPrcMarkupTessBufMatrix
In this mode, all the drawing entities are transformed by the matrix given in the doubles post multiplied by the current transformation matrix. At the end of the mode, the transformation matrix that was previously active is restored.

To apply one of this modes for OdPrcMarkupTessBufText object put it inside BufBlock by setNextInBlock() function, e.g: Code:
OdPrcMarkupTessPtr CreatePlainTextMarkup (OdPrcFileStructure &pCurFS)
{
//...
  pCurMkpTess = pCurMkpTess->setNext(OdPrcMarkupTessBufMatrix::createObject());
  OdGePoint3d origP(3, 3, 0);
  ((OdPrcMarkupTessBufMatrixPtr &) pCurMkpTess)->setMatrix(OdGeMatrix3d::translation(origP.asVector()));
  OdPrcMarkupTessBufTextPtr pBufText = OdPrcMarkupTessBufText::createObject();
  ODA_VERIFY(pBufText->setText(L"Markup with Text type", 20, 4) == eOk);
  ((OdPrcMarkupTessBufMatrixPtr &) pCurMkpTess)->setNextInBlock(pBufText);
//...
}

Is it possible to programmatically change the transparency/translucency (opacity) of a BREP and/or a MESH when publishing 3D PDF from PRC?

Yes, you can use the function. Code:

OdPrcCategory1LineStyle::setTransparency (OdInt8 transparency);

for the LineStyle of the corresponding object.

How to set colour to individual points in a OdPrcPointSet object?

It's not possible. In PRC, you need to create separate PointSet objects for this purpose. But you can join them into one PartDefinition:


 ...
    OdPrcPartDefinitionPtr newDefinition = OdPrcPartDefinition::createObject();
    pPrc_FileStructure->addObject(newDefinition);
    ...
   for (int k = 0; k styleId() = OdPrcCategory1LineStyle::createByColor(getR(k), getG(k), getB(k), *pPrc_FileStructure);
     OdPrcName name;
     name.setName(<point name>);
     pPointSet->name() = name;
     pPointSet->setBehaviourBitField(PRC_GRAPHICS_Show);
     pPrc_FileStructure->addObject(pPointSet);

     pPointSet->point().push_back(OdGePoint3d(X(k), Y(k), Z(k)));
    
     newDefinition->representationItem().push_back(pPointSet->objectId());
  }

  newDefinition->setBehaviourBitField(PRC_GRAPHICS_Show); 
  pPrc_FileStructure->fileStructureTree().partDefinition().push_back(newDefinition->objectId());
  ...

How to extract raster image data when using the new PDF Importer (PDFium)?

OdDbRasterImageDef::sourceFileName() returns path to raster file.

Is it possible to export a dwg drawing to pdf in its current zoomed state other than extents view?

This is default behavior. See viewExtents() / setViewExtents() in PdfExportParams.h

When I try to export a .dwg drawing to a .pdf file and the .dwg file has a layer name without a closed bracket and with "enable layer support” ON, the .pdf is empty.

The .pdf file is actually not empty, but Adobe® software is unable to open it. If you remove '( ' from the layer name in the .pdf file, Adobe software will be able to load it.

Does PdfModule allow converting a .pdf file into a .dwg file?

No, but you can use free Pdfium module. More information is available here.

 

Is it possible to define a cross section in a .prc file?

You can use the OdPrcFromCurvesSurface class, which implements the PRC_TYPE_SURF_FromCurves type of .prc format and then do the following:

eval_point = first_curve.evaluate(param.u) + second_curve.evaluate(param.v) – origin;

Another way is to use a NURB surface (if you have code to convert a cross section surface to a NURB surface).

Please see the OdPrcCreate example application (Prc/Examples/OdPrcCreate):

  • To get sample code for creating an object of the OdPrcFromFromCuresSurface class (example case is "BrepModelFromCurves").
  • To get sample code for creating an object of the OdPrcNurbsSurface class (example case is "BrepModelNURBS").

Is it possible to create a multi-page .pdf file with the prcToPdf() method?

No, the prcToPdf() method does not support multi-paging. You need to use a toolkit for working with .pdf files that supports this feature. The prcToPdf() method cannot be used as a .pdf file creator; it’s purpose is to insert .prc content to a .pdf file and render it. Actually, Teigha does not contain functionality similar to a .pdf file editor.

How can I set the default background color when exporting to a .pdf file with .prc support?

Currently the ability to set a background color isn't provided; you can do it only at the .pdf file level. For example, if you have the following data in a .pdf file:

<<
/Type /Annot
/Subtype /3D
/Rect [0 123 594 718]
/P 2 0 R
/F 68
/Contents 9 0 R
/3DA <<
/Transparent true
/A /PO
/D /XD
>>
/3DV <<
/Type /3DView
/XN (Default View)
/MS /M
/CO 3.334073
/C2W [1.000000 0.000000 0.000000 0.000000 1.000000 0.000000 0.000000 0.000000 -1.000000 7.712374 5.931818 3.334073 ]
/P <<
/Subtype /O
/OB /Max
/OS 0.519500
>>
>>

To change the default background color:

  1. Change the key /Transparent true to /Transparent false.
  2. Set the new value for the background color between /CO and /C2W keys:
  3. 
    /BG <<
    	  /C [
    	    0.0
    	    0.0
    	    1.0
    	  ]
    	  /Subtype /SC
    >>

How can I retrieve the .pdf file name from an OdDbPdfReference object?

Use the following code fragment as a sample:

OdDbObjectId idDefinition = pPdfRef->definitionId();
OdDbPdfDefinitionPtr pDef = idDefinition.openObject();
OdString strActiveFileName = pDef->activeFileName();
OdString strSourceFileName = pDef->sourceFileName();

This sample fragment assumes that the variable pPdfRef is a smart pointer to an instance of the OdDbPdfReference class, which has been correctly created and added to the drawing database.

I have exported a .dwg file into a .pdf file with the zoom to extents flag switched off, but the drawing is not shown. Why?

When the Zoom to Extents flag is equal to false, output page parameters are taken from the layout's properties and a custom application cannot change them.

Please see the Page Setup dialog from the OdaMfcApp sample application. To open the Page Setup dialog, use File -> Page Setup from the main menu.

Does Publish SDK support the .pdf/a format for export?

Yes, PDF export functionality supports creating archive .pdf documents (PDF/A). To specify a version of PDF/A format, use the PDF_A_mode enumeration from PDFExportParams class.

Currently Publish SDK supports the following versions of PDF/A format:

  • PDF/A-1b
  • PDF/A-2b

Transparency does not work for export to a .pdf file.

Transparency works correctly, but it should be enabled using plot settings when you need to export it into a .pdf file:

OdDbLayoutPtr pLayout = OdDbBlockTableRecordPtr(pDb->getActiveLayoutBTRId().safeOpenObject())->getLayoutId().safeOpenObject(OdDb::kForWrite);
pLayout->setPlotTransparency(true);
exportToPdf(pDb);

Please also remember that since version 4.2, the PDFExportParams class does not contain the kSupportTransparency flag any more.

Is it possible to export more than one .dwg file into one .pdf file (append drawings one by one into the same .pdf file)?

Currently, no. As an idea to do this, merge several drawing databases into one database and export the merged database. Another idea is to export each drawing database into a separate .pdf file, then collect the output .pdf files into one file using free .pdf software.

What kinds of drawing entities can be exported to a .pdf file with .prc format support?

All drawing entities can be exported in the regular way.

How can I generate a .pdf file from a .prc database?

Please use the following code fragment as a sample:

{
  // open .prc for read and write access
  OdStreamBufPtr pPrcStream = odrxSystemServices()->createFile("\\input.prc", Oda::kFileRead, Oda::kShareDenyNo, Oda::kOpenExisting);

  // load special module
  OdPrcToPdfModulePtr pModule = ::odrxDynamicLinker()->loadModule(OdPrcToPdfModuleName, false);

  // create new .pdf file
  OdStreamBufPtr pPdf = odrxSystemServices()->createFile("\\output.pdf", Oda::kFileWrite, Oda::kShareDenyNo, Oda::kCreateAlways);

  // insert .prc to .pdf with some default paper and 3D View parameters.
  OdResult res = pModule->prcToPdf(pPrcStream, pPdf);
  ODA_ASSERT(res == eOk);
}

You can use a more complicated version of the prcToPdf() method:

virtual OdResult prcToPdf(OdStreamBufPtr pPrcStream, OdStreamBufPtr pPdfStream, const OdGsPageParams &pdfParams, const OdGeMatrix3d &C2W, double CO, double OS);

For additional information about C2W, CO and OS parameters, please see the Adobe® Portable Document Format specification.

How can I edit content or select objects in a .pdf file?

ODA does not provide functionality for editing a .pdf file or for selecting objects in it. Please use third-party applications for these purposes.

How can I create a .pdf file with animation in Publish SDK?

Animation is a part of the .pdf format, but not the .prc format. Publish SDK does not provide an API for editing a .pdf file.

Can I compress a .pdf file using the prcToPdf() method?

A .pdf file created by the prcToPdf() method contains content that is already compressed.