Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Tue Jun 19, 2018 9:17 pm
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 16 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Show a PDF-file
PostPosted: Fri Feb 17, 2012 5:33 am 
Offline

Joined: Wed Dec 05, 2007 5:17 am
Posts: 503
Location: Sweden
I am trying to show a PDF-file in a HTMLViewer with is't URLPath. No luck. I can't either launch a folderitem to the PDF-file - not supported. Suggestions?

_________________
iMac 27" i7, Macbook 13.3,Macbook PRO 15, Mac mini, iPhone 4s & REALStudio...
http://www.precis-it.se


Top
 Profile  
Reply with quote  
 Post subject: Re: Show a PDF-file
PostPosted: Fri Feb 17, 2012 6:16 am 
Offline
User avatar

Joined: Tue Jan 04, 2011 3:02 am
Posts: 1236
Location: Jönköping, Sweden
You have to create a WebFile to the PDF and then point the WebHTMLViewer to the URL of the WebFile. If you want the user to download the PDF you set the WebFiles ForeDownload property to true :)

_________________
Image http://www.linkedin.com/in/albinkiland
Dev. iMac 27" + 2x22" LG (2.8GHz Intel Core i7, 12GB RAM, 120GB SSD) OS X 10.8
Xojo Pro 2013r1


Top
 Profile  
Reply with quote  
 Post subject: Re: Show a PDF-file
PostPosted: Fri Feb 17, 2012 6:40 am 
Offline

Joined: Wed Dec 05, 2007 5:17 am
Posts: 503
Location: Sweden
Thanks! But HTMLviewer can't find the downloaded file.. It feels like I ought to put the
HTMLViewer1.URL=filtemp.URL in a downloaded event but I don't have such event.
dim f as FolderItem
dim filtemp as new WebFile

f=GetFolderItem("/Users/projekt/projekt01/media/"+LbBilder.Cell(row,0), FolderItem.PathTypeShell)
filtemp=WebFile.Open(f)
filtemp.ForceDownload=true

HTMLViewer1.URL=filtemp.URL

_________________
iMac 27" i7, Macbook 13.3,Macbook PRO 15, Mac mini, iPhone 4s & REALStudio...
http://www.precis-it.se


Top
 Profile  
Reply with quote  
 Post subject: Re: Show a PDF-file
PostPosted: Fri Feb 17, 2012 6:52 am 
Offline
User avatar

Joined: Tue Jan 04, 2011 3:02 am
Posts: 1236
Location: Jönköping, Sweden
Try putting the WebFile as a Session property, I think it might die to soon otherwise.
And set ForceDownload=false if you want to show the PDF in the HTMLViewer. :)

_________________
Image http://www.linkedin.com/in/albinkiland
Dev. iMac 27" + 2x22" LG (2.8GHz Intel Core i7, 12GB RAM, 120GB SSD) OS X 10.8
Xojo Pro 2013r1


Top
 Profile  
Reply with quote  
 Post subject: Re: Show a PDF-file
PostPosted: Fri Feb 17, 2012 7:02 am 
Offline

Joined: Wed Dec 05, 2007 5:17 am
Posts: 503
Location: Sweden
I have put the var as a session var and I get an URL:
/3B02A6BAC680D3610EE33B3540FD3236/files/%7B9746-6817-2337-8958-0325%7D/fil.pdf

but the file don't exist?

_________________
iMac 27" i7, Macbook 13.3,Macbook PRO 15, Mac mini, iPhone 4s & REALStudio...
http://www.precis-it.se


Top
 Profile  
Reply with quote  
 Post subject: Re: Show a PDF-file
PostPosted: Fri Feb 17, 2012 8:07 am 
Offline
User avatar

Joined: Tue Jan 04, 2011 3:02 am
Posts: 1236
Location: Jönköping, Sweden
Here's a code snippet of what I have that works here :)

Dim PDFfile as FolderItem
PDFfile = GetFolderItem("uploads").Child("invoice").Child(mainPage.editOrderDialog1.orderID.text).Child(me.cell(me.ListIndex, 0))
if PDFfile.Exists Then
Session.orderInvoiceDownloadWebFile = New WebFile
Session.orderInvoiceDownloadWebFile = WebFile.Open(PDFfile)
Session.orderInvoiceDownloadWebFile.ForceDownload = true
Session.orderInvoiceDownloadWebFile.MIMEType = "application/pdf"
ShowURL(Session.orderInvoiceDownloadWebFile.URL)
SyslogNC.send(1, 6, PDFfile.ShellPath + " nerladdad.")
else
SyslogNC.send(1, 3, PDFfile.ShellPath + " kunde inte hämtas för nedladdning. Filen kanske inte existerar på servern.")
Main.showMsg(0, "Meddelande", PDFfile.ShellPath + " kunde inte hämtas för nedladdning. Filen kanske inte existerar på servern.", 0, false)
end if


