locked
InfoPath 2007 with SharePoint Server 2007 Convert forms to TIFF or PDF to TIFF RRS feed

  • Question

  • Hi There Forum of Awesomeness,

    I had hoped to find advice on saving my InfoPath 2007 forms to TIFF or convert the exported PDFs to TIFF.

    See, a nice and easy one... right?

    Jeff

    Tuesday, October 25, 2011 7:06 PM

Answers

  • Thanks - you never know, maybe you'll teach me something in InfoPath I don't know yet... there is always more to learn  :-)

    In the default value of your timestamp field (make sure the datatype is set to "Text (string)") add the following formula:

    translate(., "-/,;:", "")     <---- the . represents the current node - so insert the timestamp field there

    Steps:

    • Click "fx" next to the default value box
    • Insert function
    • Select Text category > Translate
    • For the first "Insert Field or group" click and select timestamp
    • For the second "Insert Field or Group" delete that and replace with "-/,;:"
    • For the third "Insert Field or Group" delete that and replace with ""
    • Click Ok & Test

    For unique filenames I use the SharePoint library ID - but it sounds like your not saving the InfoPath form to a SharePoint library, are you?

    Luna will be happy once she's shed the weight and can play like a kitten again  :)

    • Marked as answer by super8jeff Wednesday, October 26, 2011 4:09 PM
    Wednesday, October 26, 2011 3:22 PM

