PDF file closing

Hi. I have links to pdf files in my hype document. When I’m running my hype document and I go to the pdf file, there is no way to close the pdf window and come back to where I was in the document. I have to start the animation from the start again. Is there a way when can consult a pdf and come back where I was in my hype document? Also, is it possible to include pdf in my file so the person calling the pdf from my application would not have to be connected to internet?

Perhaps a good way would be to open the PDF in a new window. I assume you're viewing this in a browser? you need to do something like

window.open('${resourcesFolderName}/path-to-PDF-file.pdf', '_blank'); /// blank is to open in a new window

Again if you are using a browser you can still do the above. The resources path will update accordingly. As to regards to putting it in the document (embedding) you can probably use a library and embed it in a HTML widget for someone to read.

If you give us some more information then perhaps we can tailor a solution for you

Thanks dbear. The hype file is going to be transformed into an app

And where would I put this code? Im a graphic designer not a programmer.

Hi Marts,

I appreciate you’re a graphic designer but if you are using Hype maybe you should familiarise yourself with how to use functions within Hype :smile: Of course this doesn’t help with writing code. :smile:

Here is a quick tutorial for you.

What I am doing here is using a Hype button to call the function that sends the user to the PDF in a new window. You can adapt it for whatever you are using to go to the PDF.

• Create button element in Hype
• In Actions inspector - click plus sign next to On Mouse Click. Choose Run Javascript… from Action dropdown menu followed by New Function… from function drop down menu.
• In the screen that now opens place the following code

window.open('${resourcesFolderName}/path-to-your.pdf', '_blank');

Don’t forget to put your filename where it says “path-to-your.pdf”

• You can rename your function by replacing untitledFunction
• Before we can read this PDF we have to uncheck a few boxes in the resources Panel

At the bottom of this panel (tab) you will see the following.

Uncheck the two boxes - Preload and Automatically optimize when exporting

Now you should have a button that when pressed opens a new window with your PDF

Here is a template for you to look at.

openPDF-in-new-window.zip (337.0 KB)

Hello DBear. I know how to work with the function. The question I have for you is where do I put the actual pdf file to call it? Do I put it manually in the ressource folder?

Hi again. Everything is working now but the problem is that I cant close my window and continue where I was in my Hype document. As soon as I call for a pdf there no x sign to close it, I must restart the app. Can you help with that?

I’ll have to look at a Hype document to help with that. You are mentioning an app. So i’m a bit unclear as to your set up. How are you viewing this app?

Thru an iPad. When I look at it thru Hype reflect or thru the html5 i transformed to an ap, there is no way to close the pdf and come back to where I was in the hype document, I have to start from the start all over again.