.NET Framework - XSLT to PDF

Asked By CSharper
23-Jan-10 12:19 PM
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,
Office 2007
(1)
Office 2010
(1)
Windows 7
(1)
Word 2007
(1)
Office
(1)
TextWriter
(1)
Stream
(1)
XslCompiledTransform
(1)
  Martin Honnen replied to CSharper
23-Jan-10 12:01 PM
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.


--

Martin Honnen --- MVP XML
http://msmvps.com/blogs/martin_honnen/
  Hillbilly replied to Martin Honnen
23-Jan-10 01:57 PM
W3Schools has become one of the best resources --after-- we neophytes hear
from a predecessor (GuideDog) who lets us know what to look for:
http://www.w3schools.com/xslfo/xslfo_software.asp
  Arne_Vajhøj replied to CSharper
23-Jan-10 04:13 PM
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
  CSharper replied to Arne_Vajhøj
23-Jan-10 07:55 PM
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.
  Peter Duniho replied to Arne_Vajhøj
23-Jan-10 07:51 PM
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.


The OP did say "or sorm [sic] form of offline container" (guessing
alternative.  I agree that it is much easier and that they should
consider that, assuming it can suit their needs.

But the OP should note that there is 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
  Peter Duniho replied to CSharper
23-Jan-10 08:34 PM
Sure.  The specifics depend on how you are 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).


Define "one final output".  Note that the output from your transform
will be an XML document.  You cannot 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
  Arne_Vajhøj replied to CSharper
23-Jan-10 10:10 PM
Both PDF and HTML can be saved as file.

Arne
  Arne_Vajhøj replied to Peter Duniho
23-Jan-10 10:19 PM
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.


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
  Peter Duniho replied to Arne_Vajhøj
24-Jan-10 12:24 AM
Let me rephrase: if they are usable from one's own code in any scenario,
they are usable from .NET.

I do not know anything about either package; maybe they are not usable
from _any_ kind of code, including .NET.  But then I am 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.


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

If there is 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.


True.


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 are not 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 have run into a variety of presentation bugs in
a variety of browser.  I cannot imagine the headaches someone writing
complex HTML must have to deal with (fortunately, my XSL/HTML/CSS uses
are always reasonably simple).


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 is a serious problem.


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
  Andy O'Neill replied to CSharper
24-Jan-10 08:36 AM
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 have used xslt to produce excel files a number of times.
  CSharper replied to Andy O'Neill
24-Jan-10 10:34 PM
.

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,
  Arne_Vajhøj replied to CSharper
24-Jan-10 09:47 PM
Can you go the HTML route ?

Arne
  Mike Schilling replied to Peter Duniho
25-Jan-10 05:28 AM
MSWindows understands HTML and can create PDF files.  Can it be
automated to do the conversion for you?
  Peter Duniho replied to Mike Schilling
25-Jan-10 12:16 PM
Can you be more specific?

Windows does include the IE HTML renderer, but I am not aware of any
built-in PDF support for reading, never mind writing, even for Windows
7.  Where do you see that?
  Mike Schilling replied to Peter Duniho
25-Jan-10 12:28 PM
In Word 2007, one of whose "Save as" choices is PDF.  And I am pretty
sure this is "write-only" support, as "*.pdf" is not one of the choices
in the "Open" dialogue.
  Peter Duniho replied to Mike Schilling
25-Jan-10 12:41 PM
That's not "MSWindows".  That's a Microsoft Office feature.
  Mike Schilling replied to Peter Duniho
25-Jan-10 03:36 PM
I knew what I meant to type: why did not you? :-)

Anyway, I am wondering if Word can be automated to do the HTML->PDF
conversion.
  Peter Duniho replied to Mike Schilling
25-Jan-10 03:51 PM
Hmmm?gotta get that psychic news post translator fixed.  Guess it is on
the fritz again.  Sorry!  :p


Probably.  There is 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 is 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 is not 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
  Tom Shelton replied to CSharper
