dolly_11 Posted February 28, 2007 Share Posted February 28, 2007 Hi, Can any one plzzzzzzzzz help me out of this problem?I'm able to display my company logo on the haeder part of the HTML report but i'm not able to do the same thing in PDF report.I was using IMAGE_URI attribute and setting that parameter to the location where the image is located and so it is working for HTML.But how to do it PDF.Below is the sample code://for PDF format reportpublic static void generateRespondPDFReport(String sourceFile, HashMap parameters,String destFileName,HttpServletRequest request,HttpServletResponse response) throws Exception { JasperPrint jasperPrint = fillReport(sourceFile, parameters); //instantiate an object as ServletOutputStream ServletOutputStream out1 = response.getOutputStream();try{ // create a bytearrayoutputstream object ByteArrayOutputStream baos =new ByteArrayOutputStream();//set the content type for the response as pdf response.setContentType("application/pdf");//fill the outputstream object baos with jPrint object JasperExportManager.exportReportToPdfStream(jasperPrint,baos);//set the content size for the output file (pdf) response.setContentLength(baos.size()); //write the exported outputstream to the servlet outputstream baos.writeTo(out1); } catch (JRException e) { e.printStackTrace(); }//And code for HTML is belowJRHtmlExporter exporter = new JRHtmlExporter(); request.getSession().setAttribute(ImageServlet.DEFAULT_JASPER_PRINT_SESSION_ATTRIBUTE, jasperPrint); exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint); exporter.setParameter(JRExporterParameter.OUTPUT_WRITER, out); exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI, "image?image="); exporter.exportReport(); So plz tell me how to make the logo displayed in header part of PDF report as incase of HTML thanks in advance regards,dolly Link to comment Share on other sites More sharing options...
dolly_11 Posted March 5, 2007 Author Share Posted March 5, 2007 Hi, Actually i' am able to save and generate the HTML & PDF reports successfully.But when i want to view the reports directly in the browser without saving it i'm able to view both PDF and HTML reports.But the problem is i want to get even the logo to be displayed on the top of the report.But it is getting displayed only in HTML format but not in the PDF format.Why is it so?My sample code is as below: // for HTML reportJRHtmlExporter exporter = new JRHtmlExporter(); request.getSession().setAttribute(ImageServlet.DEFAULT_JASPER_PRINT_SESSION_ATTRIBUTE, jasperPrint); exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint); exporter.setParameter(JRExporterParameter.OUTPUT_WRITER, out); exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI, "image?image="); exporter.exportReport(); And for PDF format is as below: //Code for PDF format Map imagesMap = new HashMap(); JRPdfExporter exporter = new JRPdfExporter(); exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint); exporter.setParameter(JRHtmlExporterParameter.IMAGES_MAP, imagesMap); exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI, "image?image="); exporter.setParameter(JRExporterParameter.OUTPUT_STREAM,response.getOutputStream()); exporter.exportReport(); When i'm using the above code i'm able to view the reports in both HTML and PDF format.But the logo is getting displayed only in HTML report but in PDF report I'm getting a small rectangle sought of image instead of the logo.Why is it so?Plzz help me out of this problem....... Thanks,dolly 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