XSLT to PDF

C

CSharper

Is it possible to do XSLT transform and send the output to PDF or sorm
form of offline container to view later (with out transformation)
Thanks,
 
M

Martin Honnen

CSharper said:
Is it possible to do XSLT transform and send the output to PDF or sorm
form of offline container to view later (with out transformation)

XSLT can be used to transform XML to XML and if you use XSL-FO
(http://en.wikipedia.org/wiki/XSL_Formatting_Objects) as the target
format of your XSLT stylesheet then a FO processor can process the
result of your XSLT transformation to create a PDF document.
 
A

Arne Vajhøj

Is it possible to do XSLT transform and send the output to PDF or sorm
form of offline container to view later (with out transformation)

The output from the XSLT transformation can usually be
saved as a file.

PDF may be more tricky. I only know two XSL-FO products
that can generate PDF:
- Apache FOP
- Altova StyleVision
and I very much doubt that any of those are callable from .NET.

HTML would be a lot easier. And still have decent printing capabilities.

Arne
 
C

CSharper

The output from the XSLT transformation can usually be
saved as a file.

PDF may be more tricky. I only know two XSL-FO products
that can generate PDF:
   - Apache FOP
   - Altova StyleVision
and I very much doubt that any of those are callable from .NET.

HTML would be a lot easier. And still have decent printing capabilities.

Arne

Hi Arne,

Thanks, is it possible to save it as a file? I am after printing. I
have multiple XSLT and I want to transform XML against each xslt and
generate one final output with all the transformation.
 
P

Peter Duniho

Arne said:
The output from the XSLT transformation can usually be
saved as a file.

PDF may be more tricky. I only know two XSL-FO products
that can generate PDF:
- Apache FOP
- Altova StyleVision
and I very much doubt that any of those are callable from .NET.

I assume you mean you doubts they have specific .NET support. A library
that can be called via other means is also callable via .NET. It just
requires a little more work, is all.
HTML would be a lot easier. And still have decent printing capabilities.

The OP did say "or sorm [sic] form of offline container" (guessing
"sorm" is supposed to be "some"), so HTML may well be a suitable
alternative. I agree that it's much easier and that they should
consider that, assuming it can suit their needs.

But the OP should note that there's a big difference between PDF and
HTML in terms of features. HTML is very much renderer-dependent. This
is sometimes a very good thing, but when you want to make sure the
output looks _exactly_ as you intended, PDF is a much more appropriate
format.

Pete
 
P

Peter Duniho

CSharper said:
Thanks, is it possible to save it as a file?

Sure. The specifics depend on how you're doing the transform. But, for
example, if you are using the XslCompiledTransform class, and calling
the Transform() method, you simply use one of the overloads that allows
you to direct the output to a file. The simplest overload takes two
strings: a URI indicating where to find the input, and a string
indicating the filename where the output should be saved. Other
overloads allow the output to be an XmlWriter, TextWriter, Stream, etc.
all of which may be connected to a file (but of course could be
something else if you like).
I am after printing. I
have multiple XSLT and I want to transform XML against each xslt and
generate one final output with all the transformation.

Define "one final output". Note that the output from your transform
will be an XML document. You can't just append one XML document to
another. But of course, if you have a well-defined way of merging all
your output XML documents into something that makes sense as a single
document, that would be fine.

Pete
 
A

Arne Vajhøj

Thanks, is it possible to save it as a file? I am after printing. I
have multiple XSLT and I want to transform XML against each xslt and
generate one final output with all the transformation.

Both PDF and HTML can be saved as file.

Arne
 
A

Arne Vajhøj

I assume you mean you doubts they have specific .NET support. A library
that can be called via other means is also callable via .NET. It just
requires a little more work, is all.

AFAIK then neither are libraries - Apache FOP is a Java app and
Altova StyleVision is a native app.

I suspect that the "little" more work is a pretty big little.
HTML would be a lot easier. And still have decent printing capabilities.

The OP did say "or sorm [sic] form of offline container" (guessing
"sorm" is supposed to be "some"), so HTML may well be a suitable
alternative. I agree that it's much easier and that they should consider
that, assuming it can suit their needs.

But the OP should note that there's a big difference between PDF and
HTML in terms of features. HTML is very much renderer-dependent. This is
sometimes a very good thing, but when you want to make sure the output
looks _exactly_ as you intended, PDF is a much more appropriate format.

XML->HTML via XSLT is easy.

HTML prints nicely.

If the exact formatting is important, then the transformation must
assume a specific browser.

It may even be possible to convert the HTML to PDF.

Arne
 
P

Peter Duniho

Arne said:
[...]
and I very much doubt that any of those are callable from .NET.

I assume you mean you doubts they have specific .NET support. A library
that can be called via other means is also callable via .NET. It just
requires a little more work, is all.

AFAIK then neither are libraries - Apache FOP is a Java app and
Altova StyleVision is a native app.

Let me rephrase: if they are usable from one's own code in any scenario,
they are usable from .NET.

I don't know anything about either package; maybe they aren't usable
from _any_ kind of code, including .NET. But then I'm not sure why they
are mentioned as a solution in a programming newsgroup. My assumption
is that the OP is actually looking for something that works in code.
I suspect that the "little" more work is a pretty big little.

For libraries? Or standalone application? If there's a well-defined
way to use them from code, the work shouldn't be all that hard even if
they aren't specifically .NET-friendly, whether they are libraries or
standalone applications.

If there's not a well-defined way to use them from code, then yes…it
could potentially be a lot of work to get them to work from code. But
that would be true no matter what language/platform one was writing
one's code in, making them somewhat impractical solutions to be
suggested in a programming newsgroup.
XML->HTML via XSLT is easy.
True.

HTML prints nicely.

Not always true.

Unfortunately, browsers have a variety of implementation bugs in which
their output, either on-screen or printed, does not necessarily conform
to the specification, and worse, there are often problems when printing
a document that aren't seen in on-screen display (I ascribe that to the
fact that for whatever reason, different code paths are used depending
on the output device, and on poorer testing for printing scenarios).

