Convert Web Based InfoPath Form via Form Services to a PDF
Hello,
Does anyone have a good idea on how to convert a web based InfoPath form into a PDF?
I've been looking into the MOSS Document Conversions, which could prove quite interesting. OOB, It allows to convert from InfoPath Form to Web Page (Web Publishing Page). Does a converter like "InfoPath Form to PDF" exist? Or perhaps just a "InfoPath to plain PDF" exist?
I've also been looking into the http://www.websupergoo.com/abcpdf-1.htm - ABCPDF component. It's quite clever, as it's able to take a URL as a parameter and return the web page as a searchable PDF (not just an bitmap image). However it fails converting any pages coming out of SharePoint / Form Services (even though it actually supports JavaScript).
Hit me back on any suggestions and ideas you have on this subject.
Kind regards.
Alle Antworten
I've got the same requirement: convert an InfoPath 2007 browser form to a PDF document (server side solution).
Of course you could just install a PDF printer on each client and that would work but I need a server side solution please help.
I've seen a video demo by Dafina Toncheva from Miscrosoft (EC306) and she was using the document converter of MOSS "From InfoPath to PDF". The feature seem to have disappear because Adobe seems to threaten with a lawsuit. It must be somewhere to download but where??
Hmmm that is interesting.. I know that Microsoft pulled the PDF writing capabilities from the Office 2007 client package. But this feature was then later available as an add-in for download:
Not sure if that add-in is usable in any way on a MOSS 2007 server.
Anyway, what you CAN do is rename your .xsn infopath template to .cab and open it. You'll find that all InfoPath views are nicely stored as .xsl stylesheets. So what you can do is perform a transformation of the .xml data file your infopath template saved with that .xsl file and you'll have some nice html that you can convert into a .pdf with a 3rd party component like:
http://www.winnovative-software.com/PdfTools.aspx
One thing to be aware of though is that you might not be successful getting image files etc. from the .xsn file into your transformation.
Anyway - this is a solution until the day where Microsoft might decide to release a real PDF Document Converter for MOSS.
if you save your info path form as source files, you will see that there is a stylesheet for each view of your form. Write a sharepoint event handler or a custom page that will take your form data file, transform it into a web page using XSLT and then use one of the open souce PDF generators to produce the pdf file.
This is how form to pdf converter in MOSS 2007 is implemented.
Another problem that you'll run into is attachments. If your form has attachments, where do they go?
Attachments are stored as a base64 blob in the infopath form, so it is fairly straightforward to write code to iterate through the attachments and store them somewhere else.
I found using the email submit option in infopath was a good way to send people completed, read only forms. It works with Outlook 2003/2007, but not sure about other email clients. Once it is on the clients machine, they can pdf it at their leisure.
Cheers,
Al
If you have Word on the server, you could use Word automation to print an InfoPath form to PDF. You would first have to convert the form from InfoPath to Word, and then use the Office 2007 save as PDF add-in to convert from Word to PDF (see http://enterprise-solutions.swits.net/infopath2007/article.php?t=use-word-2007-convert-infopath-2007-pdf&c=infopath2007). The advantage of using such a solution is that you won't be bound to printing just one view from InfoPath, because you basically decide what your form will ultimately look like when you design your Word document. The disadvantage of using such a solution is that Word automation on the server might not scale well.
A second option is to use a third-party component with which you can programmatically create PDF documents. It is then just a matter of converting the XML from your InfoPath form to PDF. The advantage is that you'll have total freedom when constructing your PDFs and the solution should be more scalable than the Word option.
- I'm tyring to implement this exact soluition. (InfoPath to Html, Html to PDF) It works fine for simple infopath forms, I extract the cab, read the manifest, identify the views etc. I'm using an XsltCompiledTransform to transform the xml and the view.
The problem is that when I attempt to use a form with secondary data sources it errors with:
System.Xml.Xsl.XslTransformException: Cannot find the script or external object that implements prefix 'http://schemas.microsoft.com/office/infopath/2003/xslt/xDocument'..
This probably happens because the view contains something like:
<
xsl:when test="function-available('xdXDocument:GetDOM')">The namespace included in the xsl is:
xmlns:xdXDocument
="http://schemas.microsoft.com/office/infopath/2003/xslt/xDocument" Obvoulsy when InfoPath transforms the data it includes these functions somehow, although I'm not sure how.
I was thinking either a custom XmlResolver, or a different XSLT processor. I was also checking my versions of MSXML but I think I have them up to date.
Has anyone else had this problem? - Have the same problem, though it's the http://schemas.microsoft.com/office/infopath/2006/xslt/User namespace which, gives me the exeption. Did you ever find a solution?
Yes I did get a solution. Basicallly I only process Print Views as they don't have any of the nasty xDocument stuff that I can't deal with.
I have built a component that does the following:
Locate the XSN document from the Pre Processor directives in the infopath XML file.
Download the XSN
Extract the contents as it is a CAB format
Parse the manifest file and locate all the Views.
Identify the Print View XSLT and transform it with the XML to give us HTML.
I then use Winnovative Html to PDF converter to generate a PDF. As I have extracted the image files, the Winnovative component also renders them in the PDF which is great.
I then stream the result back to the browser for the user to save.
Just a note on the Office Addin. We could not get that to work successfully as a server side solution and cannot explain why.- TJ,
Can you elaborate on what you mean by "Basicallly I only process Print Views as they don't have any of the nasty xDocument stuff that I can't deal with"?
I'm having the same problem. I get HTML by grabbing the XSN file and adding it to my project as an embedded resource, but for a lot of the forms it only shows my top header even though the HTML code is there for the rest of the form. - Sure. A normal view, might have some infopath control in it, like a button or a date control. Some of these work by using special xslt functions that are part of the xDocument schema. I have not found much information about these functions. When I try and transform the xml and the "normal" view I get errors from the Microsoft XLST engine that it can't deal with those functions. I assume that InfoPath has a built in library that contains the definition for these functions. I was never able to transform these views. So my work around was to use a print view as infopath seems to cut out all of the stuff that causes the xlst engine to error, and I can transform it correctly. So the limitation I currently have in my InfoPath to PDF solution is that it will only convert forms that have a Print View.
I'm not sure why you are not seeing all the html rendered. Are you transforming the xml with the print view xslt? I suggest saving it to the disk at each point Ie after XSLT trasnform as html, then after PDF conversion to see at which point that solution fails.
You may also want to check your version of MSXML, this can be out of date and cause odd issues.

