XML/Code formatting for PDF output

This forum is for all Flare issues not related to any of the other categories.
Post Reply
bboursaw
Propeller Head
Posts: 39
Joined: Thu Apr 02, 2015 4:20 pm

XML/Code formatting for PDF output

Post by bboursaw »

First off, I do realize this is not a new topic and there have been several posts through the forum as well as on the web regarding code formatting - but not much for PDF output. So based on all of my research and sifting, it appears that there still is no way to easily format XML or other code to have syntax highlighting within PDF output? Maybe I have missed something throughout all of the posts and if so, I am sincerely sorry, as I'm not trying to be, "That guy." Has anyone come up with a method for better handling how code can be included in PDF output? Any recommendations or suggestions would be greatly appreciated.
techwriter31
Propellus Maximus
Posts: 551
Joined: Wed Mar 05, 2008 10:50 am

Re: XML/Code formatting for PDF output

Post by techwriter31 »

Yeah, unfortunately most of the options out there require JavaScript and thus aren't supported in PDF outputs. We use various "pre" tags to format our code. In Flare, you can select the "pre" style and paste the code into the topic. As soon as you paste the content, there is a small clipboard displayed at the end. Click the drop-down on the clipboard and select "Paste Inline Text".

Still not the easiest/most automated method, but it works.
Kellie
NorthEast
Master Propellus Maximus
Posts: 6365
Joined: Mon Mar 05, 2007 8:33 am

Re: XML/Code formatting for PDF output

Post by NorthEast »

If you're talking about automatic syntax highlighting using javascript, such as Google prettify, then they'll only work for web-based outputs. The syntax highlighting isn't in the built output, it's applied at run-time by the browser using javascript, which is why it won't work for PDFs.

Presumably you require a tool that you can run on your local source topic files to apply the syntax highlighting before you build the project. I'm not aware of any tools that will do that, however I've never looked for one.
doc_guy
Propellus Maximus
Posts: 1979
Joined: Tue Nov 28, 2006 11:18 am
Location: Crossroads of the West
Contact:

Re: XML/Code formatting for PDF output

Post by doc_guy »

If your code absolutely *must* be prettified in the PDF documents, the easiest way is probably to store the code in text-based documents that you might even include in your Flare project. Then make the changes to the code, and take a screen shot and insert the screen shot into Flare. If you change the code, you'd need to know to update the screen shot, which is a pain, but I have found no good solution for prettifying source code in PDF. Most of the time I just don't think it is worth it, and leave the code unprettified in my PDF output. In some cases, like in API docs, or whatever, I actually use inline styles to apply colors to various elements, but this is a completely manual process, and can be a big pain in the coccyx.
Paul Pehrson
My Blog

Image
LeeD
Propeller Head
Posts: 11
Joined: Sat Apr 25, 2015 8:25 am

Re: XML/Code formatting for PDF output

Post by LeeD »

Our group has been using prettify, which was working fine, until now. As it turns out, the prettify developers decided to change their access url without notifying anyone. All is well again, however, with the updated url.

Nice, huh?

We're also investigating Prism: http://www.prismjs.com, which was recommended by Scott Deloach at MadWorld. It'd be nice to have another tool in my back pocket in the event this is a recurring theme with the prettify folks.

Good luck,
Leon
NorthEast
Master Propellus Maximus
Posts: 6365
Joined: Mon Mar 05, 2007 8:33 am

Re: XML/Code formatting for PDF output

Post by NorthEast »

You are using prettify with PDF outputs?
LeeD
Propeller Head
Posts: 11
Joined: Sat Apr 25, 2015 8:25 am

Re: XML/Code formatting for PDF output

Post by LeeD »

No, sorry, it's for the online help, not PDF.
stephjnca
Jr. Propeller Head
Posts: 3
Joined: Mon Aug 31, 2015 7:22 am

Re: XML/Code formatting for PDF output

Post by stephjnca »

Hey there, Leon

Do you mind providing the updated access URL for prettify? I just noticed that the syntax highlighting is no longer working in our output.

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

Re: XML/Code formatting for PDF output

Post by Phlawm53 »

------
I created a separate thread that describes how I finally got syntax-highlighted code samples to appear in both online and PDF Flare Targets:

viewtopic.php?f=6&t=29397

The essential point is that one needs to use a syntax highlighter that wraps code in inline HTML formatting. That inline HTML appears in both online and PDF outputs.

HOWEVER, it's necessary to append <br/> tags to each line of code that is terminated by a SPAN tag.

AND Flare's execrable internal text editor doesn't make the job any easier.

Cheers & hope this helps,
Riley
SFO
Post Reply