This code starts a download of the PDF for the user.
I think I forgot to mention the ShowURL part ;-)

_________________
Image http://www.linkedin.com/in/albinkiland
Dev. iMac 27" + 2x22" LG (2.8GHz Intel Core i7, 12GB RAM, 120GB SSD) OS X 10.8
Xojo Pro 2013r1


Top
 Profile  
Reply with quote  
 Post subject: Re: Show a PDF-file
PostPosted: Fri Feb 17, 2012 8:23 am 
Offline

Joined: Wed Dec 05, 2007 5:17 am
Posts: 503
Location: Sweden
Tack!
I think it was the Mime-type that had to be set!? After changing that it worked.
Great.
Best regards
Johan

_________________
iMac 27" i7, Macbook 13.3,Macbook PRO 15, Mac mini, iPhone 4s & REALStudio...
http://www.precis-it.se


Top
 Profile  
Reply with quote  
 Post subject: Re: Show a PDF-file
PostPosted: Fri Apr 19, 2013 5:45 am 
Offline

Joined: Mon Apr 15, 2013 3:13 am
Posts: 11
Hi :) ,

I know this is late, But can you tell me how you managed to get it working.

Thanks in advance
regadrs


Top
 Profile  
Reply with quote  
 Post subject: Re: Show a PDF-file
PostPosted: Fri Apr 19, 2013 2:52 pm 
Offline

Joined: Wed Apr 26, 2006 12:56 pm
Posts: 26
Location: Topeka, KS
I've handled this a little differently than what was suggested above, because the above method in essence kills your application when the PDF loads because it stays within the existing window. I wanted the PDF to open in a new Tab.

To do this requires the use of a Weblink that is used to launch the PDF.

I have created a WebListbox of the PDF's that I let the user choose from. They must select the PDF in the list and then click on my Weblink which I made look like a button. Browsers only allow a new Tab to be opened by a Weblink. That is why I used this method.

Here is a Screenshot of it:
Image

I placed the following code in the MouseEnter Event of my Weblink(The 'Display' Button Look a like at bottom of the screen). When your mouse hovers over the Weblink it loads in to its URL property of the Weblink, with the URL of the Session.Webfile I opened containing the PDF that was selected in my Weblistbox.

Dim LogoFile(500) as FolderItem
Dim WebfileCounter as Integer
Session.WebfileCounter=Session.WebfileCounter+1
WebfileCounter=Session.WebfileCounter
LogoFile(WebfileCounter)=Session.PDFArray(ListBox1.ListIndex)
Session.LogoFile = WebFile.Open(LogoFile(WebFileCounter))
Session.LogoFile.mimetype = "application/pdf"

If LogoFile(WebfileCounter).Exists Then
Link1.URL=Session.LogoFile.URL
Else
MsgBox("File Selected "+LogoFile(WebfileCounter).Name+" does not exist")
End If

_________________
Stephen Koger
SEKESC-Greenbush
"Ensuring Equal Educational Oppurtunities for Everyone"


Top
 Profile  
Reply with quote  
 Post subject: Re: Show a PDF-file
PostPosted: Fri Apr 19, 2013 3:48 pm 
Offline

Joined: Wed Mar 22, 2006 11:15 am
Posts: 712
Location: Southern California
bluesfannoz wrote:
Browsers only allow a new Tab to be opened by a Weblink.


Just a note that if you want to make WE buttons and images behave like WebLinks you can use the freeware at:
http://webcustomcontrols.com/?p=628

_________________
Daniel L. Taylor
Custom Controls for Real Studio WE!
Visit: http://www.webcustomcontrols.com/


Top
 Profile  
Reply with quote  
 Post subject: Re: Show a PDF-file
PostPosted: Sat Apr 20, 2013 4:09 am 
Offline

Joined: Mon Apr 15, 2013 3:13 am
Posts: 11
Hi,

Thanks for reply.
here is another issue. I am generating a pdf file store it and now trying to show on a HTMLViewer I get permission errors
Could not execute returned javascript: Access to 'the file path' from script denied
Source: alert("The file path");
alert("0");
window.location = "the file path again";
RS.controls['BsNMTtbp'].setEnabled(true);
RS.controls['BsNMTtbp'].refresh();

