AllenDowney / plastex-oreilly

Branch of plastex that generates DocBook 4.5 that meets O'Reilly style guidelines.
7 stars 7 forks source link

figure size is not right in the ORM pdf #5

Open AllenDowney opened 12 years ago

AllenDowney commented 12 years ago

Either the figure size is not getting passed along or the ORM autobuild is ignoring it, so all figures are big.

test_suite/small demonstrates the problem

AllenDowney commented 12 years ago

It looks like specifying the size of images is not part of DocBook. There is a pgwide attribute to indicate if you want the figure scaled to the width of the page, but that's it.

So maybe the right thing is for plastex to use the latex width, height and scale parameters to resize the PDF and then pass along the resized image.

There is code in Packages/graphicx.py that is supposed to do this but

1) There is a bug that causes the argument of includegraphics.invoke to be incorrect sometimes, and

2) the rescaling code doesn't work on PDFs

So I'm stumped for now.

tiarno commented 12 years ago

we can handle this in a couple of ways; postprocessing (this code will pass the height/width params through to docbook:

    <imagedata
    tal:attributes="fileref self/image/url;height self/style/height;width self/style/width" />

or we can do it by loading up pyPdf and rescaling on-the-fly, like Kevin does for PNGs using PIL. It's just tedious to write the code since we could have scale, height, or width given. not that hard, just tedious.

I'm not sure which way is best, given that oreilly will probably change their process at some point to no longer bother with pdfs (if i read the comment correctly on the question of pdfs).