All replies

  • Hi Jeff,

    I haven't used this myself, but check out this post - it looks promising:

    http://rhostetter.blogspot.com/2004/09/infopath-fun.html

    Melissa

    Tuesday, October 25, 2011 8:39 PM
  • Wow Melissa, just when I think I am all alone, there you are.  Thank you. 

    Yeah, I am behind the military's firewall and can't reach that site but when I get home, I'll feed my cat and check it out.

    Could ask you a favor?  That code:

    Dim filename As String
                Dim nameNode As XPathNavigator
                nameNode = MainDataSource.CreateNavigator.SelectSingleNode("/dfs:myFields/dfs:dataFields/SOLDIER_DATA/@NAME_", NamespaceManager)
                filename = nameNode.Value + ".pdf"
                Me.CurrentView.Export("\\SAN\shared\15YR_LTR_" + filename, ExportFormat.Pdf)

    Well it works great but now I have been asked to slip a time stamp on the saved .pdf for the occassion when @NAME will be the same. 

    Any thoughts?  And thanks again.

    Tuesday, October 25, 2011 8:52 PM
  • As far as adding a timestamp - that shouldn't be a problem.  Is this code on a button?  If so -  you can add a new field to your maindatasource, called timestamp.  Then, add a rule to the button that sets the timestamp field to now().<p>Then, adjust your code to the following:</p>
    
                 Dim filename As String
                 Dim nameNode As XPathNavigator
                 nameNode = MainDataSource.CreateNavigator.SelectSingleNode("/dfs:myFields/dfs:dataFields/SOLDIER_DATA/@NAME_", NamespaceManager)
                 Dim timestamp As String
                 Dim tsNode As XPathNavigator
                 tsNode = MainDataSource.CreateNavigator.SelectSingleNode("/my:myFields/my:timestamp", NamespaceManager)
                 filename = nameNode.Value + tsNode.Value + ".pdf"
                 Me.CurrentView.Export("\\SAN\shared\15YR_LTR_" + filename, ExportFormat.Pdf)
    


    For the timestamp field, copy the xpath just as you did yesterday but for the new timestamp field now.  Replace the /my:myFields/my:timestamp in the code above with the copied xpath.

    Did you check out the link I sent you yesterday?  Is your cat well-fed now?  :-)

    Wednesday, October 26, 2011 12:27 PM
  • Melissa,

      You are the best hopefully one day you'll need help with something I am good at (yet completely unknown) so that I can reciprocate the favor.

      This code is going to work I just have to find a way to strip the foriegn characters (:,/ like 11:20 or 10/26/2011)

    it doesn't like my path when I have those characters so if I can find the fx: to add to my timestamp textbox to remove them and replaceit with a format like 110610262011 then I think it will work. 

    After reading what I just wrote... Am I retarded?  Is there a smarted way to create unique names or give users an option to overwrite existing files or Save as something unique?

    P.S  - Luna the cat is 33 lbs.  I had to put her on "diet" cat food...she hates me right now.  

    Wednesday, October 26, 2011 3:08 PM
  • Thanks - you never know, maybe you'll teach me something in InfoPath I don't know yet... there is always more to learn  :-)

    In the default value of your timestamp field (make sure the datatype is set to "Text (string)") add the following formula:

    translate(., "-/,;:", "")     <---- the . represents the current node - so insert the timestamp field there

    Steps:

    • Click "fx" next to the default value box
    • Insert function
    • Select Text category > Translate
    • For the first "Insert Field or group" click and select timestamp
    • For the second "Insert Field or Group" delete that and replace with "-/,;:"
    • For the third "Insert Field or Group" delete that and replace with ""
    • Click Ok & Test

    For unique filenames I use the SharePoint library ID - but it sounds like your not saving the InfoPath form to a SharePoint library, are you?

    Luna will be happy once she's shed the weight and can play like a kitten again  :)

    • Marked as answer by super8jeff Wednesday, October 26, 2011 4:09 PM
    Wednesday, October 26, 2011 3:22 PM
  • Hello Melissa,

      So, that works fabulously, except I have to put the Rule to add now() to timestamp in another button as an error "You NOOBIE! Have exceeded the number of rules for this event"...  Or something to that effect. 

    After I started down this path of saving pdfs on a shared drive I received the access to the SharePoint server so now I am going to try the SharePoint library ID.  I did create a submit button to my SharePoint data connection which works (except I can't save the different forms in subfolders, I assume because the subfolders are not Data Connection Libraries) but I haven't tried the convert to .PDF portion yet.  It should be the same code except for data connection instead of the local \\SAN\shared path.

      How hard can it be?? ~!:{)  That is my weak attempt at a nervous emoticon.

    Anyway, you are selflessly terrific.  The world would be a better place if there were more Melissa Rentons around.

    I have alot to learn, thanks for your time and patience.

     

    Wednesday, October 26, 2011 4:07 PM
  • Ohh I just love the "exceeded rule limit".  I still run into that sometimes and have to do workarounds.  You may be able to get away with putting the now() function in the default value.  So now your default value would be:

    translate(now(), "-/,;:", "")

    You should be able to save in subfolders - you would need to make a dynamic field to get your submit location.  For example, maybe project is a selection in the form and there are project subfolders.  You would have a submitFldr field in the main datasource that would: 

    concat(http://server/site/subsite/formLibrary/, submitFldr)

    Your emoticon looks like it's drinking some java and has a moustache by the way  :)  I'm no good at those things either. 

    Wednesday, October 26, 2011 6:02 PM
  • Hello Melissa!

      Umm...  so I am converting these documents to InfoPath forms.  They query data from a SQL database.  So I have textboxes binded to the Receive SQL data connection that fill when I put in the soldier's SSN.  I have a "Print Preview" Button, a "Save As PDF" button and a "Submit to SharePoint" button.  They all work sorta; 1. I hit the print preview button and the user has to CTRL P to print (it's not autoprint and I haven't figured out how to do that).  2.  The Save As PDF saves to the local share (YAY FOR MELISSA!!!!) but now I wonder how to save it to the SharePoint Site.  3. The Submit To SharePoint function saves it to a document library but will not save to the (ex: 15YR_Letter) subfolder.  

      It would will be cool to be able to save them to that subfolder that way all the forms in there are 15YE letters.  SO....  You are saying for that part I need to create a dropdown menu that has 15YR_Letter in it and when chosen it completes a textbox with concat(http://mysharepointserver/myDataConnectionLibrary/, subfolder_15YR_Letters.

    Oh my...  I feel like I am taking too much of your time but I can't express how much I appreciate your help. 

    Wednesday, October 26, 2011 8:30 PM
  • Haha - that's quite allright, I enjoy helping others.  Especially when they're nice about it (you'd be surprised how nasty some people get - it's like they think they're paying top dollar for your input when it's really free).

    We don't necessarily need a dropdown to set the value of the subfolder - what exactly is the meaning behind the nomenclature for the folders?  It's possible that the value in the folder is already selected somewhere within your form - i.e. if you're having the user select or enter how many years then we already have the number and the formula would be:

    ..... wait a second... I just noticed something.  Are you trying to have the pdf's save to a data connection library?  The data connection library is intended to be used for, well, data connections.  These are typically .udcx files that contain information for other applications (such as infopath) to know how to connect to a datasource.  Not for storing physical documents.  What you want is a document library.  Ok back to the formula:

    concat(http://mysharepoint/server/myDocumentLibrary/, "subfolder_", userEnteredYearField, "YR_Letters")

    Also, one thing I'd like to suggest (or HIGHLY suggest) is instead of using direct SQL data connections if you could create a web service to query / submit the data to SQL.  It's way more flexible, it's browser-compatible (if you have InfoPath Forms Services), and it's faster.

    Wednesday, October 26, 2011 8:53 PM
  • Hey there Melissa,

      WOW!  This is getting exciting! (How lame am I?) 

    So I could use this with a data source to direct which Form Library the form gets submitted.  Uhmmmm...  So, if I have a data source that auto-fills a textbox (I'll call... UNIT textbox) when the SSN is queried that indicates which Department the soldier is in and then make rules in the submit button like if UNIT = INFANTRY then

    concat(http://mysharepoint/server/myINFANTRY_FORM Library/, "subfolder_15YR_Letters", UNIT texbox, "filename") ?????

    I'm going to start having InfoPath nightmares.  Thank you for being there.

    Thursday, October 27, 2011 4:10 PM
  • Haha - I think all of us "techy" people get oddly excited about this stuff - and we get those weird looks from those who just don't understand  :-)

    Yep - exactly.  You can autoset a lot of information using external datasources.  One tip - don't put it all on the submit button.  And don't set everything to automatically query the datasource when the form is opened.  That will just put a heavy load.  Instead, do it incrementally to the best you can.  Some stuff will need to be automatically queried at time of form opening - but not all of them.

    For instance... say in your form your user is entering their SSN.  You would put a rule on the SSN field that would set the query field for SSN of the external datasource to the SSN the user just entered, then an action to query that datasource, then an action to set the department that was returned by the query.

    Depending how many units you have - you may want to make your own table, or xml datasource that contains the UNIT = Folder data.  That way, if you have 100 units you won't need 100 condtional rules.  You would be able to query that data as well and then just simply set the value.

    The nightmares just may turn into great ideas - keep a pad of paper by your bed just in case :-)

    Thursday, October 27, 2011 5:43 PM
  • I see some interesting answers to your question, excellent stuff. 

    Another approach you can consider, to bypass the whole signing business, is to convert the form to PDF and then use a free tool such as Ghostscript to convert PDF to TIFF.

    To automatically convert InfoPath to PDF see:

     

    To convert PDF to TIFF see this link.

    A future version of the PDF Converter  will support direct TIFF output.

    Please note that I worked on this product so the usual disclaimers apply.

    Tuesday, November 1, 2011 10:22 AM
  • Melissa!?!??

     

      Well in case you our another that might be half as smart as you could help me again?  Pretty Please. 

    SO...  ...nameNode = MainDataSource.CreateNavigator.SelectSingleNode("/dfs:myFields/my:ID", NamespaceManager)
                filename = nameNode.Value + ".pdf"
                CurrentView.Export("\\SAN\_" + filename, ExportFormat.pdf)

    This works great!! It even saves as .xml ! Which is cool.  Now I'd like to use the same button to export a different view. 

    LIKE

    filename = nameNode.Value + ".pdf"
                CurrentView.Export("\\SAN\_" + filename, ExportFormat.pdf)LIKE

    and the under that I could use

     filename = nameNode.Value + ".xml"
                NameOfOtherView.Export("\\SAN\_" + filename, ExportFormat.xps) ????

     

      Thanks!!

      Jeff

    Wednesday, November 16, 2011 7:29 PM
  • Hi Jeff!

    Well - I thought it would be as simple as saying "now export this view, too" but unfortunately I have not found it to be that simple.  What I had to do is this:

    Add a new hidden field to my form, call it "viewSwitch"
    Add a rule to the export button to set the viewSwitch field's value to "1"
    Add this line to the bottom of the programming for the button to switch the view (but you can't export it here - InfoPath doesn't like that):

    Me.ViewInfos.SwitchView("View2")
    


    Of course replace the View2 with the name of the other view you want to export.  Now, add programming to the changed event of the viewSwitch field:

     Dim filename As String
                Dim nameNode As XPathNavigator
                nameNode = MainDataSource.CreateNavigator.SelectSingleNode("/my:myFields/my:field1", NamespaceManager)
                Dim tsNode As XPathNavigator
                tsNode = MainDataSource.CreateNavigator.SelectSingleNode("/my:myFields/my:field2", NamespaceManager)
                filename = nameNode.Value + ".pdf"
                Me.CurrentView.Export("C:\Users\rentonm\Documents\InfoPath Projects\TestExport\exports\" + filename, ExportFormat.Pdf)
    

     (same as the code on the export button except different filename - make sure to make those unique so they don't override eachother).

    I hope that helps!  Kind of a silly approach, but that's all I could come up with after hitting roadblocks using other routes.

     

    Monday, November 28, 2011 5:28 PM
  • Melissa,

      I thought I had lost you!  It is amazing how selfless you are to spend so much time helping the dazed and confused like me.  I really do appreciate your time and kind-heartedness. 

      I am continuously refining my InfoPath skills, maybe one day I will know something that can help someone and maybe one day I can reciprocate the favors.

      Thank you, Thank you, Thank you...   Now, I am off to try the SwitchVeiw!  See you on the other side.

    Oh by the way...  my fat cat has a new sister... 8 week old boxer!

    Tuesday, December 6, 2011 6:26 PM
  • Hi Jeff,

    I'm sure some day you'll get there  :)  I started off as a silent forum lurker myself. 

    How does Luna like her new sister?  Dogs are fun - sometimes I wish they would be just as independent as cats.  I have one dog, two cats, and a bunny rabbit.  Talk about a funny farm. 

    Let me know if you need any help implementing the switchView method.

    Melissa

    Tuesday, December 6, 2011 6:59 PM