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.

@taz5
Copy link

taz5 commented Jan 25, 2023

Hi, I converted the file using the parser and then wanted to see it using the softwares you mentioned but unfortunately, it doesn't work with any of the ones I tried. Maybe I did something wrong. Have you tested it with the softwares? If so, would it be possible for you to explain the procedure for them? Also, I wanted to understand how the file converts to u3d if the subtype mention is PRC. Could you explain that as well?

@StormyCube
Copy link

Thank you so much!!!!

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