Slashdot Mirror


Pretty Printing From An XML File?

Omega1045 writes "Where I work we are developing a new product that receives an XML document (on a W2k workstation), and we need to format and print said document. We are currently using XSLT + CSS to build a cool little HTML page out the the XML, then use a browser to print out the HTML. However, while HTML is a nice format for display, it is not a nice format for printing. We have messed around with the idea of spitting out Rich Text with XSLT. However, Rich Text is confusing and quite frankly sucks. We are looking for a (free if possible) format that we can translate our XML document into via XSLT, and print. The best idea we have at this point is to translate into a Word or OpenOffice XML schema document, and use one of those applications to print. Other ideas?"

13 of 65 comments (clear)

  1. FOP by pi_rules · · Score: 4, Informative

    Apache FOP Homepage

    Very powerful if you ask me. I used it on a project back in 2000-2001 and was pleased with how it turned out at the time. I'm sure the current product is much, much, better than it was back then.

    1. Re:FOP by danpat · · Score: 2, Informative

      I agree. XML-FO is supposed to be the W3C's "definitive" answer to an XML, page-oriented formatting language. XML-FO achieves basically exactly what PDF does, but in XML. It's supposed to be a structured representation of print-formatted data.

      I've used it quite a lot and it's great. It's very easy to transform your XML data into the XML-FO schema, from which you can use Apache-FOP (or one of the commercial tools) to turn it into a format other tools can use (PDF, ps, RTF, etc).

    2. Re:FOP by malachid69 · · Score: 2, Informative
      I agree. XML->XSL->FOP is the way to go.

      BTW, from http://www.w3schools.com/xslfo/xslfo_intro.asp:

      XSL-FO is Formally Named XSL Why this confusion? Is XSL-FO and XSL the same thing? Yes it is, but we will give you an explanation: Styling is both about transforming and formatting information. When the World Wide Web Consortium (W3C) made their first XSL Working Draft, it contained the language syntax for both transforming and formatting XML documents. Later the XSL Working Group at W3C split the original draft into separate Recommendations:

      • XSLT, a language for transforming information
      • XSL or XSL-FO, a language for formatting information
      • XPath, a language for defining parts of an XML document
      --
      http://www.google.com/profiles/malachid
  2. Try PDF by Mastos · · Score: 4, Informative

    I have a similiar problem I solve through the use of XSLT and XSL-FO. Use XSLT to transform the XML into XSL-FO. Then, use Apache FOP to render the XSL-FO into PDF.

    Another variation is to transform your XML into an HTML subset, then use a standard XSLT to transform the HTML into XSL-FO. A similiar technique is used by Aurigadoc to create all sorts of output formats using an XML source.

    1. Re:Try PDF by Apreche · · Score: 2, Informative

      That's a good idea. You can also translate into postscript, then send the postscript right to the printer. You can also use ps2pdf to make pdfs from the postscript. People don't realize, but postscript is actually a programming language you can write in. Turning an XML document into a postscript should be not outside the real of possibility with XSL.

      --
      The GeekNights podcast is going strong. Listen!
  3. XSLT-FO by JumpSuit+Boy · · Score: 4, Informative

    http://xml.apache.org/fop/
    http://www.cranesoftwr ights.com/training/ has a book about how do this that was created using XSLT-FO

    There are also paywhere implimentations XSLT-FO this. Basicaly it is the extension to XSLT for print.

    --
    Oh really?
  4. Consider YesLogic Prince by PornMaster · · Score: 3, Informative

    Prince is a batch formatter for converting XML into PDF and PostScript by applying Cascading Style Sheets (CSS). Unlike other formatters, Prince prints any XML vocabulary without relying on proprietary markup

  5. Docbook by ptaff · · Score: 3, Informative

    Another XML-based format is DocBook, which originally was SGML based but now has a XML DTD too. From this format you can output to ps, pdf, rtf and plenty of other formats.

    You could also hack one of the docbook XSL stylesheets (using XSLT? would be pretty!) to make it parse your own format.

    Feel ready to own one or many Tux Stickers?

  6. Apache FOP Supports Postscript by Mastos · · Score: 2, Informative

    While its support might not be complete (http://xml.apache.org/fop/output.html#ps) Apache FOP can also render into postscript. The advantage of XML-FO, while it hasn't been very well received, is it tries to be sufficiently expressive to support any number of output types from print (PDF, PS, RDF, etc) to graphics (SVG).

  7. XMLPDF by WasterDave · · Score: 3, Informative

    Never quite sure what the hell it does myself, but a few people here swear by it:

    http://www.xmlpdf.com/

    Cheers,
    Dave

    --
    I write a blog now, you should be afraid.
  8. maybe...? by heistgonewrong · · Score: 1, Informative

    send it to a MySQL database, then Use PHP to creat a PDF, and print it from PDF... although I can't contest for the quality of printing from PDF. Just my 2cents.

  9. Re:You're almost there... by Anonymous Coward · · Score: 1, Informative

    The W3C seems to disagree with you.

    No they don't, as other people have pointed out, you have thoroughly confused the terms "specification" and "standard". If you want to hear it straight from the horse's mouth:

    The W3C has been an active voice in industry technology debates for a little over two years now. Today, we represent over one hundred and seventy developers, research organizations, government agencies, and users. We have a technical staff of three dozen folks around the world working in three Domains on thirty Activity Areas. We are not a:

    1. Standards body, because we do not make legally binding decisions
    2. Research Think-tank, because we work on the here-and-now
    3. Trade Organization, because we represent the public trust

    There you have it. The W3C are not a standards body. They don't make standards. If you want to use a standardised document format, ISO, a real standards body, has produced ISO-HTML.

  10. Re:Try Docbook by CRCulver · · Score: 3, Informative

    LaTeX doesn't do Unicode, you'll have to translate those characters.

    Actually, LaTeX does do Unicode, and quite well. You just have to install Dominique Unruh's unicode package if your LaTeX distribution doesn't already ship it. I've used it for over a year to typeset documents with lots of Old Church Slavonic, Greek, and Hebrew, easily mixing scripts in one document and being free to keep all foreign scripts in UTF-8.

    If you would like to see some examples, check out my two tutorials for LaTeX for philologists (which I still work on and update from time to time).