How to add the "print preview" button on a browser form? - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

How to add the "print preview" button on a browser form?

Last post 09-01-2013 02:47 PM by Patrick Halstead. 13 replies.
Page 1 of 1 (14 items)
Sort Posts: Previous Next
  • 04-23-2012 04:37 AM

    • teylyn
    • Top 500 Contributor
    • Joined on 03-29-2012
    • Taranaki, New Zealand
    • Posts 49

    How to add the "print preview" button on a browser form?

    Hello,

    I've done some research before posting this. We're looking at a qRules injected IP form published to a SharePoint forms library. Apparently it is not possible to add the IP Ribbon button for "Print preview" to an InfoPath view onto a browser form.

    Why? What's the big deal? Please help me understand.

    My situation:

    My company's contractors access our SharePoint site and fill in a qRules injected InfoPath form to notify us about work they are going to do on our electricity network. This work will result in a temporary power outage for a number of customers (i.e. people who live in houses and whose power will be cut for a while). The IP form includes a print view that is intended to be, -- well --, printed, so the contractors can print off a couple dozen copies and stick it into the letter boxes of the households affected.

    I've designed an IP form with a few views. On the first view, the contractors fill in the details of the power outage. On the next view, they check the data and submit it to a SharePoint list, using qRules SubmitToSharePointList. That all works fine. qRules rocks. Big time.

    My form does not show the InfoPath ribbon. For a reason. It would confuse the end users who are filling in the form. These are highly specialized guys who put their lives on the line (literally) every day, working on live power lines with 33KV or 11KV. They call that "low" voltage. I have great respect for them. They buzz, literally. But they are not very computer literate. I don't want to make their lives even more complicated. I want to present them with a form that has big, friendly buttons that they can click. Very Douglas Adams, in a way. Don't panic, and all.

    So my form has several views:

    - enter the outage data - street, start time, end time, comments. - review and check for correctness and submit to our company's SharePoint list

    Fine. Then ...

    - click to see a view to print a notice for the householders of the affected street, then just use the print command of the browser to print off a couple dozen copies of the notice.

    The form's Print view has a few buttons to navigate around the form views. UX and all. Very basic. End users, remember? When the print view shows in the browser, the form can be printed from the browser, but the navigation buttons will still show and will print on the paper copies. Ugly. Not desired.

    My research tells me that in order to hide the navigation buttons on the print output, I would need to employ the "print preview" command that is found in the IP ribbon.

    Now, here's the catch: I don't want to show the InfoPath ribbon.

    AT ALL!

    The ribbon will only confuse the guys. If there are icons to click, they will click them before it makes sense. They will get confused. I only want them to see, and be able to click, things that they actually need to see.

    Therefore, I'm hiding the IP ribbon by specifying the form options in InfoPath Designer.

    I need a button/functionality to open the print preview, sans navigation buttons, in a new browser window. The same thing that the IP ribbon "Print preview" does. But I don't want it to be on the ribbon. I need it to be on the form.

    Alternatively, I could just show a view without any buttons but this would have to show in a new window. I've seen posts in this forum that says it's possible to do that, but that this is not encouraged, since there may be a disconnect between several instances of a form and saving data. Thing is, I don't want to save anything with that view. It's read only, meant to be printed only, not saved, so the user won't be able to save data from the print view.

    Thanks for still reading this. :)

    I need either:

    - a functionality of some kind to allow me to add a button to my print view that will render the InfoPath version of a Print Preview (in the same window, but hiding the form buttons), as triggered by the ribbon command, or

    - a functionality to open a view that does not have any nav buttons, but see it in a new browser window, so my guys on the ground can then just print a few copies off the new window and after that, just close it.

    Does that make sense? Is that too much of an ask?

    If this involves code, I'm happy to tackle the learning curve. The form is qRules injected, so it's already and admin-approved form and a few more lines of code won't make a difference. I'd just need to know what these lines would be and how/where to apply them.

    cheers, teylyn

    teylyn - MS MVP (Excel) www.teylyn.com @ingeborgNZ
    Filed under:
  • 04-23-2012 07:33 AM In reply to

    Re: How to add the "print preview" button on a browser form?

    Hi Teylyn!

    One random idea is to use a separate web part below the form and use web part connectors. The second web part shows the separate view, so it doesn't have to be a separate window. You may also be able to get rid of the ribbon by having the InfoPath form display in a content web part, but that may not be of much help.

    I will ask Ernesto and Hilary to see if they have any other ideas.

    More soon,

    Patrick Halstead
    Project Manager at Qdabra
  • 04-23-2012 08:36 AM In reply to

    Re: How to add the "print preview" button on a browser form?

    I found another idea here. Note he mentions something at the end of the thread that was a deal breaker for him - if the form wasn't saved first, his changes didn't show.

    So - you could have something in your form that required submit prior to showing the link - have a secondary data source field called submitted that defaults to false, for example, and set it to true once the form has been submitted - your link could be inside a section you hide unless submitted is equal to true.

    You'd need to submit the form to a form library, if you aren't already, and of course, test thoroughly. In my sample form, I've created a view just for printing - since it opens in a new window / tab, making sure all the fields are read only is going to protect your guys from data loss - they won't be able to change data in the print view of the form. The view they fill out uses the other view for its print view.

    Check out the attached sample - let me know if you have any questions about this approach.

    Hilary Stoupa

  • 04-23-2012 09:57 PM In reply to

    • teylyn
    • Top 500 Contributor
    • Joined on 03-29-2012
    • Taranaki, New Zealand
    • Posts 49

    Re: How to add the "print preview" button on a browser form?

    Thanks Patrick and Hilary for your prompt replies.

    Patrick, I don't present the form in a web part, but as a browser enabled form straight from the forms library. Maybe I'm not getting this and make stupid rookie mistakes?

    Hilary, I had stumbled across that thread during my research and thought the approach did not work for me, because I didn't want to save the form. But then I had another think about it and thanks to your sample I was able to figure out what to do. I'm now saving each form and will use a nightly workflow to remove them from the library.

    Two things:

    Thing 1: My form is an admin-approved qRules injected form. So the SharePointListUrl() resolves to http://siteCollection/site/FormServerTemplates instead of http//siteCollection/site/library -- I've hard-coded the URL for now and it works. Is there a better alternative?

    Thing 2: Ideally I would like to use a button or an image to trigger the print hyperlink. But I find that the hyperlink behaves differently when applied to an image compared to text. I create a hyperlink on an image and select "Data source" with "xdXDocument:get-DOM()/my:myFields/my:Printlink" , but it does not stick. When I edit the hyperlink the "Data source" option is unchecked and the "Address" is checked again. Any ideas?

    By the way, you folks are magic!

    cheers, teylyn

    teylyn - MS MVP (Excel) www.teylyn.com @ingeborgNZ
  • 04-24-2012 08:06 AM In reply to

    Re: How to add the "print preview" button on a browser form?

    As to the SharePointListUrl resolving to FormServerTemplates - I think if you set a library to use the form as a content type and the link used to open it opens from the library, that function will return the library - may be worth a try.

    I like you workflow workaround!

    I'm confused by item two - can you attach a sample form where you are trying this?

    Hilary Stoupa

  • 04-25-2012 04:03 AM In reply to

    • teylyn
    • Top 500 Contributor
    • Joined on 03-29-2012
    • Taranaki, New Zealand
    • Posts 49

    Re: How to add the "print preview" button on a browser form?

    Thanks for your help, Hilary. I really appreciate it.

    As to the SharePointListUrl resolving to FormServerTemplates - I think if you set a library to use the form as a content type and the link used to open it opens from the library, that function will return the library - may be worth a try.

    Sorry, I don't quite get what your're driving at. The form is an admin-approved form. I've uploaded it in Central Admin. I've published it to a site collection. I have added the form as a content type to a library of "MyFlippingBrilliantSite". But the SharePointListUrl() still resolves to FormServerTemplates, not the library name. What am I doing wrong?

    I'm confused by item two - can you attach a sample form where you are trying this?
    I'm attaching an xsn file. There is a hyperlink on a piece of text showing as "Print". The hyperlink is set use "Data source" and the value is "xdXDocument:get-DOM()/my:myFields/my:Printlink".

    There is also an image in the form. I am trying to apply the same hyperlink functionality to the image. So I right-click the image and select "Edit Hyperlink". I select "Data source" and enter "xdXDocument:get-DOM()/my:myFields/my:Printlink" into the box and hit OK. But when I right-click the image again and select "Edit Hyperlink", the "Data source" option is no longer selected. Instead, the "Address" option is selected, with a value of "http://address" in the box. Also, when I publish the form (and spend the next ten minutes admin-approving it in our slow DEV environment), the image links to "http://address" and not to "xdXDocument:get-DOM()/my:myFields/my:Printlink"

    Am I breaking new ground here? Or is something wrong with my setup?

    cheers, teylyn

    teylyn - MS MVP (Excel) www.teylyn.com @ingeborgNZ
  • 04-25-2012 05:33 PM In reply to

    Re: How to add the "print preview" button on a browser form?

    So, when I look at the view for your form in a text editor, I see something quite different from when I do the same thing in my form. Something is up with the form itself.

    I manually changed your form's XSL to match mine. In yours, the XSL looked like this:

                   <a href="http://address">
                    <font size="2" face="Calibri">
                     <img style="BORDER-BOTTOM: #0000ff 1.5pt; BORDER-LEFT: #0000ff 1.5pt; WIDTH: 48px; HEIGHT: 48px; BORDER-TOP: #0000ff 1.5pt; BORDER-RIGHT: #0000ff 1.5pt" src="E7890C83.png"/>
                    </font>
                   </a>

    In mine, it looked like this:

              <a class="xdDataBindingUI" xd:disableEditing="yes">
               <xsl:attribute name="href">
                <xsl:value-of select="my:field1"/>
               </xsl:attribute>
               <img style="WIDTH: 317px; HEIGHT: 306px" src="2C9A773F.jpg"/>
              </a>

    I manually changed your view to use the same XSL as mine did - I've attached the template with that change. It appears to be "sticking" - I added a field to your main data source, as I would expect to have some kind of failure if you selected data source but pasted in an XPath to a node that doesn't actually exist in your form, as your outline of your steps above indicates you did.

    As to the SharePointListUrl - the time I tried that must have been w/ a sandboxed form not admin approved! With admin approval, I get the same results as you do. qRules has 'GetInputParameter' though... and your form link should include the library as the Source. When I tried this, the Source was the path to the library the template was opened from (not FormServerTemplates). It is the full path - you could use substring-before to get everything before "/Forms/AllItems.aspx" and set a field to that to store your library name. The command I used was:

    GetInputParameter /key=Source

    Hope this helps!

    Hilary Stoupa

  • 04-25-2012 06:21 PM In reply to

    • teylyn
    • Top 500 Contributor
    • Joined on 03-29-2012
    • Taranaki, New Zealand
    • Posts 49

    Re: How to add the "print preview" button on a browser form?

    >> when I look at the view for your form in a text editor

    How can I do this? I tried to opened the xsn with Notepad++ but that does not work.

    teylyn - MS MVP (Excel) www.teylyn.com @ingeborgNZ
  • 04-25-2012 07:19 PM In reply to

    Re: How to add the "print preview" button on a browser form?

    Oh, sorry - you can save the form as source file - under Publish for IP 2010, under the File menu for IP 2007. In your source files, you are looking for your .xsl files - those are your views. To pack it back up, right click on manifest.xsf and select Design - then File > Save As to get it back to an XSN.

    Hilary Stoupa

  • 04-26-2012 03:10 AM In reply to

    • teylyn
    • Top 500 Contributor
    • Joined on 03-29-2012
    • Taranaki, New Zealand
    • Posts 49

    Re: How to add the "print preview" button on a browser form?

    Hello Hilary,

    I am being way-layed by things my employer considers more urgent, but I have a few questions and will post them as soon as I come up for air. Thank you for your explanations so far. They've been really helpful.

    I've been thrown in the InfoPath pool before I could swim, so I have a few knowledge gaps that need to be filled. I will try not to pester you with the most essential of RTFM questions. Then again, I can see some quite different behaviour comparing your form and mine. Maybe my form has become corrupt. Does that happen with xsn files? Details later.

    teylyn - MS MVP (Excel) www.teylyn.com @ingeborgNZ
  • 04-29-2012 09:20 PM In reply to

    • teylyn
    • Top 500 Contributor
    • Joined on 03-29-2012
    • Taranaki, New Zealand
    • Posts 49

    Re: How to add the "print preview" button on a browser form?

    Hello,

    I'd like to explore the image link a bit more. I don't quite understand why a link to a data source would look so different in your form than in mine. I'm obviously missing something. Here are my steps:

    • create a new, blank form with File > New > Blank Form > Design Form
    • Add a group with three fields.
    • Insert an image and add a hyperlink to one of the text fileds. It does not stick.
    • Insert some text and add a hyperlink to one of the text fields. Now, that does not stick either

    I'm totally confused now. Do I have wrong expectations? What am I missing?

    cheers,

     

    teylyn - MS MVP (Excel) www.teylyn.com @ingeborgNZ
  • 04-30-2012 08:38 AM In reply to

    Re: How to add the "print preview" button on a browser form?

    Are you selecting the field using the field picker? Is your Office install up-to-date (patched, service packs installed)?

    Hilary Stoupa

  • 08-28-2013 08:54 AM In reply to

    Re: How to add the "print preview" button on a browser form?

    This is probably too little late, but maybe it'll help someone else who looks to this in the future.  I use this to add a print button to my forms.  Works perfectly.

  • 09-01-2013 02:47 PM In reply to

    Re: How to add the "print preview" button on a browser form?

    Excellent. Thanks for posting that! :)

    Patrick Halstead
    Project Manager at Qdabra
Page 1 of 1 (14 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.