Inline SVG (Flare-processed text) in PDF target

This forum is for all Flare issues related to PDF, eBook, Microsoft Word, Adobe FrameMaker, XPS, and XHTML book targets.
Post Reply
KayJay
Propeller Head
Posts: 23
Joined: Tue Nov 29, 2016 7:19 am

Inline SVG (Flare-processed text) in PDF target

Post by KayJay »

Hi All :flare:,

I'm using flowcharts (SVG files) in my documentation, and would like to be able to include cross-references (perhaps also variables and conditional text) in these graphics.
I am using Flare 12 R2 and have Ghostscript and the correct Java version installed so that linked SVGs with static text (eg. <img src="myflowchart.svg"/>) are working fine when added to PDF targets (as well as HTML5). However these linked SVGs do not display in HTML5 or in PDF when there is dynamic text involved, such as a cross-reference.

I would therefore like to use SVG as an inline element so that the text is processed by Flare. For example,

Code: Select all

        <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="100" height="100">
            <circle cx="50" cy="50" r="40" stroke="green" stroke-width="4" fill="red" />
            <text x="0" y="15" fill="blue">This is some SVG text!</text>
            <text x="0" y="55" fill="blue">See <MadCap:xref xlink:href="DummyTopic.htm">DummyTopic</MadCap:xref>.</text>
        </svg>
works fine in the HTML5 output, but in the PDF target the image is not shown and only the text (which is not linked properly) is included.

So, does anybody have an idea how I can find a solution that displays SVGs with Flare-processed text in PDFs?

I'm happy to invest some development time in finding/building a solution. Some ideas I've been thinking about are:
  • Making a pre-build script that builds a minimal HTML5 target with the flowcharts, saves the resulting SVGs to a directory, and the PDF target uses linked SVG files from this directory. Manually trying this shows the image but with no hyperlink.
  • Building the PDF target twice - writing some script that resolves the text on the first build, uses a post-build script to replace some placeholder text in a SVG with this content and build again for the updated version. This seems difficult as it would be hard to reach into the PDF output to access the resolved text, and I'm not sure if these links will work in the output.
  • Using EPS or some other vector-graphics format in the PDF, though I don't think Flare can resolve xrefs in EPS either (from testing).
Any ideas? Can anyone tell me the order in which cross-references are resolved in PDFs vs. when ghostscript processes SVGs? Anyone know a way I can hack PDF links into being preserved when ghostscript processes SVG files?
doc_guy
Propellus Maximus
Posts: 1979
Joined: Tue Nov 28, 2006 11:18 am
Location: Crossroads of the West
Contact:

Re: Inline SVG (Flare-processed text) in PDF target

Post by doc_guy »

My guess is that the XML schema of the transform that manipulates the SVG code to a graphical form doesn't allow for elements with the MadCap namespace (or any other element that isn't part of the SVG schema), making the XML invalid, which is why the PDF target can't understand it.

It is a cool idea, though. Have you tried talking to somebody in Support and having it added as a feature request?
Paul Pehrson
My Blog

Image
Phlawm53
Sr. Propeller Head
Posts: 442
Joined: Tue Mar 16, 2010 10:58 am
Location: San Francisco, CA
Contact:

Re: Inline SVG (Flare-processed text) in PDF target

Post by Phlawm53 »

Per the "but in the PDF target the image" bit.

Can you use *any* tool to successfully embed the inline SVG tags into a PDF?

For example, hand edit a 100-percent standards compliant XHTML and CSS file entirely outside of Flare. Use the W3C's validator to ensure that the XHTML is fully standards compliant. Does a web browser properly present the inline SVG?

If yes, try to find a process that generates a PDF that presents the SVG code in the same way. I could be wrong but I think the issue might be the nature of PDF.

All that said, Flare's PDF engine also contains gaps in its XHTML and CSS support. Some of those gaps make sense: Unlike XHTML, PDF is a static medium. Even so, Flare doesn't support some XHTML and CSS constructs that would be useful in PDFs...

Cheers & hope this helps,
Riley
SFO
Post Reply