Saturday, 1 May 2010

Acrobat 3D PDFs - stopping export to 3D Reviewer

Prompted by a question at AcrobatUsers, here's a schneaky hack for anyone putting 3D models into their PDF files and who wants to stop the trivially-easy export of those models into other software.

When you import a 3D file using Acrobat Pro Extended, it can be stored internally in one of two ways: PRC (B-rep) and U3D. PRC preserves the exact contents of CAD/CAM files, so is great if you want people to be able to do accurate measurements on the 3D model, and U3D embeds polygonal geometry (meshes), as generated from 3D modelling software such as Sketchup, 3DS Max, Maya etc. You can down-sample U3D scenes to intentionally reduce their value to anyone, but then of course you lose accuracy on measurements.

Either way, if you send the PDF to someone using Reader 9, they get to look at it and not much more.

However if they have Acrobat 9, they can right-click on the 3D scene, and find a nice little context menu:


If the model is a PRC, the "Export Data" option is available, and will let them export to a number of formats (IGES, ParaSolid, STEP, VRML, and STL). As the PRC model is "perfect", so is the exported copy. If the model is stored as a U3D mesh, only the "Edit in 3D Reviewer" option is available, but it's still possible to hoof the model out. Not good, if your model was supposed to be "protected" by this whole PDF idea.

The trivial-but-deceptive solution is to apply security to the PDF, and in the security options panel uncheck "Enable copying of text, images and other objects". When you import a PRC file, Acrobat Pro Extended even tells you this (as a stark reminder your data is perfect and vulnerable):



So fine, you apply password security - but hold on a second. First, remember that password permissions security on a PDF is an illusion of security, not real security. It can be removed in 5 seconds by anyone with free software, of which there are pages and pages on Google. The only truly secure methods are certificates and DRM (such as through Adobe LiveCycle), and both of those cost money to implement. While we're at it, what if you don't want to stop copying at the document level (maybe something else in the document needs to be copyable)? Can we get the "Export to" and "Edit with" options to just go away?

Well, yes - yes we can! But first, we need to understand something about these annotations in Acrobat 9. If you open the content inspector sidebar (right-click the sidebar area if it's hidden) and inspect your 3D PDF, you will see the annotation is stored as "3D":

However, it's NOT a "3D annotation". The 1.7L3 PDF specification only understands something called a "Rich Media annotation", which can play Flash, video or 3D content, and which has a special variable to say which it's trying to display. So the image above is showing the page contains a "RichMediaAnnot of type 3D".

Why care? Because Acrobat 9 and Reader 9 don't care. If you create a RichMedia annotation of ANY type, it will play it even if the content doesn't match the type variable - but they make up the context menu based on the type variable alone. Confused? Well think of it like this - if we make a VIDEO annotation, but put a 3D scene inside it, Acrobat and Reader will show the 3D scene just perfect; but will show the context menu for a video:



Note the distinct lack of anything saying "Export" or "Open in". Nada. Zip. Bupkis. The PDF is still not secured, but we can't extract the 3D data! Not only that, if we try and open the PDF directly in 3D Reviewer, it'll show an empty scene - because dear old 3D Reviewer only looks for annotations of type=3D.

Getting excited yet? Want to know how to do this insane alchemy of the annotations?

You need a SWF.

Any SWF. Literally any SWF - you're not even going to use it. You just need one.

Create your 3D scene as normal in the PDF, and right-click it to choose Properties. In the popup window, switch to the Resources tab and press ADD. Select that SWF and add it. Don't bother with anything else, because it's only going to be there for 5 seconds.

now press OK to close the Properties panel, and immediately right-click and re-open it again. Go back to the Resources tab, and remove the SWF. Yup - delete it. Press OK again, and you're done. The PDF is exactly as it was before (you haven't even saved your changes yet) - but go open that content inspector and see what it says:



Now for the fun part - activate your 3D scene, and right click it. What don't you see?