25-Jan-10 04:16 PM
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.

--
Tom Shelton
  CSharper replied to Tom Shelton
25-Jan-10 10:43 PM
S?
ld be

Hi Tom,

Thank you for bringing that up, yes currently I am looking at XPS
route since it is build into .net frame work compare to PDF.  I am
also tragetting 3.0 framework anyway.

Thanks all for the conversation.
Create New Account
help
ms 2007 .NET Framework With the introduction of windows 7 and new computers why is ms office 2007 the latest version of office products? .NET Framework Discussions Office 2010 (1) Visual (1) Louisiana (1) Lakewood (1) Avenue (1) Greg (1) Netframework (1) F3FEB522C902 (1 Am 01.03.2010 02:30, schrieb wchris14: This group (microsoft.public.dotnet.framework) is about writing applications based http: / / msdn.microsoft.com / en-us / netframework / default.aspx) - - Armin See: http: / / www.microsoft.com / office / 2010 / en / default.aspx?WT.srch = 1&WT.mc_id = 28187644-BD16-423C-A7BF-F3FEB522C902 - - Richard
Visual Basic y Office 2007 .NET Framework Hola buenas tardes. Tengo un proyecto desarrollado en Visual Basic 6.0 y me ha surgido el tema de tener que conectarme a una base de datos de Office 2007, pero me da error de que no se reconoce el formato de la base de Connection (1) Visual Basic 6.0 (1) ConexionExterna.open En (1) BaseDatos.mdb G (1) Office 2007 (1) ADODB (1) Set G (1) El 01 / 06 / 2010 12:00 p.m., David Varez escribi??: El ??objeto ado? soporta solo hasta ciertas versiones de office, debieras actualizarlo keywords: Visual, Basic, y, Office, 2007 description: Hola buenas tardes. Tengo un proyecto
WebBrowser-Control mit Office 2007 Dokus - Frage .NET Framework Hi Leute, sorry das ich mich wegen so einer Lapalie an Doku angeworfen und dieses wurde dann innerhalb des WB-Controls angezeigt. Unter WinXP-SP3 mit Office 2003 und Win7 mit Office 2003 hat das geklappt. Leider seit der Umstellung auf Office 2007 unter Win 7 funkt das einfach nicht mehr, es wird immer das Word 2007 mit dem File geoeffnet und nicht innnerhalb des Control angezeigt. . . . . . Im Netz habe ich nur Olli C# - German Discussions Windows XP (1) Internet Explorer 7 (1) Internet Explorer 8 (1) Office 2007 (1) Office 2003 (1) Excel 2007 (1) Windows 7 (1) Word 2007 (1) Hallo
Office 2007 RibbonX (XML) Validation .NET Framework Hello, I think this is my first post in this that I do know about XML have been gathered in my novice accomplishments using the Office 2007 CustomUI Editor (Editor) to write XML that customizes the Microsoft Word Ribbon. The Editor has is invalid. The value 'gigantic' is invalid according to its datatype. 'http: / / schemas.microsoft.com / office / 2006.01 / customui:ST_SizeUI' - The Enumeration Contraint Failed I have opened customUI.xsd and it not reported at all. Can anyone give me any help or ideas on how a Office customUI file is validated when using a 3rd party XML editor like UltrEdit? Thanks. - - Greg for an eclectic collection of Word Tips. Xml Discussions Microsoft Word (1) Visual Studio (1) Office 2007 (1) Office 2010 (1) CustomUI (1) XMLlint (1) I do not know the answer to
Office 2010 - Outlook 2007 Addin .NET Framework Hello! Is there a way to put my Outlook 2007 Addin in the first Ribbon "Start" of Outlook 2010? Without changes Outlook 2010 put my Addin in the Ribbon called "Addins" that is unusable for my users. I need a way to deploy my Addin to Office 2007 and later to Office 2010. I hope there is a way without migrating to VSTO