Using PDFNet to generate 3D PDF files

Q: I would like to know whether the PDFNet SDK able to convert or
create any U3D file or not? I have a 3D model that contain a lot of
Polymesh and I would like to save the 3D model into 3D PDF format, so
that other people can view the 3D model directly from that PDF file.
Thanks!
-----------------

A: PDFNet SDK comes with a number of sample projects (http://
www.pdftron.com/pdfnet/samplecode.html).
In case you would like to embed 3D data (U3D) to PDF the best starting
point is U3D sample:
   http://www.pdftron.com/pdfnet/samplecode.html#U3D

Even though the sample looks fairly simple, all 'advanced' samples can
be boiled down to the same sequence of steps (i.e. embedding a U3D
file and setting-up the 3D annotation on a page).

In case you also need to generate U3D file from scratch you could use
Intel’s U3D library (http://sourceforge.net/projects/u3d/). There are
multiple ways to generate U3D with Intel’s U3D library. As a starting
point you may want to take a look at IDTFConverter.exe tool. This tool
converts simple to understand IDTF text files (e.g.
http://www.pdftron.com/pub/U3D/line_vertexcolor.idtf) to U3D (http://
www.pdftron.com/pub/U3D/line_vertexcolor.u3d) using the
IDTFConverterutility.

IDTF files can be programmatically parsed/generated using IDTFGen/
U3DInclude headers in U3D lib. Actually you don’t need to generate
IDTF files at all – you can simply generate objects and serialize them
to U3D. This approach is illustrated U3DExporter tool for VTK (e.g.
http://www.pdftron.com/pub/U3D/vtkU3DExporter.zip).

Q: Can I also use PDFNet to extract U3D models from PDF?


A: The U3D sample (http://www.pdftron.com/net/samplecode.html#U3D)
shows how to embed U3D model in PDF. You can embed any type of U3D
file (FEM simulation result, shade contour plot, vector plot, etc) -
as part of SDK we include very simple U3D sample, but you can replace
it with models of any type of content or complexity.

To extract U3D data you would read 3DD data stream from 3D annotation
dictionary. For an example of how to traverse all annotation in a PDF
document please take a look at Annotation sample project (http://
www.pdftron.com/net/samplecode.html#Annotation). For example:

// C# pseudocode
Page page = …
int num_annots = page.GetNumAnnots();
for (int i=0; i<num_annots; ++i) {
Annot annot = page.GetAnnot(i);
if (annot.IsValid() && annot.GetType() == Annot.Type.e_3D) {
// Rect bbox = annot.GetRect();
Obj 3dd_stm = annot.GetSDFObj().FindObj(“3DD”);
if (3dd_stm != null) {
FilterReader reader = new FilterReader(3dd_stm);
StdFile out_file = new StdFile(“my.u3d”,
StdFile.OpenMode.e_write_mode);
FilterWriter writer = new FilteWriter(out_file);
writer.WriteFilter(reader);
writer.Flush();
out_file.Close();
}
}
}
}

// C++ pseudocode
Page page = …
int num_annots = page.GetNumAnnots();
for (int i=0; i<num_annots; ++i) {
Annot annot = page.GetAnnot(i);
if (annot.IsValid() && annot.GetType() == Annot::e_3D) {
// Rect bbox = annot.GetRect();
Obj 3dd_stm = annot.GetSDFObj().FindObj(“3DD”);
if (3dd_stm) {
FilterReader reader(3dd_stm);
StdFile out_file(“my.u3d”, StdFile.OpenMode.e_write_mode);
FilterWriter writer(out_file);
writer.WriteFilter(reader);
writer.Flush();
}
}
}
}

Q: Is U3D only method to load the 3D models and convert it into 3D PDF
in your product?
-----------------

A: Besides U3D, PDFNet can also be used to embed/extract/replace PRC
files. The procedure to embed PRC file is similar to U3D. You would
generate a PRC/U3D file using a third party library or your own code
and then create a PDF using PDFNet.

Benefits of U3D format
  • Supports animations.
  • Open ECMA standard.
  • Free reference implementations available.
  • Supported by multiple third party products.

Benefits of PRC format
  • Allows storage of large CAD files to PDFs that are a fraction of
the original size.
  • Can retain geometry for reuse in CAD, CAM, and CAE applications.
  • Will be part of the upcoming PDF specification

The only two options to create 3D PDF is using u3D or PRC. PRC format
is described in the following specification:

http://livedocs.adobe.com/acrobat_sdk/9/Acrobat9_HTMLHelp/API_References/PRCReference/PRC_Format_Specification/index.html

Unlike U3D, PRC is still faily recent, is not completely standardized,
and is not widely adopted.