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
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 ?
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.
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>
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.
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")
"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