Detecting if a PDF file contains 3D element -


is there way detect if pdf contains 3d element (universal 3d object embedded) without reading file contents? can information obtained metadata?

afaik, there no requirement put info metadata fact 3d elements may contained in document.

some u3d writing software may put hint xml metadata though.

long answer

you'll have parse pdf page tree @ least partially in order find out.

technically, 3d elements implemented annotations. discover annotation, you'd have follow parsing path:

  1. read trailer. tells object number of /root indirect object of document.

  2. read cross reference table. tells byte offsets each indirect object within document.

  3. go /root indirect object. read /pages key. tells indirect object represents root of document's page tree.

  4. go indirect object represents /pages. read /kids key. tells other indirect objects represent document pages.

  5. go each indirect object representing document page. (optionally present) /annots key. if present point other indirect objects representing (possibly sorts of) annotations.

now you've found out if pdf contains annotation(s) or not. if not, stop here. if yes, go on determine annotation type(s):

  1. go indirect objects found in last step. of /type /annot. see if additionally of /subtype /3d. if yes, have found 3d annotation. (attention, may still not u3d one!)

  2. within lastly found indirect object(s) -- one(s) /subtype /3d key -- additional key of /3dd. points indirect object contains actual 3d stream.

  3. go indirect object containing 3d stream. object dictionary should again contain key:value pair of /type /3d. @ /subtype key. if says /u3d have found looked for...

short answer

you may lucky , harvest low-hanging fruits using old grep this:

$> grep -a u3d cc-7-july09.pdf    /subtype /u3d   /ms /u3d   /u3dpath [ <135bb3d42fbd85f7c2e178> <056d9a891fb5fdce8e> ]   /ms /u3d   /u3dpath [ <5ffaf35ce3cbd34fae5360> <4ddfd6048fc6da05> ]   /ms /u3d   /u3dpath [ <2e4e4fd7fec771038bc5ea> <2a6579cc91be0b> ]   /ms /u3d   /u3dpath [ <6f303af9850721d5d1fc6c> <7d1b08beae4a5a9bedbb> ]   /ms /u3d   /u3dpath [ <f270a04603f0de08b8aa29> <ee5180016ffbd542> ]   /ms /u3d   /u3dpath [ <a1d5848f6841ada9a3583c> <a3f8a5d45849d392ef> ]   /ms /u3d   /u3dpath [ <34b8650d178bbdff61dc03> <2d8f4c7d3cd980f976> ]   /ms /u3d   /u3dpath [ <843cd0339fd1852cca235b> <9719fb65a990897f> ] 

however, not work 3d pdf documents, if 3d elements part of object stream.


Comments

Popular posts from this blog

dns - How To Use Custom Nameserver On Free Cloudflare? -

python - Pygame screen.blit not working -

c# - Web API response xml language -