Friday, March 02, 2007 5:02 PM
I have a requirement to convert an infopath file to pdf.It's very urgent, friends.
I have no idea about. Is there any way of doing so through code?..
Thanks in advance...
Wednesday, March 07, 2007 12:28 PMOf course it can be done in code. But it involves a lot of code and quit some experience with both xsn and pdf. If you need it urgently try googling wether such a converter already exists or forget about it.
Thursday, March 08, 2007 5:57 AM
Thanks micvos. Finally I got a single reply from this forum.This is for the first time I need to wait for many days for a reply in this forum.
Thanks for your mind. Let me give some more details. Infopath form templates has .xsn. But when we fill the form and save it, it is stored as .xml.
can u suggest any method for converting this .xml with xsl to pdf?
I already got one add-in from microsoft which can do the same. But I want to do it in a button click.This is not possibile with add-in, because , we need to go to file menu and click on 'Export to pdf' option.
I am now thinking in a way to use crystalreport for the same. Can you give any input?
thanks in advance...
Thursday, March 08, 2007 9:32 AMNow I'm not really sure what you want. Do you want to convert a infopath document(xsn) to pdf or do you want to convert a filled out form into something printable.
Thursday, March 08, 2007 11:05 AM
An filled out form comes to our application. The template form is >xsn.We need to convert tothe filled out form to pdf. That's the actual requirement.
Thursday, March 22, 2007 2:39 PM
U can get help regrading how to Add the Form Control to the Visual Studio 2005 Project in this link http://msdn2.microsoft.com/en-us/library/ms406041.aspx.
Install 2007 Microsoft Office Add-in: Microsoft Save as PDF or XPS u can get addin from this link
After adding the FormControl to the windows application and installing Microsoft Add-in.
This code helps to conver the infopath(*.xml) file to the PDF.
// file refers the source file path
// finalFilename is the destination file path
MessageBox.Show("Confirm of exporting Document" + finalFileName);
FormControl1.XmlForm.CurrentView.Export(finalFileName + ".pdf", Microsoft.Office.InfoPath.ExportFormat.Pdf)
instead of PDF there are two option available
Thursday, March 29, 2007 9:02 PM
can you explain the form control better? Thanks. Still working hard on how to do this in infopath 2007.
thanks in advance.
Friday, March 30, 2007 9:14 AM
By default there is no option to convert the infopath file to PDF. So Microsoft gives addin to overcome the issue you can download the 2007 Microsoft Office Add-in: Microsoft Save as PDF or XPS from this link http://www.microsoft.com/downloads/details.aspx?familyid=4D951911-3E7E-4AE6-B059-A2E79ED87041&displaylang=en
Once you installed then there is a option in the file menu export to PDF and XPS in the Infopath 2007.
Add the Form Control to Windows Application
Form control is a COM object, so by default it will not available in toolbox. So the First step is to add the Form control to the toolbox under the general tab.
These are the below steps to add a FormControl on the Toolbox.
1) Toolbox -> Go to General Tab -> Right click on it
2) Select ChooseItems you will get window (Choose Toolbox items) click Browse button
3) Go to path ("E:\Program Files\Microsoft Office\Office12") most probably this may the path oterwise go to loaction where the Office 2007 is installed
4) There you can find the Microsoft.Office.InfoPath.FormControl.dll select the dll
5) Know you cand find the FormControl under the tab of .Net FrameWork Components(select the FormControl and Click OK)
6) Use can see FormControl in the General tab.
7) Drag and drop in Windows Application
In the Button click Event
1) FormControl1.Open(SourceInfopath) (ie Opening a infopath form in FormControl)
2) Application.DoEvents() (try with Application.DoEvents() if u get error like View is not ready then place a MessageBox and just pop
some Message)3) FormControl1.XmlForm.CurrentView.Export(Destinationpath, Microsoft.Office.InfoPath.ExportFormat.Pdf )
you can ask what is the use of the second line. Here is the trick lies FormControl is the COM Object and it takes time to load. So we are giving some time to complete the Formload operation(By giving DoEvents() or by prompting MessageBox). FormControl1.open() doesn't return anything we don't have any option to know wheather FormControl loaded the infopathForm.
Most of us can get View is not ready error this is beacuse of the above reason. Because formcontrol takes time to load within that period we may try to Export operation. So in this case we may get View is not ready to avoid use the above operation
If Some one find the better way of tackling the above said error let me know
Friday, March 30, 2007 1:32 PM
A low tech way to convert an Infopath file to pdf is to copy & paste the form into MS Word, "save as" html then use Adobe Acrobat to convert the new file to a pdf. Most of the fields function properly and save properly. You may need to add text boxes since those don't seem to carry over. This method is a little cumbersome and not real fast but does work. If your form is large, you may need to copy and paste into several smaller documents. But you can combine them in the final Acrobat version.
Tuesday, April 03, 2007 4:13 PMSo let me clarify just for my understanding. I will need to create a activex/com component to do the saving as a pdf? Also is there a way to use the submit button to export/save the pdf programatically to a sharepoint url?
Once again thank you for your all your help.
Forgive my lack of knowledge of this.
Tuesday, April 03, 2007 4:30 PMThank you for your help. Just to clarify. Is there a way to export or save the form as a pdf and save it to a sharepoint url within a submit button without activex/com ? Let me know.
Thursday, April 12, 2007 2:29 PMOk so in reply to my own question. Here is a better way without a active x com object.
I know I am sorry for the jscript but here it goes.
Add this to the onclick event and have full trust enabled.
Thursday, December 27, 2007 6:52 AM
I have browser enabled infopath forms saved in a form library. I need to export these forms to pdf at run time so that to send those pdfs as attchemnt in email.
Will form control will work in this scenario?
Wednesday, March 03, 2010 2:05 PMMOSS_Sharepoint
Did you find a solution for this? I'm also having this problem.
Thanks for your reply
Thursday, March 18, 2010 9:50 AMHi Mikedopp,
i am doing something similar in Infopath 2007. where in the edit form code would i place that entry
Tuesday, April 13, 2010 5:03 AM
Do you got any solution?
Friday, May 14, 2010 12:55 AM
You may use any image capturing program, such as SNAGIT
Sunday, May 16, 2010 2:19 PM
I had the same problem with infopath to pdf conversion, i tried to use microsoft Microsoft Save as PDF or XPS, but i had a lot of problems with page breaks, positioning of an elements, tables etc. I tried also to use xslt extracted from XSN file to convert it to html and then to pdf - this was to complicated and i had some weird results. I tried also external components ( i tried all that google returns from search :) ). Thing is that all this methods are good in case of small and not complicated infopath forms. My form printout has up to 100 pages, a lot of pictures, attachements tables, and runtime evaluated expression boxes (for multilanguage support). Finally i used InfoPathToPdf.exe from a-pdf, and i just run it from my code. It uses just a virtual priter and INFOPATH - maybie it is not so elegant - but it works ! I find it as the best solutiuon for infopath to pdf conversion on the market and it costs something about 30$
Monday, June 14, 2010 3:53 AM
Can you please tell me how to use A-PDF from code, I am trying to use it from code and it hangs in waitforexit line(I am calling it from .net environment)
Tuesday, June 29, 2010 4:35 PM
This code has worked for me. I added a button called "Print" to my InfoPath form and programmed the following against it (VB.Net):
Public Sub Print_Clicked(ByVal sender As Object, ByVal e As ClickedEventArgs)
Dim filename As String
Dim nameNode As XPathNavigator
nameNode = MainDataSource.CreateNavigator().SelectSingleNode("insert the XPath to the field on which you want the name of the pdf based on", NamespaceManager)
filename = nameNode.Value + ".pdf"
Me.CurrentView.Export("C:\" + filename, ExportFormat.Pdf)
Tuesday, October 05, 2010 7:19 AM
Hi, sory for the late replay, if a-pdf hangs it means that form is not opening correctly (focus is set to some popup window), please try to copen your xml using infopath and check if infopath opens it without any errors/updates/popups/
Friday, November 19, 2010 11:39 AM
Check out the following posts:
- Batch print InfoPath Forms using the PDF Converter for SharePoint
- Converting InfoPath forms including all attachments to a single PDF file
- Controlling which views to export to PDF format in InfoPath
- Using SharePoint Forms Services to convert InfoPath forms to PDF format
- Converting Office files to PDF Format using a Web Services based interface
- Using the PDF Converter from a SharePoint workflow
- Proposed As Answer by XristosK Thursday, September 29, 2011 2:38 PM
Tuesday, February 22, 2011 11:31 AM
I am getting problem at convert a infopath template to XMl using vsta.
one another Q. if i want to conert preprinted form means any paper form which i had scan & import to
infopath then how to edit that one or directly convert in XML
if got some stuff mail me email@example.com
Wednesday, March 02, 2011 8:07 PM
When I try this, the formControl1 is null. If I try formControl1 = new FormControl(), I get an exception. What am I doing wrong here ?
Friday, March 25, 2011 4:15 AM
I don't know the method about code, maybe there is proper one can fix the problem.
I just want to show my way to export as pdf file. I think the "save as PDF/XPS" feature can't deal with the infopath so well as there are many tables, images, blabla... So actually you can use a print driver-PDF Creator
For the infopath file is printable files. In the print dialog, choose he pdf creator as the virtual printer, tick the print to file checkbox.
Then it will be added to pdf creator and you can further define the settings like security and compression to get expected files. Then wait for the output opened in the adobe reader.
Of course capture it as image file then export to pdf file is feasible by the creator but it's time-consuming if have a bunch file to go.
Never too old to learn
Friday, April 01, 2011 6:21 PMFor something like this why not just print it to cutepdf or pdf creator?
- Proposed As Answer by Derek.Wilkes Tuesday, July 05, 2011 11:42 AM
Friday, April 01, 2011 9:02 PM
If you are trying to generate a pdf from the xml, you could use http://itextpdf.com/ to generate your pdf on the fly.
The basic logic will be :
- Parse your InfoPath XML
- Process the XML to generate a PDF whith itextpdf library
Hope this helps.
- Proposed As Answer by XristosK Thursday, September 29, 2011 2:39 PM
Wednesday, April 13, 2011 12:40 AMInstall Solid PDF Reader http://soliddocuments.apposite.com.hk/products.htm and print to pdf while in infopath
- Proposed As Answer by Derek.Wilkes Tuesday, July 05, 2011 11:42 AM