Web Connection
View PDF in new browser tab
Gravatar is a globally recognized avatar based on your email address. View PDF in new browser tab
  Stein Goering
  All
  Jan 30, 2018 @ 10:46pm

I'm using XFRX to run VFP reports out of my web app, directing the output to a PDF. (BTW, the wwXFRX classes make this a snap to implement.) I then display the results using:

Response.redirect(lcPDFPath)

This works fine, but it opens the PDF in the current browser tab. Ideally I'd like to leave the original portal page open and have the PDF open in a new tab. Is there an easy way to accomplish that?

--stein

Gravatar is a globally recognized avatar based on your email address. re: View PDF in new browser tab
  FoxInCloud Support - Thierry N.
  Stein Goering
  Jan 31, 2018 @ 03:41am

In FoxInCloud we use JS:

var form = jQuery('<form/>', {action:URL, method:'get', target:(['txt','csv','pdf'].indexOf(URL.substr(URL.lastIndexOf('.')+1).toLowerCase()) > -1 ? '_blank':'')});
form.append(jQuery('<input/>', {type:'hidden', value:'void'})); // submit() marche seulement si quelque chose est à envoyer
jQuery(document.body).append(form);
form.submit().remove(); // sends request - ajouter un try-catch pour éviter les erreurs de pop-up ?
Gravatar is a globally recognized avatar based on your email address. re: View PDF in new browser tab
  Harvey Mushman
  Stein Goering
  Jan 31, 2018 @ 06:14am

I see in your second post something about target and txt,csv,pdf and then some additional JS that has _blank which if you were writing this in HTML would spawn a new tab.

So my guess is something about your JS is not firing correctly.

Gravatar is a globally recognized avatar based on your email address. re: View PDF in new browser tab
  Michael Hogan (Ideate Hosting)
  Stein Goering
  Jan 31, 2018 @ 07:24am

A common question. Whatever link or button you use in the CALLING PAGE to launch your report should open in a new window or tab such as:

<a href="DocView.wc?DocCode={listcode}" target="_blank">Open Report</a>
Gravatar is a globally recognized avatar based on your email address. re: View PDF in new browser tab
  Rick Strahl
  Stein Goering
  Jan 31, 2018 @ 12:02pm

With a redirect you can't change the output target after you've sent the link. But there is another easy solution.

Simple: Open the link or form that you want to display the PDF with a new target="PdfViewer" name tag:

<a href="generatedPdf.wcapp" target="PdfViewer">Generate Report</a>

<!--- OR --->
<form action="generatePdf.wcapp" target="PdfViewer" method="POST">
...
</form>

The only problem with this is if you have some sort of problem with the request the error message will also end up on the remote target.

Gravatar is a globally recognized avatar based on your email address. re: View PDF in new browser tab
  Luca
  Rick Strahl
  Feb 1, 2018 @ 07:38am

I put a link in webpage:

<ww:wwWebHyperLink ID="lblLink" runat="server" ControlSource="" Target="_blank" Visible="False">PDF</ww:wwWebHyperLink>

Printing procedure creates PDF file then returns name for link:

WITH .lblLink
    .NavigateUrl="PdfPage.wc?Pdf="+m.TempFile
    .Visible=.T.
ENDWITH 

OnLoad() of PdfPage:

Response.TransmitFile(Process.oConfig.cTemp+.cPdf+".pdf","application/pdf")

Gravatar is a globally recognized avatar based on your email address. re: View PDF in new browser tab
  Stein Goering
  Harvey Mushman
  Feb 1, 2018 @ 12:20pm

"I see in your second post something about target ..."

Harvey, That was Thierry's post, in response to mine. I haven't tried it yet but I'm sure the javascript he provided works fine.

--stein

Gravatar is a globally recognized avatar based on your email address. re: View PDF in new browser tab
  Stein Goering
  Stein Goering
  Feb 1, 2018 @ 12:24pm

Thanks to everyone who responded. It looks like I've got plenty of options...

© 1996-2024