Please help


Top
 Profile  
Reply with quote  
 Post subject: Re: Show a PDF-file
PostPosted: Sat Apr 20, 2013 4:50 am 
Offline
User avatar

Joined: Wed May 10, 2006 2:42 pm
Posts: 2985
Location: Germany
Well, you can have the PDF download.
For that make the webfile being part of the webpage (as property) and set ForceDownload = true before you use showurl with the webfile url.
Now you don't need to set mime type with ForceDownload = true, but you should give it a file name.

Next you can show the URL with ForceDownload = false in a htmlviewer control. The browser decides if it downloads the file or shows it.

Better may be to use a plugin like our MBS Real Studio DynaPDF Pro plugin to render the pages as JPEGs and show them in an imageview:

see
http://webapps.monkeybreadsoftware.de/webpdf/webpdf.cgi

This way you have full control over what's working.

Greetings
Christian

_________________
See you in Orlando, Florida for Real World 2013
More details and registration here:
http://www.realsoftware.com/community/realworld.php


Top
 Profile  
Reply with quote  
 Post subject: Re: Show a PDF-file
PostPosted: Wed Apr 24, 2013 12:02 am 
Offline

Joined: Wed Apr 26, 2006 12:56 pm
Posts: 26
Location: Topeka, KS
You need to open the PDF as a Webfile. Then either download or select to have it displayed. In my example above I have chosen to display it using the browsers built-in PDF Renderer.

Are you going to be a RealWorld? If so we can look at what your doing.

anis2505 wrote:
Hi,

Thanks for reply.
here is another issue. I am generating a pdf file store it and now trying to show on a HTMLViewer I get permission errors
Could not execute returned javascript: Access to 'the file path' from script denied
Source: alert("The file path");
alert("0");
window.location = "the file path again";
RS.controls['BsNMTtbp'].setEnabled(true);
RS.controls['BsNMTtbp'].refresh();

Please help

_________________
Stephen Koger
SEKESC-Greenbush
"Ensuring Equal Educational Oppurtunities for Everyone"


Top
 Profile  
Reply with quote  
 Post subject: Re: Show a PDF-file
PostPosted: Wed Apr 24, 2013 4:46 am 
Offline

Joined: Mon Apr 15, 2013 3:13 am
Posts: 11
bluesfannoz wrote:
You need to open the PDF as a Webfile. Then either download or select to have it displayed. In my example above I have chosen to display it using the browsers built-in PDF Renderer.

Are you going to be a RealWorld? If so we can look at what your doing.


Hi,

I can download the pdf file but I am unable to display it.

I'm currently building an intranet application. I started with Asp.Net( I know damn MS ) and changed to Real studio.

generally I'm using PHP as web developping, but usually PHP is for website. I was looking for RIA tools and remebred that real studio provide such thing.

Anyway for the PDF I can download it but I am unable to display it in the browser.

For now my reporting solution is a html file like this

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title><!--{{Title}}--></title>
</head>
<body class="container">
<div class="row>
<p>
<img src="logofsm.png" alt="logofsm" align="middle"/>
</P>
</div>
<h1 style="text-align:center"><!--{{ReportTitle}}--></h1>
<table width="100%" border="1">
<thead>
<!--{{Headers}}-->
</thead>
<tbody>
<!--{{Content}}-->
</tbody>
</table>
</body>
</html>


and I wrote a function that took a recordset or a list and bind it to the write variable on file for example "<!--{{Content}}-->"
Then I show it in a HTMLViewer

So as Real Studio experts. do you think such solution would cosume lots of memory and how to optimise this.

Thanks


Top
 Profile  
Reply with quote  
 Post subject: Re: Show a PDF-file
PostPosted: Wed Apr 24, 2013 6:25 am 
Offline

Joined: Wed Apr 26, 2006 12:56 pm
Posts: 26
Location: Topeka, KS
What browser are you using to try to display the PDF in the browser?

If Firefox check the open with settings for Portable Document Format under Tools-Options-Applications Tab
Image

Are you setting the Mime Type like this:
Session.LogoFile = WebFile.Open(LogoFile(WebFileCounter))
Session.LogoFile.mimetype = "application/pdf"

_________________
Stephen Koger
SEKESC-Greenbush
"Ensuring Equal Educational Oppurtunities for Everyone"


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 16 posts ]  Go to page 1, 2  Next

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group