Web Connection
Client Side Printing 101
Gravatar is a globally recognized avatar based on your email address. Client Side Printing 101
  Rod
  All
  May 24, 2017 @ 11:06am

Hi Rick and everyone, So I have my FoxPro/Web Connection app running, using only the base classes. Now I want to give the client a way to print a report. I thought I had the answer using goURL() to launch a PDF I generated to a location on the site, but that just loads the PDF locally to the server. That looked like a perfect solution as my app stayed in one tab of my browser while the PDF loaded in a separate Tab. Is there anything comparable that I can provide to the client? Or what is the standard practice for providing the client a printing facility? I can't seem to find it here or in the docs. Thanks, Rod

Gravatar is a globally recognized avatar based on your email address. re: Client Side Printing 101
  Rick Strahl
  Rod
  May 24, 2017 @ 12:18pm

Not sure what you mean.

You can serve a PDF file over HTTP to the client. Just link to an HTTP resource (file on disk) or dynamically have your Web Connection app serve the PDF file to the client.

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: Client Side Printing 101
  Rod
  Rick Strahl
  May 24, 2017 @ 12:44pm

Yes, I can use PrintToString to serve it to the client, which formats the page like a PDF file. I guess I was looking for a way, or a best practice workflow, to get the user back to the app without having to use the browser back button. goURL was nice because it opened in a separate page. I suppose I could embed a "back" link in the PDF, but that would be in the print out as well.

Gravatar is a globally recognized avatar based on your email address. re: Client Side Printing 101
  Rick Strahl
  Rod
  May 24, 2017 @ 01:39pm

You can still do that.

Use a link to point at the pdf file and use a target="pdfpage" attribute to open the link in a new page:

<a href="CreatePdf.wwd" target="_blank">View Report</a>

You can do the same with a <form> tag:

<form action="submitform.wwd" method="post" target="_blank">

although I would not recommend the latter, as that means all output goes to the second window. If you validate your form and the form needs fixes you really don't want output to go to a secondary window.

Ideally, in that scenario you create your PDF file as a file on disk in your site hierarchy (ie. /temp/generated-xxdadasdx.pdf) and then link to that file when the form has been submitted successfully.

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: Client Side Printing 101
  Rod
  Rick Strahl
  May 24, 2017 @ 02:24pm

Thanks! That gives me a few ideas to play with.

Gravatar is a globally recognized avatar based on your email address. re: Client Side Printing 101
  Rod
  Rick Strahl
  May 26, 2017 @ 05:58am

Sorry, Rick. I'm still going around in circles on this. I'm not sure what your reference to target="pdfpage" means, as that's not a valid target parameter as far as I can see. So not entirely sure what you were driving at.

I want the user to click a button (or link) on my "Page A" to:

  1. render the PDF report to disk (handled by my VFP function)
  2. open the PDF in a new tab/page on the browser, or some other way that gives the user a clear path back to "Page A".

goURL() allowed me to do this (locally) by calling that function at the end of the rendering function. I'd rather not have them click twice, (on a button and then a link)

The only solution I can think of is to always generate the PDF file to disk in advance when "Page A" loads, whether they want the report or not. Then I could just put a link to send it to target="_blank" if they want to print it. But that seems like unnecessary overhead, plus I may add functionality that does more than just render the report (it's an invoice).

So I'm wondering if I missed something in your response. Looking for a client side version of goURL().

Rod

Gravatar is a globally recognized avatar based on your email address. re: Client Side Printing 101
  Rick Strahl
  Rod
  May 26, 2017 @ 07:29pm

target forces the browser into a new window. You can name it whatever you want - it'll be a new window name.

Typically _blank is used for a new window. Any other arbitrary name creates a new window/tab with the name you specify.

+++ Rick ---

© 1996-2024