Hide form after creating PDF

Post any questions you have about using the Verj.io Studio, including client and server-side programming with Javascript or FPL, and integration with databases, web services etc.

Moderators: Jon, Steve, Ian, Dave

Segi
Ebase User
Posts: 649
Joined: Mon Dec 09, 2013 6:37 pm

Hide form after creating PDF

#1

Postby Segi » Mon Oct 13, 2014 3:04 pm

I've created a few forms that act as a report. All of my report forms display in a popup window (The parent form calls window.open with the URL to my form). In the before page event for each report, I call form.generatePdf to immediately display a PDF based on the current form.

There is a small side effect that I'd like to fix. The form window remains open and has to be manually closed by the user. What I'd like to do is hide the form window as soon as the PDF popup has been generated so they can save/print the report and then close it. Is there a way to trigger an event after form.generatePdf has successfully executed ?
0 x

Jon
Moderator
Moderator
Posts: 1342
Joined: Wed Sep 12, 2007 12:49 pm

#2

Postby Jon » Tue Oct 14, 2014 6:46 am

Seems a bit complicated to me, generatePdf() will display the PDF in a popup window anyway without the need for you to do it yourself.

But to answer your question, you can close the form popup window immediately after the generatePdf() like this, but I'm not sure what this will do to the PDF display - it might never appear.

Set up a new page on your popup form - say P2 - and set the Html++ in page properties to contain Javascript to close the window - exactly what this is depends on how you have launched the popup in the first place. Then add form.gotoPage(pages.P2) after the generatePdf();

This is an example of closing a popup window launched via a jquery dialog (anchored to a div with id popup).

Html++:

Code: Select all

<script type="text/javascript" language="javascript"><!-- 
  window.parent.closePopup&#40;&#41;;
 --></script>
Function closePopup on the original form:

Client Javascript:

Code: Select all

function closePopup&#40;&#41;
&#123;
  var div =$&#40;'#popup'&#41;;
  div.dialog&#40;"destroy"&#41;;
  div.css&#40;"display", "none"&#41;;
  div.empty&#40;&#41;;
&#125;
0 x

Segi
Ebase User
Posts: 649
Joined: Mon Dec 09, 2013 6:37 pm

#3

Postby Segi » Wed Oct 15, 2014 4:48 pm

Jon,

I resolved this issue and your post made me realize that I have to display the PDF in a different way than how I was trying to accomplish this. I had each report contained in its own separate form. What I did is move the page from each reports' form to the parent form that needs to call it. After that generatePdf() is able to display the page without me having to worry about unnecessary form windows popping up
0 x


Who is online

Users browsing this forum: No registered users and 21 guests