Quote:
Originally Posted by dgatwood
Although I haven't tried it with formulas, you should also be able to use LaTeX to create SVG content. That's how I create my title pages for my EPUB books, for example (to preserve strict formatting in a device-independent way, while retaining text searching). The basic process is as follows:
|
I came up with this .bat file, in order to take a folder full of the PDF formulas -> PNG. I just downloaded all the formulas generated from CodeCogs as PDFs, and ran them through Imagemagick's "convert":
Code:
FOR /F %%k IN ('dir /b .\*.pdf') DO (
convert -density 350 %%k ^
-background white -flatten -trim ^
-depth 8 -colors 17 ^
%%k.png
)
- -density 350
- This would just generate the image at ### DPI. For my purposes, 350 DPI is fine, but you can substitute whatever number you need.
- -background white -flatten -trim
- This just makes the background of the image white (instead of transparent), gets rid of the alpha channel, and cuts out all the surrounding blank space besides the formula itself.
- I remove transparency + the alpha channel because some devices/converters just can't handle it (look above with those huge black boxes I got via KindleGen).
- -depth 8
- This just specifies to make the PNG 8-bit depth (a few of the devices were buggy when dealing with 2 or 4-bit PNGs).
- -colors 17
- This cuts the formula down to 17 shades of color. In this case, it would be black + white + 15 shades of gray.
- I settled on 17, so it is just barely above the 16 colors which would bump it down to 4-bit image after certain tools would optimize. This cuts down on filesize dramatically (compared to the same image Indexed with 256 colors or Grayscale).
I assume Inkscape also has similar commands... although I am not too familiar with using Inkscape via commandline.
I haven't fiddled around with Imagemagick to make PDF->SVG. Might be nice to just generate the SVG+PNG of the formula at the same exact time.
Also, just having it in a nice command allows you to just convert entire folders, saving a bunch of time.
Quote:
Originally Posted by dgatwood
Either drop the resulting <svg> tag and its contents into an HTML file or import it with an <img>, <object>, or <embed> tag.
|
Hmmm... have any sample EPUB of these SVG Title Pages? Do these EPUBs include ONLY SVG Title Pages? Or do you have the PNG or HTML fallback as well for devices that can't handle SVG?