20,741
edits
m (→CanvasPDF) |
|||
| Line 176: | Line 176: | ||
== CanvasPDF == | == CanvasPDF == | ||
Checking the examples in the osg source tree, the demo rendering a PDF to a osg::Node is fairly compelling and extremely compact, requiring only ~15 lines of code {{OSG example|example=osgpdf}}: | |||
<syntaxhighlight lang="cpp"> | |||
#include <osgWidget/PdfReader> | |||
// ... | |||
osg::ref_ptr<osgWidget::PdfReader> pdfReader = new osgWidget::PdfReader; | |||
pdfReader->open(const char*filename, hints); | |||
root->addChild(pdfReader.get()); | |||
</syntaxhighlight> | |||
So all that is needed is including the osgWidget/PdfReader header and editing the top-level CMakeListst.txt file to ensure that osgWidget is added as a required library in the find_package() call. | |||
To turn this into a proper element, we can next open the header itself and check what methods are available, so that these can be exposed via Canvas properties | |||
{{Custom_Canvas_Element | {{Custom_Canvas_Element | ||
<!-- | |||
|packageName=Poppler | |packageName=Poppler | ||
|packageURL=https://github.com/Eyescale/CMake/blob/master/FindPoppler.cmake | |packageURL=https://github.com/Eyescale/CMake/blob/master/FindPoppler.cmake | ||
--> | |||
|baseclass=Image | |baseclass=Image | ||
|elementName=PDF | |elementName=PDF | ||
| Line 189: | Line 207: | ||
* [http://www.mail-archive.com/osg-users%40lists.openscenegraph.org/msg18080.html Introducing osgpdf] | * [http://www.mail-archive.com/osg-users%40lists.openscenegraph.org/msg18080.html Introducing osgpdf] | ||
* http://trac.openscenegraph.org/projects/osg/browser/OpenSceneGraph/trunk/src/osgWidget/PdfReader.cpp?rev=14085 | * http://trac.openscenegraph.org/projects/osg/browser/OpenSceneGraph/trunk/src/osgWidget/PdfReader.cpp?rev=14085 | ||