Report in pdf format in oracle apex

how can i save the contents of a form as a report in pdf format by clicking on tha print button in oracle apex???
plz help if anyone knows tha solution
Edited by: user9139675 on Mar 9, 2010 11:14 PM

how can i save the contents of a form as a report in pdf format by clicking on tha print button in oracle apex???You may create a report and call it in an Apex process fired by press a button.
in the process:
l_utl_http := utl_http.request(l_url);
where set l_url like:
http://167.165.243.209/dev60cgi/rwcgi60?repdevi_key&server=Rep60&report=my_rpt.rdf&DESFORMAT=PDF&DESTYPE=FILE&DESNAME=/arch/chrisweb/devi/cache/my_rpt.PDF&BACKGROUND=YES&P_1=PC00980
The generated pdf report my_rpt.PDF is kept at /arch/chrisweb/devi/cache/

Similar Messages

  • Print PLSQL Dynamic content region in PDF format in Oracle Apex

    Hi All,
    I have created a report region by selecting "PLSQL Dynamic Content".This region calls the procedure with some parameters.So i want this plsql dynamic content to be in PDF format.
    For an easy understanding, I have created an application in Apex.Oracle.Com where i have created a Plsql Dynamic content which calls procedure do display in region.
    Step 1: http://apex.oracle.com/pls/apex/f?p=4550:1:15635986742760:::::
    Step 2: Workspace : dev_dilip
    Username: [email protected]
    Pwd : 123456
    Step 3: Open PRINT_PDF application and Run the application.
    Step 4: Username: [email protected]
    Pwd : 123456
    The procedure code can be viewed by object browser.
    Once user cliks PDF (button inapplication) a new tab should open and that plsql region should in PDF format.
    I kindly request all to check and advice me with your valuable suggestion.
    regards,
    Doddi Dilip.

    SO, you want to print the output of the procedure in pdf format? If so, you can try apex Report Query feature. You can find a number of examples for the same in this forum and in the internet:
    http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/hol08/apexprnt/apexprnt_otn.htm
    Or, have a IR based on a collection; the collection based on a function returning query. And then, use the IR's generic download option to print reports.
    http://www.oracleapplicationexpress.com/tutorials/71

  • Oracle Report in PDF format

    Hi,
    After upgrading from 11.5.7 to 11.5.10 Oracle Report in PDF format is not working(it was working fine in 11.5.7). When change output format to TEXT it working fine.
    Please advise?
    Thanks
    Dave

    Hi,
    Perhaps it is not clear about what are the invalid characters its is showing.....is it showing asterisks.....Well if it does show anything like that then all u have to do is go and change the dimensions of the particular field in which it is showing such characters.......i mean u r to change the rdf file in Reports Builder.....and try changing the length and width by dragging the edges of the particular field and then save it and after that convert it into .xml and .rep files and then run it.

  • Report in PDF format and email it to some clients, using  Database Trigger

    Hi
    Is it possible to run a report in PDF format ad email it to some clients after a specific event through Database Trigger. For example whenever a client makes an entry into order entry table (through entry form), a trigger should execute on Orders table, this trigger should execute or generate a PDF formatted report and finally mail it to Sales team?
    I have
    ORAS 10g(10.1.2.0.2)
    utl_mail configured.

    In Reportsconfig.properties file the http port is 7778,
    now the output is like this...
    SQL> /
    * WELCOME TO EVENT-BASED-REPORTING API *
    * API-Version : 9i *
    * (C) Oracle Corporation, 2000 - 2002 *
    * Debugging turned ON **************************
    *** Length of Paramlist : 1
    OK : Parameter added : GATEWAY=http://myserver.com:7778/reports/rwservlet
    *** Length of Paramlist : 2
    OK : Parameter added : SERVER=rep_myserver_oracleas2
    *** Length of Paramlist : 3
    OK : Parameter added : REPORT=D:\Reports\emp.rdf
    *** Length of Paramlist : 4
    OK : Parameter added : USERID=abc/xyz@mydb
    *** Length of Paramlist : 5
    OK : Parameter added : DESTYPE=mail
    *** Length of Paramlist : 6
    OK : Parameter added : DESFORMAT=PDF
    *** Length of Paramlist : 7
    OK : Parameter added : [email protected]
    Starting run_report: building url
    *** Building URL (RUN_REPORT)
    OK : URL built :
    http://myserver.com:7778/reports/rwservlet?SERVER=rep_myserver_oracleas2&REPO
    RT=D%3A%CReports%5Cemp.rdf&USERID=abc%2Fxyz%40mydb&DESTYPE=mail&D
    ESFORMAT=PDF&DESNAME=khan.emran84%40gmail.com&statusformat=xml
    *** Submitting HTTP Request
    *** using URL
    :http://myserver.com:7778/reports/rwservlet?SERVER=rep_myserver_oracleas2&REP
    ORT=D%3A%5CReports%5Cemp.rdf&USERID=abc%2Fxyz%40mydb&DESTYPE=mail&
    DESFORMAT=PDF&DESNAME=khan.emran84%40gmail.com&statusformat=xml
    OK : Request submitted - Return stream : <?xml version = '1.0' encoding =
    'ISO-8859-1' standalone = 'yes'?>
    <serverQueues>
    <error code="50159"
    component="REP" message="Executed successfully but there were some errors when
    distribute the output"/>
    <
    OK : Request submitted - Length of stream : 229
    *** XML-Parsed - Following Structure discovered :
    *** Checking elements!
    serverQueues ()
    *** Checking attributes!
    error
    *** Checking attributes!
    __code = 50159
    __component = REP
    __message = Executed successfully but there were some errors when distribute the
    output
    *** Finished Parsing XML
    Getting value for element: job
    Getting value for element: error
    *** Requesting value for Attribute error.component [REP]
    Getting value for element: error
    *** Requesting value for Attribute error.code [50159]
    Getting value for element: error
    *** Requesting value for Attribute error.message [Executed successfully but    
    there were some errors when distribute the output]
    REP-50159:Executed successfully but there were some errors when distribute the
    output
    declare
    ERROR at line 1:
    ORA-20999:
    ORA-06512: at "NRSP.SRW", line 264
    ORA-06512: at "NRSP.SRW", line 799
    ORA-06512: at line 15

  • How to generate jasper report in pdf format using swing

    hi all,
    im new to swing and jasper.. can anybody provide me some example on how to generate the jasper report in pdf format? i will call the reportManager from sessionBean.. below is my code:
    1)delegate:
    public GenerateReportDto generateIntoPdfReport(String fileName, String outputFileName, Map parameters){
    GenerateReportDto generateReportDto = getAuditTrailServiceRemote().generateIntoPdfReport(fileName, outputFileName, parameters);
    return generateReportDto;
    2)sessionBean:
    public GenerateReportDto generateIntoPdfReport(String fileName, String outputFileName, Map parameters){
    //Map parameters = new HashMap();
    ReportManager reportManager = new ReportManager();
    3)ReportManager()
    public void generateIntoPdfReport(String fileName, String outputFileName, Map parameters) {
              Connection conn = null;
              try {
                   conn = dataSource.getConnection();
                   //Generate the report to bytes
                   File reportFile = new File(fileName);               
                   byte[] bytes =
                        JasperRunManager.runReportToPdf(
                             reportFile.getPath(),
                             parameters,
                             conn
              //conn.close();
              //Write the bytes to a file
              ByteBuffer buf = ByteBuffer.wrap(bytes);
              File file = new File(outputFileName);
              // (if the file exists)
              boolean append = false;
              // Create a writable file channel
              FileChannel wChannel = new FileOutputStream(file, append).getChannel();
              // Write the ByteBuffer contents; the bytes between the ByteBuffer's
              // position and the limit is written to the file
              wChannel.write(buf);
              // Close the file
              wChannel.close();
              } finally {
                   if (conn != null) {
    conn.close();
    Any help would be highly appreciated. Thanks in advance

    Hi ,
    One 'simple' way is by using the DBMS_SCHEDULER db package and the procedure CREATE_JOB(....) using as job_type the value 'EXECUTABLE'...
    Read for further info in 'PL/SQL Packages and Types Reference'.
    If you have access to OEM ... you can configure this there using wizard.....
    Other way is to use the External Procedure call capabiblity of Oracle DB Server...:
    http://www.oracle.com/pls/db102/ranked?word=external+procedure+call&remark=federated_search
    My greetings,
    Sim

  • How to create a FSG report in pdf format

    How to create a FSG report in pdf format?
    Thanks In Advance
    Kris

    Hi,
    There is an enhancement request at user group review to create FSG's in PDF format. However, I transformed the FSG output by using ascii2pdf shareware software (do a search on google.) I created a shell script that did the transformation and emailed the report from Oracle Apps. It seems to work ok.
    Renee

  • Error 500 Internal Server Error" When Generating Hyperion Financial Reports in PDF Format

    We are unable to open pdf reports in Workspace with the following error. It was all working fine and doesn't work now for unknown reasons.
    Error 500 Internal Server Error" When Generating Hyperion Financial Reports in PDF Format
    We are on 11.1.2.1 environment. Ghost Script 8.54 and Java heap settings xms256m and xmx512m.
    Please advice.

    hello,
    just to clarify
    a) the parameter is named DESFORMAT not :DESFORMAT, there is
    no : in front of the name, if you submit it via URL !
    b) there are some issues with acrobat5 and IE but those are not
    only caused by PDFs generated with oracle reports.
    regards,
    the oracle reports team --pw                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Emailing a report in pdf format.

    Hi ,
    I have a requirement of monthly getting a report in pdf format and mailing it as an attachment.
    Please tell me if this is possible on apex.
    thanks,

    It's possible.. Now, can you change you name in the forum so we know who were are talking to, we are a friendly group here, and normally don't bite..If you have BI Publisher available, you can build a report in it,m and have it scheduled to send reports .. Or you can look at this thread Re: send .pdf-file from report query in an email which talks about running the report to the server using an APEX api and then sending the resulting pdf via a dbms_job you setup..
    Thank you,
    Tony Miller
    Webster, TX

  • How To Generate And Print Reports In PDF Format From EBS With The UTF8 Char

    Hi,
    I want to know How To Generate And Print Reports In PDF Format From EBS With The UTF8 Character Set in R12.0.4.
    Regards

    Refer to Note: 239196.1 - PASTA 3.0 Release Information
    https://metalink.oracle.com/metalink/plsql/ml2_documents.showDocument?p_database_id=NOT&p_id=239196.1
    Or, you can use XML Publisher.
    Note: 551591.1 - Need Latest XML Publisher / BI Publisher Patches For R12
    https://metalink.oracle.com/metalink/plsql/ml2_documents.showDocument?p_database_id=NOT&p_id=551591.1

  • Regarding downloading thw report in pdf format

    Hi Experts,
    when we download the report in pdf format using printer friendly icon,
    my concern is that is it possible to add watermark in the downloaded report
    by changing in xml files.
    please suggest any solutions.

    Hi ,
    While scheduling a report we can get the pdf watermark .Check the below link
    http://oraclebizint.wordpress.com/2008/02/04/oracle-bi-ee-101332-adding-watermarks-to-delivered-pdf-documents-using-pdf-merger-api-of-bi-publisher/
    Thanks,
    Ananth

  • Save the report in PDF format on the server: is it possible?

    Hi all,
    Is it possible to save the report in PDF format on the server?
    In other words, in a web application:
    1) the user requests a report
    2) the report produced in PDF format, is saved on the server, where is the Java Reporting Component
    3) the report, in PDF format, is sent to the client's user
    Thanks a lot

    PrintOutputController.export, get the byte stream, save on server.
    Sincerely,
    Ted Ueda

  • IllegalArgumentException error while exporting report in PDF format

    Hi all,
    we are using Crystal Report 2008, Java 1.5.22 and JRC 11.8.4.1094 to export reports in pdf format within java.
    It is working fine for all reports except for a specific report where it gives IllegalArgumentException while exporting the PDF.
    Below the error occurred:
    12:39:16,875 ERROR [c] Disk Exporter: no output file was created by an exporter
    12:39:16,875 ERROR <b> PdfExporter: caught Exception in PDFFormatter.finalizeFormatJob (from destination?); aborting export
    java.lang.IllegalArgumentException
         at com.crystaldecisions.reports.exporters.destination.disk.c.a(Unknown Source)
         at com.crystaldecisions.reports.exporters.format.page.pdf.b.a(Unknown Source)
         at com.crystaldecisions.reports.a.e.if(Unknown Source)
         at com.crystaldecisions.reports.formatter.a.c.if(Unknown Source)
         at com.crystaldecisions.reports.formatter.a.c.a(Unknown Source)
         at com.businessobjects.reports.sdk.b.b.int(Unknown Source)
         at com.businessobjects.reports.sdk.JRCCommunicationAdapter.request(Unknown Source)
         at com.crystaldecisions.proxy.remoteagent.x.a(Unknown Source)
         at com.crystaldecisions.proxy.remoteagent.q.a(Unknown Source)
         at com.crystaldecisions.sdk.occa.report.application.dd.a(Unknown Source)
         at com.crystaldecisions.sdk.occa.report.application.ReportSource.a(Unknown Source)
         at com.crystaldecisions.sdk.occa.report.application.ReportSource.a(Unknown Source)
         at com.crystaldecisions.sdk.occa.report.application.ReportSource.export(Unknown Source)
         at com.crystaldecisions.sdk.occa.report.application.AdvancedReportSource.export(Unknown Source)
         at com.crystaldecisions.sdk.occa.report.application.NonDCPAdvancedReportSource.export(Unknown Source)
         at com.crystaldecisions.reports.reportengineinterface.JPEReportSource.export(Unknown Source)
         at com.crystaldecisions.report.web.event.br.a(Unknown Source)
         at com.crystaldecisions.report.web.event.w.a(Unknown Source)
         at com.crystaldecisions.report.web.event.b7.broadcast(Unknown Source)
         at com.crystaldecisions.report.web.event.av.a(Unknown Source)
         at com.crystaldecisions.report.web.WorkflowController.do(Unknown Source)
         at com.crystaldecisions.report.web.WorkflowController.doLifecycle(Unknown Source)
         at com.crystaldecisions.report.web.ServerControl.a(Unknown Source)
         at com.crystaldecisions.report.web.viewer.ReportExportControl.a(Unknown Source)
         at com.crystaldecisions.report.web.ServerControl.getHtmlContent(Unknown Source)
    12:39:16,875 INFO  [c] Disk Exporter: finalizing export to destination
    12:39:16,875 ERROR [JRCCommunicationAdapter] Failed to export report
    com.crystaldecisions.reports.exporters.format.page.pdf.a.a: Unknown exception is thrown
         at com.crystaldecisions.reports.exporters.format.page.pdf.b.a(Unknown Source)
         at com.crystaldecisions.reports.a.e.if(Unknown Source)
         at com.crystaldecisions.reports.formatter.a.c.if(Unknown Source)
         at com.crystaldecisions.reports.formatter.a.c.a(Unknown Source)
         at com.businessobjects.reports.sdk.b.b.int(Unknown Source)
         at com.businessobjects.reports.sdk.JRCCommunicationAdapter.request(Unknown Source)
         at com.crystaldecisions.proxy.remoteagent.x.a(Unknown Source)
         at com.crystaldecisions.proxy.remoteagent.q.a(Unknown Source)
         at com.crystaldecisions.sdk.occa.report.application.dd.a(Unknown Source)
         at com.crystaldecisions.sdk.occa.report.application.ReportSource.a(Unknown Source)
         at com.crystaldecisions.sdk.occa.report.application.ReportSource.a(Unknown Source)
         at com.crystaldecisions.sdk.occa.report.application.ReportSource.export(Unknown Source)
         at com.crystaldecisions.sdk.occa.report.application.AdvancedReportSource.export(Unknown Source)
         at com.crystaldecisions.sdk.occa.report.application.NonDCPAdvancedReportSource.export(Unknown Source)
         at com.crystaldecisions.reports.reportengineinterface.JPEReportSource.export(Unknown Source)
         at com.crystaldecisions.report.web.event.br.a(Unknown Source)
         at com.crystaldecisions.report.web.event.w.a(Unknown Source)
         at com.crystaldecisions.report.web.event.b7.broadcast(Unknown Source)
         at com.crystaldecisions.report.web.event.av.a(Unknown Source)
         at com.crystaldecisions.report.web.WorkflowController.do(Unknown Source)
         at com.crystaldecisions.report.web.WorkflowController.doLifecycle(Unknown Source)
         at com.crystaldecisions.report.web.ServerControl.a(Unknown Source)
         at com.crystaldecisions.report.web.viewer.ReportExportControl.a(Unknown Source)
         at com.crystaldecisions.report.web.ServerControl.getHtmlContent(Unknown Source)
    Caused by: java.lang.IllegalArgumentException
         at com.crystaldecisions.reports.exporters.destination.disk.c.a(Unknown Source)
         ... 56 more
    Have an idea?
    Thanks

    Hello Andrea.
    I searched through the SAP Notes for the error that you are encountering.  There is an SAP Note that exists titled the following:
    1332907 - Report being exported to PDF format using the Crystal Reports for Eclipse 1.x runtime, errors with the exception: PdfExporter: caught Exception in PDFFormatter.finalizeFormatJob
    Since you may not have access to the SAP Notes, I will extract the details that are mentioned in the note here:
    =============================================
    Symptom
    Attempting to export a report to Adobe PDF format using the Crystal Reports for Eclipse 1.x runtime results in an exception.
    The exception indicates "PdfExporter: caught Exception in PDFFormatter.finalizeFormatJob"
    Environment
    Windows 2003
    Apache Tomcat 5.0
    Crystal Reports for Eclipse version 1.x
    Reproducing the Issue
    Using the Crystal Reports for Eclipse runtime version 1.x attempt to export a report to PDF format that has the "Repeat Group Header on Each Page" option enabled.
    Note: This does not occur if this option is enabled in a subreport.
    Cause
    When the "Repeat Group Header on Each Page" is enabled for a group in a main report the Crystal Reports for Eclipse 1.x runtime is unable to correclty format the PDF document which results in an exception.
    Resolution
    Updating the application to use Crystal Reports for Eclipse version 2.x runtime will resolve the issue.
    The most recent updates to the Crystal Reports for Eclipse runtime can be freely downloaded from the SAP SDN Website. 
    http://www.sdn.sap.com/irj/boc/crystalreports-java
    =============================================
    Since you are on JRC 11.8.4.1094 which is Crystal Reports for Eclipse 1.x, this may be the cause of your problem.
    I hope that this helps.
    Regards.
    - Robert

  • Getting a report in excel format from oracle report builder 10gDS release2

    I want to get a report in excel format from oracle report builder 10gDS release2.
    Is there ne method by which minimum effort is required for changing already made reports .
    I have searched for it on internet :-
    http://www.oracle.com/webapps/online-help/reports/10.1.2/state/content/navId.3/navSetId._/vtTopicFile.htmlhelp_rwbuild_hs%7Crwwhthow%7Cwhatare%7Coutput%7Coutput_a_simpleexcel~htm/
    Example, given in the last of the page opened from the above url, is not working.
    Can neone plz explain the example and how to use it
    Thanks & Regards
    JD

    Ok, for the release 2 its quite straightfoward, in your calling form you would have something like this code:
    declare
         pl_id ParamList;
    repid REPORT_OBJECT;
    v_rep VARCHAR2(100);
    v_rep_status VARCHAR2(20);
    v_repsrv     VARCHAR2(100):= 'yourreportserver';
    v_serv varchar2(50) := 'yourservername' ;
    begin
    pl_id := Get_Parameter_List('tmpdata');
    if not id_null(pl_id) then
    Destroy_Parameter_List( pl_id );
    end if;
    pl_id := Create_Parameter_List('tmpdata');
    Add_Parameter(pl_id,'DESTYPE' ,TEXT_PARAMETER,'Screen' );
    Add_Parameter(pl_id,'PARAMFORM' ,TEXT_PARAMETER,'NO' );
    repid := FIND_REPORT_OBJECT('yourreport');     SET_REPORT_OBJECT_PROPERTY(repid,REPORT_COMM_MODE,SYNCHRONOUS);
    SET_REPORT_OBJECT_PROPERTY(repid,REPORT_EXECUTION_MODE,RUNTIME);
    SET_REPORT_OBJECT_PROPERTY(repid,REPORT_SERVER, v_repsrv);
    set_report_object_property(repid,REPORT_DESTYPE,CACHE );
    set_report_object_property(repid,REPORT_DESFORMAT,'SPREADSHEET' );
    v_rep := RUN_REPORT_OBJECT(repid,pl_id);
    v_rep := substr(v_rep,length(v_repsrv)+2,10 ) ;
    end;
    I have plenty of reports being formated to excel with this same method so it should work for you, the only diference with my previous code is this line.
    set_report_object_property(repid,REPORT_DESFORMAT,'SPREADSHEET' );
    The rest remains untouched.
    Hope it helps.

  • A big problem of Generate report with PDF format....Urgent

    I want to generate a report with pdf format through one java file, it have two page 1)gen_report.jsp 2) report_gen.java , the compliation was failed. However, i don't what the problem is .... i hope anyone can help me as it is very argent for me ....Thanks a lot
    1)gen_report.jsp
    <table  id="AutoNumber1">
       <tr>
         <td background="images/top5movie.png">
         <p align="center"> </p>
        </td>
       </tr>
       <tr>
       <td >
          <div align="center">
            <table id="AutoNumber2" >
                  <form method="GET" action="../report_gen" name="report_gen" target="_blank" onSubmit="javascript:return checkr1(this)">
                    <tr>
                      <td ><b>Report Description:</b></td>
                      <td >This report is to show the top five popular movies in cinemix for a period </td>
                    </tr>
                    <tr>
                      <td><b>Data scope:</b></td>
                      <td >Start from
                      <input type="text" name="start" value="2003-1-1" >to
                      <input type="text" name="end" value="2006-1-1" ></td>
                     </tr>
                     <tr>
                      <td><b>Data processing:</b></td>
                      <td >Show
                        <select name="order_by">
                          <option value="desc" selected>top</option>
                          <option value="asc">bottom</option>
                        </select>
                      5 films</td>
                    </tr>
                    <tr>
                      <td> <p align="center">
                          <input type="submit" value="View_Report" name="subm">
                        </p></td>
                    </tr>
                    <input type="hidden" name="report" value="r1">
                  </form>
                  <form method="GET" action="../report_gen" name="report_gen" target="_blank" onSubmit="javascript:return checkr2(this)">
                    <input type="hidden" name="report" value="r2">
                  </form>
                </table>
         </div>
          </td>
        </tr>
      </table>Then my java code is here
    report_gen.java
    import java.io.*;
    import java.net.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.util.*;
    import java.sql.*;
    // chart and pdf out
    import java.awt.Graphics2D;
    import java.awt.geom.Rectangle2D;
    import java.io.FileNotFoundException;
    import java.io.FileOutputStream;
    import org.jfree.chart.ChartFactory;
    import org.jfree.chart.JFreeChart;
    import org.jfree.chart.plot.PlotOrientation;
    import org.jfree.data.category.DefaultCategoryDataset;
    import org.jfree.data.xy.*;
    import org.jfree.data.xy.XYBarDataset;
    import org.jfree.data.general.DefaultPieDataset;
    import org.jfree.data.statistics.SimpleHistogramDataset;
    import org.jfree.data.xy.XYSeries;
    import org.jfree.data.xy.XYSeriesCollection;
    import com.lowagie.text.Document;
    import com.lowagie.text.DocumentException;
    import com.lowagie.text.Rectangle;
    import com.lowagie.text.pdf.DefaultFontMapper;
    import com.lowagie.text.pdf.PdfContentByte;
    import com.lowagie.text.pdf.PdfTemplate;
    import com.lowagie.text.pdf.PdfWriter;
    import com.lowagie.text.*;
    import com.lowagie.text.pdf.*;
    import com.lowagie.text.pdf.PdfPCell;
    public class report_gen extends HttpServlet
       private final String titles[] = {"Top Five popular movies ",
                        "Financial cirumstance of cinemas",
                        "Distribution of time segment",
                        "Distribution of favourite movie type"
       private final String descs[] = {"This report is to show the top five  popular movies in cinemix for a period ",
                   "This report is to show the financial circumstance of each cinema site ",
                   "This report is to analysis the customer when is the most visit time ",
                   "This report is to analysis the customer which type of movie do they watch the most"
        private final String bigTitle = "Cinemix";
        private final String driver = "org.gjt.mm.mysql.Driver";
        private final String url= "jdbc:mysql://localhost:3306/cinemix";
        private final String userID = "abc";
        private final String passwd = "abc";     
        public void init(ServletConfig config) throws ServletException
          super.init(config);
       protected void doGet(HttpServletRequest request, HttpServletResponse response)
       throws ServletException, IOException
          final int width = 550;
         final int height = 200;
    / title font (centre and report title)
         final Font fTitle0 = FontFactory.getFont("Helvetica", 42, Font.BOLD);
         final Font fTitle1 = FontFactory.getFont("Helvetica", 30, Font.BOLD);
              // centre name:
        final String title0 = bigTitle;
       // Default category for DefaultCategoryDataset
       final String cat = "data";
       Connection conn;
      JFreeChart chart;
       String title1     = "xyz Report";
       String chartDesc = "description";
       String notes[] = new String[4];
       String chartTitle = "so bad this is title";
       String chartXTitle = "this is x";
       String chartYTitle = "this is y.";
       String report = request.getParameter("report");     
       int max=-10000;
       int min=10000;
       int j=0;          
      // do some basic checking
       if (report == null || report.equals(""))
         report = "-1";  // this course unknow report error message
         String start   = request.getParameter("start");
         String end  = request.getParameter("end");
         String order_by  = request.getParameter("order_by");  // ToDo: check invalid string
           int topN  = 5;
        String order = (order_by.equals("desc")) ? "Top" : "Last";
       String inv[] = {"08:30", "09:30", "10:30", "11:30", "12:30", "11:30", "12:30", "13:30", "14:30", "15:30", "16:30", "17:30","18:30","19:30","20:30","21:30","22:30","23:30"};
         int inv_val[] = new int[inv.length - 1];
         try
            Class.forName(driver).newInstance();
             catch(Exception e)
            printE("Cannot load mysql database driver!", response);
              e.printStackTrace();
               return;
           try
                 conn = DriverManager.getConnection(url, userID, passwd);
                  if (report.equals("r1")) {  // report 1
               DefaultCategoryDataset dataset = new DefaultCategoryDataset();
              Statement stmt = conn.createStatement();
              String sql = "select *,count(f.Name),f.Name from film f, filmDetail fd, ticket t where f.startDate > '" + start + "' and f.endDate <  '" + end + "'and fd.filmID = f.filmID and fd.filmDetailID = t.filmDetailID group by f.name order by fd.filmDetailID asc limit '" +topN+"'";
              ResultSet rs = stmt.executeQuery(sql);
            while (rs.next())
           if (rs.getInt("fd.filmDetailID") > max) max = rs.getInt("fd.filmDetailID");
         if (rs.getInt("fd.filmDetailID") < min) min = rs.getInt("fd.filmDetailID");
          j++;
           ataset.setValue(rs.getInt("fd.filmDetailID"), cat,rs.getString("f.Name"));
           title1     = titles[0];
         chartDesc  = descs[0];
         chartTitle = order + " " + topN + " popular movie";
          chartYTitle = "Box Office record";
          chartXTitle = "Film Name";
          gender = " ";
          chart = ChartFactory.createBarChart(chartTitle, chartXTitle,   chartYTitle, dataset,PlotOrientation.VERTICAL, false, true, false);
        else
              print("Error: I don't inderstand your request!", response);
         return;
           catch (SQLException e)
         printE("Cannot open database connection? <br>", response);
         // printE(e.toString);
      e.printStackTrace();
      return;
         response.setContentType("application/pdf");
         Document document = new Document(PageSize.A4, 5, 5, 5, 5);
        try
             PdfWriter writer;
         writer = PdfWriter.getInstance(document, response.getOutputStream());
        HeaderFooter footer = new HeaderFooter(new Phrase("Page: "), true);
         footer.setBorder(Rectangle.NO_BORDER);
    document.setFooter(footer);
                   footer.setAlignment(Element.ALIGN_CENTER);
                   // step 3
                   document.open();
                   document.add(getHeader(title0, title1, start, end, gender, order, topN, chartDesc));
                   document.add(printChart(chart, writer));
                   document.add(getFooter(notes));
              catch(DocumentException de)
                   de.printStackTrace();
              // step 5
              document.close();
              return;
         }// end doGet()
         /** Handles the HTTP <code>POST</code> method.
          * @param request servlet request
          * @param response servlet response
         protected void doPost(HttpServletRequest request, HttpServletResponse response)
              throws ServletException, IOException
              // processRequest(request, response);
         /** Returns a short description of the servlet.
         public String getServletInfo()
              return "Generate reports for " + bigTitle;
         /* To print en error and exit(?) */
         private void printE(Object obj, HttpServletResponse response) throws IOException
              response.setContentType("text/html");
              PrintWriter out;
              out = response.getWriter();
              out.print(obj.toString());
              out.close();
              // To-Do: how to force exiting?
         // create data chart
         private PdfPTable getHeader(String title0, String title1, String start, String end, String sex, String order, int topN, String desc)
              Font fTitle0 = FontFactory.getFont("Helvetica", 42, Font.BOLD);
              Font fTitle1 = FontFactory.getFont("Helvetica", 24, Font.BOLD);
              Font fTitle3 = FontFactory.getFont("Helvetica", 12, Font.BOLD);
              Font fValue = FontFactory.getFont("Helvetica", 12, Font.UNDERLINE);
              Paragraph parStartEnd = new Paragraph();
              parStartEnd.add(new Phrase("Data start from:                  ", fTitle3));
              parStartEnd.add(new Phrase(start, fValue));
              parStartEnd.add(new Phrase("     to     ", fTitle3));
              parStartEnd.add(new Phrase(end, fValue));
              Paragraph parGenerateDate = new Paragraph();
              parGenerateDate.add(new Phrase("Report generated at:         ", fTitle3));
              parGenerateDate.add(new Phrase(new java.util.Date().toString(), fValue));
              Paragraph parGender = new Paragraph();
              parGender.add(new Phrase("Current show gender:       ", fTitle3));
              parGender.add(new Phrase(sex, fValue));
              Paragraph parTopN = new Paragraph();
              parTopN.add(new Phrase("Now is showing                 ", fTitle3));
              parTopN.add(new Phrase(order, fValue));
              parTopN.add(new Phrase("  ", fValue));
              parTopN.add(new Phrase(new Integer(topN).toString(), fValue));
              parTopN.add(new Phrase("   record(s)", fTitle3));
              // Start main table
              PdfPTable tblMain = new PdfPTable(1);
              tblMain.getDefaultCell().setBorder(0);
              // Print title
              tblMain.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
              tblMain.addCell(new Paragraph(title0, fTitle0));
              tblMain.addCell(new Paragraph(title1, fTitle1));
              tblMain.addCell("");
              tblMain.addCell("");
              tblMain.addCell("");
              // Print headers data
              //tblMain.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT);
              //tblMain.addCell(parInvoiceNum);
              //tblMain.addCell("");
              tblMain.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
              tblMain.addCell(parStartEnd);
              tblMain.addCell("");
              tblMain.addCell(parGenerateDate);
              tblMain.addCell("");
              if (sex != " ")
                   tblMain.addCell(parGender);
              else if(order != null && topN > 0)
                   tblMain.addCell(parTopN);
              else
                   tblMain.addCell(" \n");
              tblMain.addCell("");
              tblMain.setWidthPercentage(96);
              tblMain.addCell(new Paragraph("Description of this report:", fTitle3));
              tblMain.addCell(desc);
              tblMain.addCell("\n");
              // Finish main table
              return tblMain;
         // print a chart _directly_ to pdf and return a empty Pdftable...
         public PdfPTable printChart(JFreeChart chart, PdfWriter writer)
              PdfContentByte cb = writer.getDirectContent();
              int width = 550;
              int height = 450;
              PdfTemplate tp = cb.createTemplate(width, height);
              Graphics2D g2d = tp.createGraphics(width, height, new DefaultFontMapper());
              Rectangle2D r2d = new Rectangle2D.Double(0, 0, width, height); //->,
              chart.draw(g2d, r2d);
              g2d.dispose();
              cb.addTemplate(tp, 20, 170);
              // quick method to push down the footer text
              // the only things this method return
              PdfPTable tblDownDown = new PdfPTable(1);
              tblDownDown.getDefaultCell().setBorder(0);
              tblDownDown.addCell(" \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n");
              tblDownDown.addCell(" \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n");
              tblDownDown.addCell(" \n \n \n \n \n \n");
              return tblDownDown;
         public PdfPTable getFooter(String notes[])
              Font fNote = FontFactory.getFont("Helvetica", 14, Font.UNDERLINE);
              Font fComment = FontFactory.getFont("Helvetica", 12, Font.ITALIC);
              Font fTitle1 = FontFactory.getFont("Helvetica", 30, Font.ITALIC);
              // Start footer table
              PdfPTable tblFooter = new PdfPTable(1);
              tblFooter.getDefaultCell().setBorder(0);
              if (notes != null)
                   tblFooter.addCell(new Paragraph("Notes:", fNote));
                   tblFooter.addCell("");
                   tblFooter.addCell("");
                   tblFooter.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
                   for (int i=0;i<notes.length;i++)
                        if (notes[i] != null)
                             tblFooter.addCell(new Paragraph("" + (i+1) + ". " + notes[i] + "", fComment));
                             tblFooter.addCell("");
                             tblFooter.addCell("");
                        tblFooter.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
                        tblFooter.addCell(new Paragraph("- End of report -", fComment));
                        return tblFooter;
    }

    Go to the cache directory and see if you can open the report directly from here (not in IE).
    I have seen posts on problems with Acrobat Reader Plugin for IE (I believe it was version 6 of Reader).

  • How to get a report in pdf format.

    Hi Experts,
    Could any one let me know that, how to get the report in PDF format.
    Once a report is generated it should be displayed in pdf format or downloaded in pdf format.
    Thanks in Advance,
    Regards,
    Irfan Hussain

    Hi,
    Check out this code:
    REPORT  zspooltopdf.
    PARAMETER: p_email1 LIKE somlreci1-receiver
                                        DEFAULT '[email protected]',
               p_sender LIKE somlreci1-receiver
                                        DEFAULT '[email protected]',
               p_delspl  AS CHECKBOX.
    *DATA DECLARATION
    DATA: gd_recsize TYPE i.
    * Spool IDs
    TYPES: BEGIN OF t_tbtcp.
            INCLUDE STRUCTURE tbtcp.
    TYPES: END OF t_tbtcp.
    DATA: it_tbtcp TYPE STANDARD TABLE OF t_tbtcp INITIAL SIZE 0,
          wa_tbtcp TYPE t_tbtcp.
    * Job Runtime Parameters
    DATA: gd_eventid LIKE tbtcm-eventid,
          gd_eventparm LIKE tbtcm-eventparm,
          gd_external_program_active LIKE tbtcm-xpgactive,
          gd_jobcount LIKE tbtcm-jobcount,
          gd_jobname LIKE tbtcm-jobname,
          gd_stepcount LIKE tbtcm-stepcount,
          gd_error    TYPE sy-subrc,
          gd_reciever TYPE sy-subrc.
    DATA:  w_recsize TYPE i.
    DATA: gd_subject   LIKE sodocchgi1-obj_descr,
          it_mess_bod LIKE solisti1 OCCURS 0 WITH HEADER LINE,
          it_mess_att LIKE solisti1 OCCURS 0 WITH HEADER LINE,
          gd_sender_type     LIKE soextreci1-adr_typ,
          gd_attachment_desc TYPE so_obj_nam,
          gd_attachment_name TYPE so_obj_des.
    * Spool to PDF conversions
    DATA: gd_spool_nr LIKE tsp01-rqident,
          gd_destination LIKE rlgrap-filename,
          gd_bytecount LIKE tst01-dsize,
          gd_buffer TYPE string.
    * Binary store for PDF
    DATA: BEGIN OF it_pdf_output OCCURS 0.
            INCLUDE STRUCTURE tline.
    DATA: END OF it_pdf_output.
    CONSTANTS: c_dev LIKE  sy-sysid VALUE 'DEV',
               c_no(1)     TYPE c   VALUE ' ',
               c_device(4) TYPE c   VALUE 'LOCL'.
    *START-OF-SELECTION.
    START-OF-SELECTION.
    * Write statement to represent report output. Spool request is created
    * if write statement is executed in background. This could also be an
    * ALV grid which would be converted to PDF without any extra effort
      WRITE 'Hello World'.
      new-page.
      commit work.
      new-page print off.
      IF sy-batch EQ 'X'.
        PERFORM get_job_details.
        PERFORM obtain_spool_id.
    *** Alternative way could be to submit another program and store spool
    *** id into memory, will be stored in sy-spono.
    *submit ZSPOOLTOPDF2
    *        to sap-spool
    *        spool parameters   %_print
    *        archive parameters %_print
    *        without spool dynpro
    *        and return.
    * Get spool id from program called above
    *  IMPORT w_spool_nr FROM MEMORY ID 'SPOOLTOPDF'.
        PERFORM convert_spool_to_pdf.
        if p_delspl EQ 'X'.
          PERFORM delete_spool.
        endif.
        IF sy-sysid = c_dev.
          wait up to 5 seconds.
          SUBMIT rsconn01 WITH mode   = 'INT'
                          WITH output = 'X'
                          AND RETURN.
        ENDIF.
      ELSE.
        SKIP.
        WRITE:/ 'Program must be executed in background in-order for spool',
                'request to be created.'.
      ENDIF.
    *       FORM obtain_spool_id                                          *
    FORM obtain_spool_id.
      CHECK NOT ( gd_jobname IS INITIAL ).
      CHECK NOT ( gd_jobcount IS INITIAL ).
      SELECT * FROM  tbtcp
                     INTO TABLE it_tbtcp
                     WHERE      jobname     = gd_jobname
                     AND        jobcount    = gd_jobcount
                     AND        stepcount   = gd_stepcount
                     AND        listident   <> '0000000000'
                     ORDER BY   jobname
                                jobcount
                                stepcount.
      READ TABLE it_tbtcp INTO wa_tbtcp INDEX 1.
      IF sy-subrc = 0.
        message s004(zdd) with gd_spool_nr.
        gd_spool_nr = wa_tbtcp-listident.
        MESSAGE s004(zdd) WITH gd_spool_nr.
      ELSE.
        MESSAGE s005(zdd).
      ENDIF.
    ENDFORM.
    *       FORM get_job_details                                          *
    FORM get_job_details.
    * Get current job details
      CALL FUNCTION 'GET_JOB_RUNTIME_INFO'
           IMPORTING
                eventid                 = gd_eventid
                eventparm               = gd_eventparm
                external_program_active = gd_external_program_active
                jobcount                = gd_jobcount
                jobname                 = gd_jobname
                stepcount               = gd_stepcount
           EXCEPTIONS
                no_runtime_info         = 1
                OTHERS                  = 2.
    ENDFORM.
    *       FORM convert_spool_to_pdf                                     *
    FORM convert_spool_to_pdf.
      CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
           EXPORTING
                src_spoolid              = gd_spool_nr
                no_dialog                = c_no
                dst_device               = c_device
           IMPORTING
                pdf_bytecount            = gd_bytecount
           TABLES
                pdf                      = it_pdf_output
           EXCEPTIONS
                err_no_abap_spooljob     = 1
                err_no_spooljob          = 2
                err_no_permission        = 3
                err_conv_not_possible    = 4
                err_bad_destdevice       = 5
                user_cancelled           = 6
                err_spoolerror           = 7
                err_temseerror           = 8
                err_btcjob_open_failed   = 9
                err_btcjob_submit_failed = 10
                err_btcjob_close_failed  = 11
                OTHERS                   = 12.
      CHECK sy-subrc = 0.
    * Transfer the 132-long strings to 255-long strings
      LOOP AT it_pdf_output.
        TRANSLATE it_pdf_output USING ' ~'.
        CONCATENATE gd_buffer it_pdf_output INTO gd_buffer.
      ENDLOOP.
      TRANSLATE gd_buffer USING '~ '.
      DO.
        it_mess_att = gd_buffer.
        APPEND it_mess_att.
        SHIFT gd_buffer LEFT BY 255 PLACES.
        IF gd_buffer IS INITIAL.
          EXIT.
        ENDIF.
      ENDDO.
    ENDFORM.
    *       FORM delete_spool                                             *
    FORM delete_spool.
      DATA: ld_spool_nr TYPE tsp01_sp0r-rqid_char.
      ld_spool_nr = gd_spool_nr.
      CHECK p_delspl <> c_no.
      CALL FUNCTION 'RSPO_R_RDELETE_SPOOLREQ'
           EXPORTING
                spoolid = ld_spool_nr.
    ENDFORM.
    Regards,
    Gayathri

Maybe you are looking for

  • Issue in SAP CPS for Job Interception

    Issue in SAP CPS for Job Interception Scenario: After triggering a Process Chain in BW and maintaining the Job Interception settings in SAPCPS(Redwood) (so that any job which triggers in BW by that Particular User is intercepted and not let it procee

  • Which compact flash card reader (still available) works with core i7?

    Help! My card reader died. I'm having trouble finding a compact flash card reader for my iMac Core i7. I'm shooting with a Canon 7D. Any suggestions?

  • Helpful answers available: 5. Correct answers available: 1

    I see the "Helpful answers available: 5. Correct answers available: 1" statement on top of unanswered threads. Even though there are no helpful or correct answers to the question. Why ?

  • Attendance infotype  (2002)

    Hi, When I am creating any attendance in infotype 2002 with number of working hours. System is automatically generating start time and end time in the info type based on daily work schedule times. Example : Att type "ATTN-Attendance Hours(AWART)" wit

  • Slide Show does not work properly

    When reviewing a previously created slide show or when creating a new one, the first slide appears in the window.  As the current slide indication at the bottom of the screen advances, the main screen goes blank. When I hit pause, the current slide w