Showing posts with label pdf. Show all posts
Showing posts with label pdf. Show all posts

Thursday, July 1, 2010

3d pdf animation

was looking into adding animation to my 3d pdf objects again. it's really hard to find any useful info on the newer prc format (the best i could find was a low level adobe tech support guy whining about the iso application taking a long time). u3d has at least some skin and bone based animation, beyond the rigid body + scale part-level animation that is useless to me (every reference to key frame animation, afaik, refers to this). but i'm not sure if acrobat or the adobe reader support that part of the u3d ecma standard. this page (google cache) from right hemisphere seems to say that it doesn't, but that might refer just to their deep exploration code. at any rate, i think they were one of the founding parties to the standard, so it's not promising if they never bothered. somewhere i found an unreferenced statement that everything supports ecma 1st edition, but acroread 7 doesn't support ecma 3rd edition.
however, the JavaScript for Acrobat 3D Annotations API Reference doc on the adobe website describes a Bone object and specifically says it 'is usually moved over time to create animated characters.' Mesh objects contain geometry, but nothing in the api doc looks like it could be actual vertex positions, unless they're lurking in the Node.metadataString. i can find no additional info on Bone.
the U3D Supported Elements doc from the 3d dev center states that skeleton descriptions are 'parsed and unused (that is, no skeletal animation, skinning, or bones)'
also, opacity and material color animation are not supported, and i'm pretty sure that's a basic u3d limitation.
it's hard to find much info about the newer prc format. i don't see anything in the adobe spec docs that obviously provides for it (though not much anything obvious in the specs... quite sparse). i think the best i can do right now is look at the asymptote code (there was a passing reference to animating the prc in one of their journal articles as a todo item; alas, the only animation they show in that article is an ordinary movie). rumor has it that adobe turned the prc implementation over to a third party, bailing again on a drive into the 3d market, so i'm not sure prc has a future any brighter than u3d, which they have said (fwiw) they will always support.
so the only way out i can see right now is to create multiple meshes, one for each time step, and use javascript to cycle the visibility toggles. i guess the only real wasted space comes from the redundant connectivity, and that might be manageable if i continue to use only the exterior surfaces. and it would allow me to circumvent the u3d material color animation limitation. a rough estimate is 6.5 bytes/exterior node for u3d file size. actually, maybe that's not too bad... a 5 second, 20 fps animation with 8000 exterior nodes would fit in under 5MB. not too big for a short report or presentation. (maybe ~10 fps is a more realistic limit on what acroread can achieve.)
a little playing around with the quality options: diffuse color quality moved down from 300 to 100, -dcq 100, make practically no difference in file size. specular color quality, -spq 100, and animation quality 1000 -> 100, -aq 100, made zero difference since i'm not using either. geometry default quality down from 300 to 100, -gq 100, makes no difference, as does texture quality 75 -> 50, -tq 50. texture coordinate quality 300 to 100, -tcq 100, and normal quality 300 to 100, -nq 100, make zero difference. the one thing that does change the file size significantly is position quality. i had been using -pq 500, and -pq 100 decreases the size by about 7-8%. and maybe decreasing the palette from 256 to, say, 16 colors would help, though it would surely be less than a 10% difference. so i don't think there's any way i could squeeze it down more than 20-25%.

Tuesday, June 8, 2010

encrypted pdf files

managed to get a pdf file with restricted permissions using pdftk (pdf toolkit). the man page was a bit unclear on this, since if you just put in an owner password it will not actually restrict the file and no passwd is requested (or needed) to open it. this will do the trick, with all restrictions:
pdftk in.pdf output out.pdf user_pw foo
or, to make 2 levels of access:
pdftk in.pdf output out.pdf owner_pw baz user_pw foo
now the restrictions will be in place if you put in foo as the passwd, but they will not if you put in baz.

Friday, February 5, 2010

scan to pdf

here are a handy pair of commands that help convert scanned images to a pdf document: in python [os.system('convert -rotate 90 HP00%02d.jpg p%02d.pdf'%(i+1,i)) for i in range(1,15)] using the pdfjam package pdfjoin *.pdf
be careful, tho: pdfjoin will hang if you call it on files that have spaces in their paths (even if those spaces are not in the command line).
(in case i ever need it later) pdfjoin uses pdfpages with this macro:
\includepdf[pages=-,fitpaper=true,trim=0 0 0 0,offset=0 0,turn=true,noautoscale=false]{/var/tmp/5663150830922source1.pdf}

Wednesday, December 17, 2008

3d pdf objects

i tried for way too much time to compile the u3d reference library from sourceforge, with something tantalizingly close to success. the only way i could actually use it, though, was to use wine on the precompiled windows binary on an idtf file. the only way i have successfully created an idtf is by exporting an imported stl file from meshlab. i did manage to shove the resulting u3d into a pdf, and it looked pretty cool. but i need to find an easier way to make idtf files. EDIT: apparently vrml 97 can be converted to u3d with acrobat 3d. s2plot site gives some instructions, including some basic frame-based animation. also, some russian dude made a vtk->idtf exporter. not sure if he published anywhere. also also, mathgl supposedly has idtf export capability, so things like udav that use it should, too.

Thursday, May 29, 2008

pdftotext

recently i needed to rip the text out of a pdf file so i could read it on my pda. (it doesn't have a pdf reader right now, and even if i got one it would take forever to render all the images.) here's a command that works pretty well, even preserving the layout with pretty good accuracy: pdftotext -layout -enc ASCII7 -nopgbrk file.pdf file.txt