How can I extract U3D or PRC objects out of the PDF?

957 views
Skip to first unread message

Support

unread,
Feb 18, 2009, 8:55:42 PM2/18/09
to PDFTron PDFNet SDK
Q: How can I extract U3D or PRC objects out of the PDF stream so we
can parse them into our 3D rendering system. Do you have a call that
does this?

-----
A: Using PDFNet SDK you can embed or extract U3D and PCR models when
creating new or editing existing PDF documents.

As a starting point you may want to take a look at U3DTest sample
project:
http://www.pdftron.com/net/samplecode.html#U3D

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();
}
}
}
}
Reply all
Reply to author
Forward
0 new messages