veerubiji:
Yes, that's exactly what it does. You didn't specify *any* requirements on the output, so I did the minimum I could to satisfy them. Of course, PerlMonks isn't a code writing service, so had you put any nontrivial requirements in, I probably would have passed over this thread.
In any case, I can't imagine that there's a "general purpose XML to PDF" procedure that would be useful, as there are myriad forms of XML documents, and even more ways to present the data. So you're going to have to get more detailed requirements from your user(s), and figure out how to turn them into code.
First you must figure out what you want:
- Get to know the XML data you've got as input. (What elements are there? What are the rules specifying when an element is present or absent? What types of data and/or attributes can/will exist?)
- Figure out what you want the output to look like (Here you need to determine formatting, spacing, and everything else. Which elements indicate the start of a new page? Which elements need bold/underline/italics/colored text/background? Which sections are formatted as tables? Which as plaintext? etc.).
- Then figure out how to transform bits of your input to bits of your output. (For example: <FROB> element introduces a table where <Gragnar> introduces a row and <Plook> indicates a data cell. If the Plook element has an attribute="snog", then add a red background, otherwise use blue. The first row is a header which we ..... etc.)
Now that you know what sorts of transformations you need to perform, you need to:
- Read the XML document (using your favorite XML parser),
- Perform the transformations you figured out (you can use XSLT, perl, or whatever),
- Then write the transformed bits to the PDF pages.
...roboticus
When your only tool is a hammer, all problems look like your thumb.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.