Skip to content

Instantly share code, notes, and snippets.

@vyach-vasiliev
Created August 13, 2020 13:53
Show Gist options
  • Save vyach-vasiliev/8443dfe2ee21c5af0d2e2ddaa933faca to your computer and use it in GitHub Desktop.
Save vyach-vasiliev/8443dfe2ee21c5af0d2e2ddaa933faca to your computer and use it in GitHub Desktop.
Extract 3D objects from PDFs

This instruction is about how to get a 3D model out of a PDF file.

We need:

  • Python version not lower than 2.7
  • Any version OS (Windows, Linux, Mac)

Extract

Download the Pythong PDF Parser: https://blog.didierstevens.com/programs/pdf-tools/

  1. Search for the 3D object:
./pdf-parser.py -t /3D input.pdf
  1. You’ll get a response like this
obj 12 0
 Type: /3D
 Referencing: 21 0 R, 19 0 R, 20 0 R, 13 0 R
 Contains stream

  <<
    /3DOwners [21 0 R]
    /AN 19 0 R
    /Length 491554
    /OnInstantiate 20 0 R
    /Subtype /PRC
    /Type /3D
    /VA [13 0 R]
  >>
  1. The Object ID (in this case 12) is what we need to extract.
  2. Excute
./pdf-parser.py -o 12 -d output.u3d input.pdf

How open .u3d

Platform App Pricing
Online Glovius CAD Viewer Free
Platform App Pricing
Windows Blender Free
^ DAZ 3D DAZ Studio 4 Free
^ Bondware Poser Free Trial
^ Adobe Photoshop 2020 Free Trial
^ Adobe Acrobat DC Free Trial
^ Kubotek3D KeyCreator Free Trial
^ RealWorld Icon Editor Free Trial
Platform App Pricing
Mac Blender Free
^ DAZ 3D DAZ Studio 4 Free
^ Bondware Poser Free Trial
^ Adobe Photoshop 2020 Free Trial
^ Adobe Acrobat DC Free Trial
Platform App Pricing
Linux Blender Free

3D PDF Samples

https://tetra4d.com/pdf-samples/

Rights

Pythong PDF Parser - Didier Stevens (https://blog.didierstevens.com/about/)

Inspired by an article by Terence Eden (https://shkspr.mobi/blog/about/)

Feedback

Please feel free to leave comments on usage. Perhaps you can help others avoid making the same mistakes and save time.

@fischer-felix
Copy link

Similar issue to @taz5 here: trying to export the 3d model from this PDF file.

I can view it fine in Adobe acrobat, but the u3d file that I get out of it does not work anywhere.

I also noticed that in your example the subtype is shown as PRC, with my file it is U3D (see pdf-parser output below).

obj 11 0
 Type: /3D
 Referencing: 7 0 R, 8 0 R, 9 0 R, 10 0 R
 Contains stream

  <<
    /Type /3D
    /Subtype /U3D
    /VA [7 0 R 8 0 R 9 0 R 10 0 R ]
    /DV 0
    /Length 24836287
    /Filter /FlateDecode
  >>

Any help would be geatly appreciated.

@vyach-vasiliev
Copy link
Author

@taz5
Thank you for writing here about your problem.
I also reproduced your case and, unfortunately, I don't have enough time to delve deeper into the research.

Try to simplify the 3d PDF file so that the multimedia part opens immediately, without additional actions (click in some containers).
Of course, if you are making 3d PDF.

Like that: https://www.theorem.com/hubfs/3DPDF-Samples/Model%20Viewer.pdf
Source page: https://www.theorem.com/3dpdf/3dpdf-samples#pdf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment