akjal

Hi,

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...



Re: Visual C# General How to convert an infopath file pdf

micvos

Of 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.




Re: Visual C# General How to convert an infopath file pdf

akjal

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...

akjal





Re: Visual C# General How to convert an infopath file pdf

micvos

Now 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.




Re: Visual C# General How to convert an infopath file pdf

akjal

Hi

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.

Thanks,





Re: Visual C# General How to convert an infopath file pdf

coolmadhan123

Hi

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

http://www.microsoft.com/downloads/details.aspx familyid=4D951911-3E7E-4AE6-B059-A2E79ED87041&displaylang=en

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.

using Microsoft.Office.InfoPath;

using Microsoft.Office.InfoPath.FormControl

// file refers the source file path

// finalFilename is the destination file path

FormControl1.Open(file);
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

XPS Microsoft.Office.InfoPath.ExportFormat.Xps

MHT Microsoft.Office.InfoPath.ExportFormat.Xps





Re: Visual C# General How to convert an infopath file pdf

mikedopp

coolmadhan123,

can you explain the form control better Thanks. Still working hard on how to do this in infopath 2007.

thanks in advance.

mike






Re: Visual C# General How to convert an infopath file pdf

coolmadhan123

Hi Mikedopp,

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.

Programmatic Approach

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

Thanks

coolmadhan123





Re: Visual C# General How to convert an infopath file pdf

Carolyn

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.





Re: Visual C# General How to convert an infopath file pdf

mikedopp

So 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.

Mike





Re: Visual C# General How to convert an infopath file pdf

mikedopp

Thank 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.
Thanks again.
Mike





Re: Visual C# General How to convert an infopath file pdf

mikedopp

Ok 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.
{
XDocument.View.Export("C:\\MyView.pdf", "PDF");
}

More at
http://mikedopp.com





Re: Visual C# General How to convert an infopath file pdf

Moss_Sharepoint

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

Any Ideas