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();
}
}
}
}