Even for simple things, I've run into a variety of presentation bugs in
a variety of browser. I can't imagine the headaches someone writing
complex HTML must have to deal with (fortunately, my XSL/HTML/CSS uses
are always reasonably simple).
If the exact formatting is important, then the transformation must
assume a specific browser.

If by "specific browser" you mean "specific version of a specific
browser running on a specific version of a specific platform", then yes.
IMHO that's a serious problem.
It may even be possible to convert the HTML to PDF.

Any platform that includes "print to PDF", either as a built-in feature
(e.g. Mac OS) or using a third-party printer driver (e.g. Windows) can
trivially convert HTML to PDF. But you still have the browser
compatibility issues.

For long-term maintenance, if an exact output is needed, biting the
bullet and implementing output-to-PDF from the outset is really the most
efficient, most practical approach.

Pete
 
A

Andy O'Neill

HTML would be a lot easier. And still have decent printing capabilities.

Arne

Hi Arne,
Thanks, is it possible to save it as a file? I am after printing. I
have multiple XSLT and I want to transform XML against each xslt and
generate one final output with all the transformation.

Is an excel file any good to you?
I've used xslt to produce excel files a number of times.
 
C

CSharper

Hi Arne,


have multiple XSLT and I want to transform XML against each xslt and
generate one final output with all the transformation.

Is an excel file any good to you?
I've used xslt to produce excel files a number of times.

Let me explain what I am after that will you better direction
I have set of XML and collection of XSLT. I walk through each xslt and
try to transform associated XML (I know before hand which XML i need
to look for each xslt). Each result in a formatted output. Foreach
ransformation, I want to send the result to PDF or some sort of
container and continue append the result containter like appending new
pages in PDF. Once all the transformation is done, I would like to
give a dialogue for user to print it.

I was even thinking of doing all the transformation and creating the
printing container in a web service and then get the result and give
it to user to print. The client need not see each transformation
happening.

Thanks,
 
A

Arne Vajhøj

Let me explain what I am after that will you better direction
I have set of XML and collection of XSLT. I walk through each xslt and
try to transform associated XML (I know before hand which XML i need
to look for each xslt). Each result in a formatted output. Foreach
ransformation, I want to send the result to PDF or some sort of
container and continue append the result containter like appending new
pages in PDF. Once all the transformation is done, I would like to
give a dialogue for user to print it.

I was even thinking of doing all the transformation and creating the
printing container in a web service and then get the result and give
it to user to print. The client need not see each transformation
happening.

Can you go the HTML route ?

Arne
 
M

Mike Schilling

Peter said:
Not always true.

Unfortunately, browsers have a variety of implementation bugs in
which
their output, either on-screen or printed, does not necessarily
conform to the specification, and worse, there are often problems
when printing a document that aren't seen in on-screen display (I
ascribe that to the fact that for whatever reason, different code
paths are used depending on the output device, and on poorer testing
for printing scenarios).

MSWindows understands HTML and can create PDF files. Can it be
automated to do the conversion for you?
 
P

Peter Duniho

Mike said:
MSWindows understands HTML and can create PDF files. Can it be
automated to do the conversion for you?

Can you be more specific?

Windows does include the IE HTML renderer, but I'm not aware of any
built-in PDF support for reading, never mind writing, even for Windows
7. Where do you see that?
 
M

Mike Schilling

Peter said:
Can you be more specific?

Windows does include the IE HTML renderer, but I'm not aware of any
built-in PDF support for reading, never mind writing, even for
Windows
7. Where do you see that?

In Word 2007, one of whose "Save as" choices is PDF. And I'm pretty
sure this is "write-only" support, as "*.pdf" isn't one of the choices
in the "Open" dialogue.
 
P

Peter Duniho

Mike said:
In Word 2007, one of whose "Save as" choices is PDF. And I'm pretty
sure this is "write-only" support, as "*.pdf" isn't one of the choices
in the "Open" dialogue.

That's not "MSWindows". That's a Microsoft Office feature.
 
M

Mike Schilling

Peter said:
That's not "MSWindows". That's a Microsoft Office feature.

I knew what I meant to type: why didn't you? :)

Anyway, I'm wondering if Word can be automated to do the HTML->PDF
conversion.
 
P

Peter Duniho

Mike said:
I knew what I meant to type: why didn't you? :)

Hmmm…gotta get that psychic news post translator fixed. Guess it's on
the fritz again. Sorry! :p
Anyway, I'm wondering if Word can be automated to do the HTML->PDF
conversion.

Probably. There's definitely Office interop support, and assuming the
PDF plug-in is installed (not sure what Office 2010 will be like, but
Office 2007 required a download to get PDF saves working), it's possible
the option is exposed in the Save method arguments.

Of course, there may or may not be the remaining issue that if the code
is intended to run on a server, Office interop is generally frowned upon
due to problems with the lack of presence of a GUI session. There is
also the problem that Word isn't exactly the best HTML renderer around.
And of course, such a solution requires having a license for Word; one
might as well get a standalone PDF generator package.

But not counting those issues, sure…one might choose to use Word to save
HTML as PDF. :)

Pete
 
T

Tom Shelton

Is it possible to do XSLT transform and send the output to PDF or sorm
form of offline container to view later (with out transformation)
Thanks,

Not sure if the option has come up - but, have you thought about using XPS?
It is a fixed document type like PDF - but, it is an xml file so you should be
able to transform your xml to an xps document for printing...

Should be on available on any machine with 3.0 or greater.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top