Forum How do I...?

can I directly embed eps/pdf or emf/wmf?

Anonymous
I'm wondering if I can directly embed eps/pdf or emf/wmf files using 'img'. I can convert them to bitmap formats (e.g. png), but it's not just an extra step to take but also the result wouldn't be so good when printed unless I use a very high resolution when converting.
mikeday
Currently Prince does not support EPS/PDF/EMF/WMF image files.

Prince does support a subset of Scalable Vector Graphics (SVG), which has the scalable property that you are looking for. The SVG support is described in the SVG documentation.

One limitation of SVG support in Prince 5.1 is that SVG files are not recognised as images, and must be either included directly in the XML document or referenced using XML Inclusions (XInclude).
Anonymous
Thanks for your reply.
I should have mentioned that I'm well aware of Prince's support of SVG. :-) More and more tools/programs support exporting to SVG as time goes by. Therefore, it'll get easier to live without EPS/PDF support in Prince. However, still being able to 'embed' PDF/EPS is rather handy, I think. Do you have any plan to add that feature?
mikeday
It would be handy to support PDF/EPS as image formats, yes. Sadly, they are both quite complicated formats, and supporting them in their entirety would take a lot of work and considerable time.

Another thread has popped up on the forum concerning interleaving PDF content within a PDF that has been generated from Prince. This may be easier to implement than support for arbitrary PDF images.
JohnClarke
I've been searching for a while now for ways to get Latex equations inserted into a Prince PDF. There are several products that convert PS to SVG but they don't work reliably and SVG doesn't handle equations/text that well anyway. Currently, I'm converting the Latex to PNG and inserting the PNG as an image into my XHTML. This works fine, but the resolution (even in high resolution) is always sketchy because of the way Acrobat renders bitmaps (they tend to look good at one resolution and not so good otherwise).

Would it be hard to add another import vector format to Prince? PS, EPS would be ideal. Perhaps there is another format that wouldn't be as complicated? I'm using Imagemagick to convert from DVI to PNG, so it would be just as easy to convert to another vector format. It would be useful to know whether this feature (or similar) is in the works and when it might be released.

John Clarke
Cornerstone Systems Northwest Inc.

mikeday
Hi John,

I've been searching for a while now for ways to get Latex equations inserted into a Prince PDF.

How about converting the equations to MathML and then formatting that with Prince? The next major release of Prince will support MathML, and we have an early alpha version that you can try.

Best regards,

Michael
JohnClarke
Thanks Michael. Yes, I'll look into MathML. I forgot to mention that our clients use MS Excel charts and MS Word diagrams. Normally, we have to convert them to gif/jpg for the web. However, for a PDF, I'd like to be able to insert them as vector art for the reasons mentioned earlier in this thread. Hence the continued interest in PS. -John

John Clarke
Cornerstone Systems Northwest Inc.

JohnClarke
I downloaded and tried the alpha and tried some converted Latex -> MathML. Although it seems to work for the most part, the quality of the final PDF isn't as good as Latex -> PDF/PS (font looks squished, spacing is off). Perhaps, a different font and some adjustments in spacing would help? In any case, looks great for a first try. -John

John Clarke
Cornerstone Systems Northwest Inc.

Chris Thorman
Hi,

Has there been any update to plans to support this feature? I'd really like to be able to embed EPS or PDF images inside a prince document.

-c
mikeday
Not yet, it's a tricky feature to add, and there are many other priorities at present.
pavithra
Hi Mike, if there is any way of bringing in EPS in princexml?
mikeday
Only by converting it to SVG or a raster image format like JPEG, PNG, or TIFF.
rajakullayappa
Its been 20 years since we are waiting for EPS/PDF support in Prince XML. Could you please let us know when can we expect this highly important feature ?
mikeday
Hopefully within the next twenty years! :D
Chris Thorman
Hi rajakullayappa —

I don’t know your particular circumstance, or whether your build process is automated, but I have had success in my build pipeline using the pdf2svg tool to convert the PDF images to svg and then embedding those. (And if you are starting with eps, you could of course convert those to PDF first.) I have only tried this with pure-vector images (no bitmaps), and of course single-page graphics (not multi-page PDFs) but the results have been excellent. The main downside of the technique is that the text inside the embedded graphics is not searchable in the final PDF.

There is a bug in pdf2svg in which the natural size of the converted svg is in the default 96dpi px=pixels whereas pdf is in 72dpi pt=points (they forgot to specify the width/height units as pt). I just use a simple script to work around that.

Here is a gist with that script. Maybe you will find it helpful.

https://gist.github.com/cthorman/7168a0a419511152eefe5386ad06d243

@Mike, maybe you could grab this pdf2svg code and use it as a starting point for supporting this feature directly in prince.

Hope this helps,

-c