Is Javascript executed when pubilshing to PDF?

This forum is for all Flare issues related to PDF, eBook, Microsoft Word, Adobe FrameMaker, XPS, and XHTML book targets.
Post Reply
Lilshieste
Jr. Propeller Head
Posts: 3
Joined: Tue Feb 04, 2014 3:12 pm

Is Javascript executed when pubilshing to PDF?

Post by Lilshieste »

Hi all,

We're considering the use of the Javascript package MathJax (http://www.mathjax.org/) for rendering equations in our documents. (In a nutshell: the Javascript parses MathML or LaTeX and replaces it with plain text, typesetting with CSS.)

Obviously, this requires that the Javascript be executed prior to the content being rendered as a PDF. When targeting HTML5 or Help File format, the equations look as expected (because the web browser is running the Javascript). However, when targeting PDF, the equations appear in their "pre-rendered" text (MathML or LaTeX).

What are the details of the process involved with publishing to a PDF? Is it possible for the process to execute Javascript hosted in the pages?

Regards,
Joe Miller
mbryan
Jr. Propeller Head
Posts: 1
Joined: Thu Feb 20, 2014 4:39 pm

Re: Is Javascript executed when pubilshing to PDF?

Post by mbryan »

I am having the same problem. I wrote a small script to dynamically put in referenced line numbers from other cells in a table. It works perfect when publishing to HTML5, however, my end user requires the documents to be published as PDF. Is there a way to get the JavaScript to process prior to publishing the PDF?

thanks, mike
NorthEast
Master Propellus Maximus
Posts: 6372
Joined: Mon Mar 05, 2007 8:33 am

Re: Is Javascript executed when pubilshing to PDF?

Post by NorthEast »

Lilshieste - Flare does already have an equation editor that supports MATHML and works for PDFs; or does that not meet your requirements?

See: http://webhelp.madcapsoftware.com/flare ... ations.htm
BenMathiesen
Jr. Propeller Head
Posts: 3
Joined: Thu Feb 27, 2014 3:20 am

Re: Is Javascript executed when pubilshing to PDF?

Post by BenMathiesen »

I'm also interested in implementing MathJax, but I'm very new to Flare. I'd be interested in any advice you have.
The integrated equation editor is OK, but our company style is white text on a charcoal background, and the resulting PNGs have a very chunky and pixelated look compared to regular text. Modifying the "MathType | Equation" styles for font weight and so forth doesn't seem to have any effect; the current result is at the border of legibility.
You do not have the required permissions to view the files attached to this post.
Lilshieste
Jr. Propeller Head
Posts: 3
Joined: Tue Feb 04, 2014 3:12 pm

Re: Is Javascript executed when pubilshing to PDF?

Post by Lilshieste »

Dave Lee wrote:Lilshieste - Flare does already have an equation editor that supports MATHML and works for PDFs; or does that not meet your requirements?

See: http://webhelp.madcapsoftware.com/flare ... ations.htm
Hi Dave Lee,

Thanks for the response, I apologize for not seeing it sooner (I mistakenly thought I had my preferences set up to send me email notifications for replies).

I'm indeed aware of Flare's built-in equation editor, but would actually like to render our equations in text whenever possible (i.e., instead of as images). As BenMathiesen mentioned, it's not uncommon for equations to appear "blocky" when rendered as images. (Additionally, this effect is exacerbated when a user attempts to "zoom" into a document to enlarge the text.)

This is why we've considered using MathJax, which uses JavaScript to parse MathML/LaTeX into a text-based representation. MathJax allows us to render our equations as expected in our HTML publications, but it isn't able to accommodate PDFs (or other non-web-based formats). So I was wondering if there might be some way to incorporate the MathJax processing into the generation of the PDF.

Alternatively, I would be open to the possibility of using MathJax for our HTML publications, and falling back on the PNG renderings for our PDFs. Unfortunately, I wasn't able to figure out a way of accomplishing this, since MathML is automatically wrapped in a MadCap:equation element (which effectively hides the markup from MathJax). This was actually the impetus for my other question: MathML without MadCap:equation?

Thanks for any help,
Joe
BenMathiesen
Jr. Propeller Head
Posts: 3
Joined: Thu Feb 27, 2014 3:20 am

Re: Is Javascript executed when pubilshing to PDF?

Post by BenMathiesen »

Just a quick update on this issue:
In Flare 10 Madcap introduced anti-aliasing to the images generated by MathML, so they look much better. However, this assumes a light background and can't be turned off. So if your website uses dark text on a light background MathML should be fine for both web and PDF outputs.
For a dark background, the dev team accepted my bug report (#100312).
Cheers,
Ben
nielsf
Propeller Head
Posts: 86
Joined: Mon Feb 02, 2015 5:44 am
Location: Copenhagen, Denmark

Re: Is Javascript executed when pubilshing to PDF?

Post by nielsf »

In response to the original post.
I have implemented a solution, in which I
  • Enter equations directly using LaTex, but enclosed in \( )\ for inline and \[ ]\ for paragraph equations - e.g. \( {A}_{delta} = {A}_{new} - {A}_{executed} \)
  • For Web, MathJax typesets this online, on-the-fly (no wait at all).
  • For PDF, my developer colleague has created a tool which
    1. Parses all content files
    2. Puts all equations into a Web Only condition
    3. Runs all equations through a LaTex compiler which generates .PS files
    4. Stores the .PS files in an "Equations" directory in the Images directory, including whichever subdir the eq was found in
    5. Inserts said .PS as images, enclosed in a Print Only condition
  • Prints a list of what was done.
Wonderful... all I have to do is run the tool with the Content folder as parameter, and I'm ready to publish.
The tool is for sale... :wink:
-Niels
-----
Flaring in Copenhagen, Denmark
devjoe
Sr. Propeller Head
Posts: 338
Joined: Thu Jan 23, 2014 1:43 pm

Re: Is Javascript executed when pubilshing to PDF?

Post by devjoe »

The PDFs I generated from Flare 10 have equations rendered as text. They do show as images in the help outputs, though (but as stated, with antialiasing which makes them look reasonably nice).
nielsf
Propeller Head
Posts: 86
Joined: Mon Feb 02, 2015 5:44 am
Location: Copenhagen, Denmark

Re: Is Javascript executed when pubilshing to PDF?

Post by nielsf »

OK, so you use text in PDF, and images in Web. I do the exact opposite... :)
-----
Flaring in Copenhagen, Denmark
vola_newbie2
Propeller Head
Posts: 10
Joined: Fri Jul 12, 2013 4:53 am

Re: Is Javascript executed when pubilshing to PDF?

Post by vola_newbie2 »

Hi everybody,

I have just read this thread.
I have the same problem. We have LaTeX documents and we produce both print and online outputs.
I converted LaTeX to HTML and used Mathjax for my HTML5 output.
But for my print output, I still use LaTeX editor. My goal is to use only one source, so that I don't have to modify .tex and .html files ...

Regarding your workarounds, I assume that my feature request of importing LaTeX into Flare or handling LaTeX for print outputs has only a little chance to succeed then :(

Niels, how much for your tool ? :)
nielsf
Propeller Head
Posts: 86
Joined: Mon Feb 02, 2015 5:44 am
Location: Copenhagen, Denmark

Re: Is Javascript executed when pubilshing to PDF?

Post by nielsf »

@Lilshieste: I'll talk to my boos and the developer, and get back to you! :)

-Niels
-----
Flaring in Copenhagen, Denmark
Post Reply