Forum How do I...?

From Latex to Vector to PDF?

JohnClarke
Until now, I've been using bitmap images (png, jpg) to display Latex images in my html when viewing in a browser. The images are sometimes inline with text and otherwise images centered in a section with whitespace on both sizes. I first convert tex to dvi, then dvi to png using imageMagick. This works fine.

Now I want to create PDFs from my html using Prince and need clear, sharp images from my Latex. So, two issues come to mind:

1) How can I realiably size my high resolution (say 300dpi) bitmap (black and white) to print at a reasonable size? Is it as simple as finding the resolution of my images and setting the image-resolution property?

2) Would it be possible to use EPS or some other vector format in order to avoid large bitmap files and at the same time maintain clean, sharp images? I can programatically provide the image size, and therefore could adjust each image to with a custom resolution if necessary. I'm hoping for a cleaner solution though.

Note: I don't think SVG would work: a) imagemagick does not have a realiable conversion from dvi to svg and b) svg might not be easily configured to print properly.

Any ideas welcome. -John

John Clarke
Cornerstone Systems Northwest Inc.

Lynx
I first convert tex to dvi, then dvi to png using imageMagick. This works fine.

Note that future versions of Prince may support MathML (there is alpha release that already includes incomplete experimenta MathML support). So LaTeX2MathML conversion could be alternative option for formatting LaTeX formulae in Prince.

In addition one may try to embedd LaTeX formulae directly in XML document and transform them to either MathML or XML + CSS using XSLT.
I have some style sheets for LaTeX like input syntax, but it is not exactly LaTeX (rewriting them for LaTeX will require extra efforts).

There is also LaTeX2XML converter written in ECMAScript that produces XML markup compatible with Prince. However it understands only limited subset of LaTeX notations. It can be used as online converter in Opera 9 and/or macro for EmEditor.
JohnClarke
Thanks Mike. Yes, it would be great to have a LaTeX-to-MathML converter. However, I haven't seen anything that is robust enough for us. All the examples that I've seen either don't work (perhaps my browser), are not fully Latex compliant, and/or don't provide an adequate output (funny/unpredictable alignment etc.). Hence, my need for a compromise to some sort of vector image. Is there a list of image types that Prince supports somewhere? -John

John Clarke
Cornerstone Systems Northwest Inc.

JohnClarke
Never mind about the image format list. I found it. :)

John Clarke
Cornerstone Systems Northwest Inc.

k1000
I might be misunderstanding, but as you have the LaTeX source, why do you need to do LaTeX -> html -> pdf.
It could probably be easier to use LaTeX for its purpose and use pdflatex, which produces a pdf output from a LaTeX input, no ?
mikeday
Just for the record, the earlier comment was from Lynx, not me! :)

1) How can I realiably size my high resolution (say 300dpi) bitmap (black and white) to print at a reasonable size? Is it as simple as finding the resolution of my images and setting the image-resolution property?

Yes, it should be that simple. In fact, for most images Prince should automatically detect the resolution specified in the image, and you won't even need to specify it manually.

2) Would it be possible to use EPS or some other vector format in order to avoid large bitmap files and at the same time maintain clean, sharp images?

Unfortunately Prince does not currently support EPS images; SVG is the only supported vector image format at present.

Best regards,

Michael
JohnClarke
Yes, it should be that simple. In fact, for most images Prince should automatically detect the resolution specified in the image, and you won't even need to specify it manually.

Excellent! That is really cool.

Unfortunately Prince does not currently support EPS images; SVG is the only supported vector image format at present.

Understood. This is definitely on my wishlist... :) (any common vector image would work, I think) Mainly, I want a clean-looking black-and-white Latex equation. Bitmaps are OK for now, but they tend to look funny at different magnifications when viewing in a PDF and they tend to bloat PDF file size. However, I realize that supporting a vector image of any type in Prince will be a challenge.

John Clarke
Cornerstone Systems Northwest Inc.

JohnClarke
k1000 wrote:
I might be misunderstanding, but as you have the LaTeX source, why do you need to do LaTeX -> html -> pdf.
It could probably be easier to use LaTeX for its purpose and use pdflatex, which produces a pdf output from a LaTeX input, no ?

Thanks for the suggestion. You're right, if I had only Latex to represent as a PDF, this would work fine. However, I have latex equations as images within html, so I need something (like Prince!) that can realiably convert HTML into a PDF. -John

John Clarke
Cornerstone Systems Northwest Inc.

k1000
Right.

I thought all your HTML was produced by your LaTeX source. But of course, my suggestion is useless if it is not the case...