paul.webb Posted May 19, 2014 Share Posted May 19, 2014 Hi there,I have JasperReports Server v5.5.0 build 20131024_0957 set up on a Red Hat Enterprise Linux based server along with my existing LAMP installation. I'm using HTML links to integrate JasperReports with my PHP-based SaaS application. So the application calls a URL like this one:http://[internal-site-url]:8080/jasperserver/flow.html?_flowId=viewReportFlow&j_username=[a_js_username]&j_password=[a_js_password]&ParentFolderUri=%2Freports%2F[Project]&reportUnit=%2Freports%2F[Project]%2F[ReportID]&standAlone=true&decorate=no&output=pdf&inv_id=[Parameter](I've removed any identifiable information from the above URL, but you get the idea)This generates a PDF from JasperReports Server, and they look very nice.What I'd like is this: When someone clicks the URL, it generates a PDF and saves it to the server into a local folder, like /var/tmp/[Parameter].pdf.I cannot seem to find a way to do this. I found ways to schedule a report to run, but I want the report to be generated on demand and saved locally, because from there I can have a script come along and move the file to the correct location based on the customer and the type of report it is.This is an amazing product. I'm thinking it can do this and I just can't find it.Thanks in advance for the help! Link to comment Share on other sites More sharing options...
marianol Posted May 19, 2014 Share Posted May 19, 2014 What you need to do is use the Webservices Guide http://community.jaspersoft.com/documentation/jasperreports-server-web-services-guide/v550/introduction , take a good look at the scheduler API and the report Execution one depending on how you want to implement it.The scheduler API allows you to execute a report with a set of input controls and set the output to be saved either in the local filesystem or an FTP server. The Report Execution one will give back to your PHP app the PDF data stram and you can save that localy form PHP. Link to comment Share on other sites More sharing options...
cfiles Posted May 20, 2014 Share Posted May 20, 2014 You can also use PHP and the cURL extension to wrap the URL and save the output to a file. Something like:<?php $fp = fopen ('/tmp/my-jasper-pdf.pdf', 'w+');$url = "http://url_to_the_jasper_report"; $ch = curl_init($url);curl_setopt($ch, CURLOPT_TIMEOUT, 50);curl_setopt($ch, CURLOPT_FILE, $fp);curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);$data = curl_exec($ch);curl_close($ch);?>[/code]The API is a better option, but if you need something quick and diry this should work. Link to comment Share on other sites More sharing options...
Techvedic Posted May 22, 2014 Share Posted May 22, 2014 Hi,~Go to Record/Request/Page (First)~Loop~ Set Variable [$PDFPath; Value:"file:" & Get ( DesktopPath ) & My Table::ID Number& ".pdf"]~ If [Get(SystemPlatform) = 2]~ Set Variable [$PDFPath; Value:"filewin:/"& Middle ($PDFPath; 2; Length ($PDFPath))]~ End If~ Save Records as PDF [Restore; "$PDFPath"; Current Records]~ Go to Record/Request/Page [Next; Exit after Last]~End LoopMay Be this can Help You.. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now