ivan.krsul Posted April 15, 2014 Share Posted April 15, 2014 I am trying to extract from the jasperserver a report, using Web Services 5.0, a report in PDF format, but I am am getting a blank PDF file. I am coding in C#/ASP.NET and I managed to get the query to work for all formats except for PDF as follows: // Setup WebClient WebClient httpclient = new WebClient(); //Basic Auth httpclient.Credentials = new NetworkCredential("jasperadmin", "jasperadmin"); httpclient.Headers.Add("Content-Type", "application/x-www-form-urlencoded"); // Build resourceDescriptor string requestXml = System.IO.File.ReadAllText(Server.MapPath("XMLFile.xml")); // Send PUT string requestAllResult = ""; requestAllResult = httpclient.UploadString("http://localhost:8080/jasperserver/rest/report/reports/IvanReports/TestReport2?RUN_OUTPUT_FORMAT=PDF", "PUT", requestXml); // Get session cookie string session = httpclient.ResponseHeaders.Get("Set-Cookie"); // Set session cookie httpclient.Headers.Add("Cookie", session); // Extract uuid, filename is always report XmlDocument doc = new System.Xml.XmlDocument(); doc.LoadXml(requestAllResult); XmlNode node = doc.DocumentElement.SelectSingleNode("uuid"); string uuid = node.InnerText; //Build GET URL string reportUrl = "http://localhost:8080/jasperserver/rest/report/"; reportUrl += uuid; reportUrl += "?file=report"; // Get report string report = httpclient.DownloadString(reportUrl); // Send the report to the user // I AM ASSUMING THE BUG IS HERE... but I may be mistaken Response.ContentType = "application/pdf"; Response.AddHeader("Content-Disposition", "attachment; filename=file.pdf"); Response.ClearContent(); byte[] bytes = System.Text.UTF8Encoding.UTF8.GetBytes(report); Response.OutputStream.Write(bytes, 0, bytes.Length); Response.Flush(); Response.Close();[/code] The XML I am using is as folows:<resourcedescriptor isnew="false" name="TestReport2" uristring="/reports/IvanReports/TestReport2" wstype="reportUnit"> </resourcedescriptor>The report I am trying to extract works well in jasperserver using the Web interface, and I can generate the PDF report there without any trouble. Does anyone know why this code is getting a blank PDF for the report?Ivan Link to comment Share on other sites More sharing options...
Voltrone Posted December 23, 2014 Share Posted December 23, 2014 I was getting blank PDFs from Chrome REST clients I guess because they were messing up with encoding. I tried 'Send and Download' method in Postman and it downloaded a correct PDF. Cheers Link to comment Share on other sites More sharing options...
assiacpge2011 Posted May 13, 2015 Share Posted May 13, 2015 Hi I have the same problem. I download Blank PDFs.I'm using Python to send http requests to jasperserverand my report is containing charts and tables.does anyone find the solution to this problem?Thanks,Assia Link to comment Share on other sites More sharing options...
assiacpge2011 Posted May 13, 2015 Share Posted May 13, 2015 Hi I have the same problem. I download Blank PDFs.I'm using Python to send http requests to jasperserverand my report is containing charts and tables.does anyone find the solution to this problem?Thanks,Assia 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