Writing Html Content into PDF using JSP

Dear All,
I am using JSP to generate Employee payslip dynamically. Presently i am diplaying payslip as on-screen display.
Here i want to give option "Save as PDF". I am able to create PDF file using IText Libraries. i want to integrate HTML code into the PDF file.
Writing HTML Content (using HTML Tags) into PDF.

Well it is a difficult ask and i believe we are trying to re-invent the wheel
Just to make my life simple i could have choosen either sample API given below to serve my cause
1).[http://xmlgraphics.apache.org/fop/] (Apache FOP one can simply write an XSL template of their and then substitute the values from respective DTO's by using XSL - XML transformations and can generate content in different formats which includes PDF aswell)
2).[http://jasperforge.org/plugins/project/project_home.php?group_id=102] (Just design a simple report template using iReport and create a jrxml files and write a small code snipett such that you can pass few details at the runtime and can export the report in different formats which includes PDF aswell)
3).[http://www.object-refinery.com/jfreereport/] (Is much similar to what jasper offers in order to compile these you can either use pentaho product IDE or BEA/Oracle Actuate report tools)
You can simply try searching for different examples for getting more help on using the respective API's
Hope that helps :)
REGARDS,
RaHuL

Similar Messages

  • Convert html into tidy html to convert pdf using iText

    hello.
    I am try to convert html document into pdf.
    first i tried iText it works properly. but it needs all the tags to be witten correctly.
    when u try html not well formeted it gives an exception.
    So is there any way to convert html to pdf.
    or if not if not then way to convert html into properly taged HTML
    so it s easy to convert it to html,
    If you have any working example of Tidy.jar please send me.
    Thanks..

    Hi,
    I had a similar tasko to do i.e converting HTML to PDF.
    Please follow the link to this site and download the trial code.
    http://www.pd4ml.com
    I was able to convert my HTML to PDF.
    Have a look at it and let me know.
    Regards,
    Joe

  • Converting xml file with arabic content to pdf using FOP

    Hello all
    I am trying to convert a dynamically generated xml file in which most of the data comes from the oracle database with arabic content, to pdf using FOP. I have used "Windows-1256" encoding for the xml. If i open the xml generated with the internet explorer the arabic content displays properly but the pdf is not generated and the acrobat reader shows the file as corrupted or not supported. Please help me. Its very urgent.
    Thanks & Regards
    Gurpreet Singh

    There is no direct support for importing RTF from an XML extract. Perhaps feature 1514 "Mapping formatted XML data into multiline field" will be of some use. This was released in 11.0, I believe.
    Essentially you can establish paragraph and certain text formatting like bold and underline when you include the proper token information in the data. I believe this is similar to simple HTML tokens.
    Example: <FIELD><P>First paragraph of data.</P><P>New paragraph with <B><U>bold and underline text</U></B>. Rest of paragraph normal.</P></FIELD>
    The result is something like this:
    <P>First paragraph of data.</P><P>New paragraph with <B><U>bold and underline text</U></B>. Rest of paragraph normal.</P>

  • Error while trying to export a report into PDF using JRC (Linux env)

    Hi all,
    I have my web app installed on a Linux environment. When trying to export a CR report into PDF using JRC
    PrintOutputController controller = reportClientDoc.getPrintOutputController();
              ByteArrayInputStream byteArrayInputStream = (ByteArrayInputStream) controller.export(ReportExportFormat.PDF);
    I got this error message:
    19/02/2009     10:21:37     b     INFO     PdfExporter: PdfDocumentModeller.modelPage (page 1)
    19/02/2009     10:21:37     b     INFO     PdfExporter: Modelling page
    19/02/2009     10:21:37     b     INFO     PdfExporter: Creating document manager, text modeller and image modeller.
    19/02/2009     10:21:37     b     ERROR     PdfExporter: Exception caught in PDFFormatter.formatPage (from PdfDocumentModeller.modelPage); aborting export
    java.lang.IllegalArgumentException: Data type is not supported.
         at java.awt.image.Raster.createInterleavedRaster(Raster.java:212)
         at java.awt.image.Raster.createInterleavedRaster(Raster.java:178)
         at java.awt.image.ComponentColorModel.createCompatibleWritableRaster(ComponentColorModel.java:2826)
         at java.awt.image.BufferedImage.<init>(BufferedImage.java:439)
         at com.crystaldecisions.reports.exporters.format.page.pdf.pdflib.u.<init>(Unknown Source)
         at com.crystaldecisions.reports.exporters.format.page.pdf.b.k.a(Unknown Source)
         at com.crystaldecisions.reports.exporters.format.page.pdf.b.k.a(Unknown Source)
         at com.crystaldecisions.reports.exporters.format.page.pdf.b.d(Unknown Source)
         at com.crystaldecisions.reports.exporters.format.page.pdf.b.a(Unknown Source)
         at com.crystaldecisions.reports.formatter.a.c.a(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.PrintOutputController.export(Unknown Source)
         at com.crystaldecisions.sdk.occa.report.application.PrintOutputController.export(Unknown Source)
         at com.crystaldecisions.reports.sdk.PrintOutputController.export(Unknown Source)
    On my Windows environment the JRC export into PDF work perfectly. I know that there are some known issues regarding the usage of JRC on Linux environments. Could this be one of those?
    Any solution (or workaround) would be highly appreciated!
    Thank you!
    PS Maybe this is relevant: I use a MySQL database!
    Edited by: Sandila Catalin on Feb 19, 2009 10:01 AM

    What kind of image do you have in the report?
    Do you have -Djava.awt.headless=true specified for the Java JVM option?
    Sincerely,
    Ted Ueda

  • Setting Font for converting multiple text files into PDF using VB 6.0

    Dear All,
    Am converting multiple text files into PDF using VB6.0. Currently, am unable to control the font face and size for the generated files. Below is the procedure am using for each file;
    Public Sub proc_convert_to_PDF(srcFilename As String, destFilename As String)
    Dim p_AcroApp As CAcroApp
    Dim p_VDoc As CAcroAVDoc
    Dim p_DDoc As CAcroPDDoc
    Dim IsOk As Boolean
    Set p_AcroApp = CreateObject("AcroExch.App")
    Set p_VDoc = CreateObject("AcroExch.AVDoc")
    Call p_VDoc.Open(srcFilename, "")
    Set p_VDoc = p_AcroApp.GetActiveDoc
    If p_VDoc.IsValid Then
    Set p_DDoc = p_VDoc.GetPDDoc
    ' Fill in pdf properties.
    p_DDoc.SetInfo "Title", Format(Date, "dd-mm-yyy")
    p_DDoc.SetInfo "Subject", srcFilename
    If p_DDoc.Save(1 Or 4 Or 32, destFilename) <> True Then
    MsgBox "Failed to save " & srcFilename
    End If
    p_DDoc.Close
    End If
    'Close the PDF
    p_VDoc.Close True
    p_AcroApp.Exit
    'Clear Variables
    Set p_DDoc = Nothing
    Set p_VDoc = Nothing
    Set p_AcroApp = Nothing
    End Sub
    What I need;
    1) to be able to set the font face of the destination file ( destFilename)
    2) to be able to set the font size of the destination file ( destFilename)
    Am using Adobe Acrobat 7.0 Type Library
    Kindly Help.
    Thanks in advance

    We didn't say it doesn't work. We said it isn't supported.
    There are a number of other ways to make a PDF. The one which would
    give the most control is if your application directly printed to GDI,
    controlling the font directly. This could print to Adobe PDF.
    You could look for an application that gives control of font for
    printing.
    You could use a text-to-PostScript system and distill the result. You
    could even look for a non-Adobe text-to-PDF.
    Working in the unsupported and dangerous world you chose, the font
    size for text conversion is set (and this is very bad design from
    Adobe) in the settings for Create PDF > From Web Page. There is no API
    to this.
    Aandi Inston

  • How to use OCR Font A type by the time of writing some text into Pdf fil

    Hi,
    I am generating one pdf file in java. How can I use OCR Font A for text of pdf file ..Please can any one help where can I get OCR Font A and how to use that one in java ... I want to write some text into pdf file and that text should use OCR Font A family ...
    Thanks.

    This document shows how to disable OCR during conversion; just do the opposite: https://forums.adobe.com/docs/DOC-3062

  • Could not get exact contents from pdf using adobe acrobat professional

    Hi,
    I am using acrobat professional to extract contents from a pdf into HTML. During extraction of pdf into HTML some contents are getting rendered as images. But with pdf to xml extraction i can get the exact contents. But i need HTML file from pdf. Any suggestions. Thanks in advance.

    You might want to see if you can select the background with the object touchup tool. If so, can you then just delete the selected object. May take a while to go through the document, but if it solves the problem you are ahead. You may be able to select it with JavaScript and repeat the process. My point of using the object touchup tool is that it may not be a background set by Acrobat, but something that is simply labeled as an image from the Acrobat viewpoint.

  • How to export pdf using jsp

    hai friends
    i know to export excel using jsp
    but tried the same process to pdf, it s not work..
    please give some solution......
    thanks
    rex

    It's working absolutely fine for me. I suspect the problem is one of these two:
    1. You're giving the incorrect path of the file. Check the size of the downloaded file, it's probably 0 bytes.
    2. Check the file that has been created on the server first; is that fine? That could also be the origin of the problem.
    This is th code I've used. I copied an existing PDF to my webapps root folder ( $CATALINA_HOME/webapps/myApp/test.pdf ) and hardcoded the values of filename to check it and it works for me.
    BufferedOutputStream out = new BufferedOutputStream( resp.getOutputStream());
    try
        filename = "test.pdf";
        resp.setContentType("application/pdf");//vnd.ms-excel" );
       resp.setHeader("Content-disposition","attachment; filename=\"" + filename + "\"" );
        BufferedInputStream bufferedInputStream = new BufferedInputStream(new FileInputStream(getServletContext().getRealPath("/") + filename));
        int i;
        while ((i=bufferedInputStream.read()) != -1)
         out.write(i);
        bufferedInputStream.close();
      out.flush();
       out.close();
    catch ( Exception e )
         System.out.println(e);
    }

  • How to put data into textbox using JSP

    How can I put data into a textbox using JSP?
    This code prints to a html page but I want it inside an text area:
    // Print out the type and file name of each row.
            while(ftplrs.next())
                int type = ftplrs.getType();
                if(type == FtpListResult.DIRECTORY)
                    out.print("DIR\t");
                else if(type == FtpListResult.FILE)
                    out.print("FILE\t");
                else if(type == FtpListResult.LINK)
                    out.print("LINK\t");
                else if(type == FtpListResult.OTHERS)
                    out.print("OTHER\t");
                out.print(ftplrs.getName() +"<br>");
            }I have tried with the code below:
    <textarea name="showDirectoryContent" rows="10" cols="70">
    <%
           // Print out the type and file name of each row.
            while(ftplrs.next())
                int type = ftplrs.getType();
                if(type == FtpListResult.DIRECTORY)
    %>
                    <%= "DIR\t" %>
    <%            else if(type == FtpListResult.FILE) %>
                    <%= "FILE\t" %>
    <%            else if(type == FtpListResult.LINK)  %>
                    <%= "LINK\t" %>
    <%            else if(type == FtpListResult.OTHERS) %>
                    <%= "OTHER\t" %>
    <%            String temp = ftplrs.getName() +"<br>");
                  <%= temp > <br>
    %>
    </textarea>I get the following error:
    Location: /myJSPs/jsp/grid-portal-project/processviewfiles_dir.jsp
    Internal Servlet Error:
    org.apache.jasper.JasperException: Unable to compile Note: sun.tools.javac.Main has been deprecated.
    C:\tomcat\jakarta-tomcat-3.3.1\work\DEFAULT\myJSPs\jsp\grid_0002dportal_0002dproject\processviewfiles_dir_3.java:151: 'else' without 'if'.
    else if(type == FtpListResult.FILE)
    ^
    C:\tomcat\jakarta-tomcat-3.3.1\work\DEFAULT\myJSPs\jsp\grid_0002dportal_0002dproject\processviewfiles_dir_3.java:165: 'else' without 'if'.
    else if(type == FtpListResult.LINK)
    ^
    C:\tomcat\jakarta-tomcat-3.3.1\work\DEFAULT\myJSPs\jsp\grid_0002dportal_0002dproject\processviewfiles_dir_3.java:179: 'else' without 'if'.
    else if(type == FtpListResult.OTHERS)
    ^
    C:\tomcat\jakarta-tomcat-3.3.1\work\DEFAULT\myJSPs\jsp\grid_0002dportal_0002dproject\processviewfiles_dir_3.java:193: ';' expected.
    String temp = ftplrs.getName() +"");
    ^
    4 errors, 1 warning
         at org.apache.tomcat.facade.JasperLiaison.javac(JspInterceptor.java:898)
         at org.apache.tomcat.facade.JasperLiaison.processJspFile(JspInterceptor.java:733)
         at org.apache.tomcat.facade.JspInterceptor.requestMap(JspInterceptor.java:506)
         at org.apache.tomcat.core.ContextManager.processRequest(ContextManager.java:968)
         at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:875)
         at org.apache.tomcat.core.ContextManager.service(ContextManager.java:833)
         at org.apache.tomcat.modules.server.Http10Interceptor.processConnection(Http10Interceptor.java:176)
         at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:494)
         at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:516)
         at java.lang.Thread.run(Thread.java:536)
    Please help???

    Yes indeed this works:
    <textarea name="showDirectoryContent" rows="10" cols="70">
    <%
           // Print out the type and file name of each row.
            while(ftplrs.next())
                int type = ftplrs.getType();
                if(type == FtpListResult.DIRECTORY)
    {%>
                    <%= "DIR\t" %>
    <%}            else if(type == FtpListResult.FILE)  {%>
                    <%= "FILE\t" %>
    <%}            else if(type == FtpListResult.LINK)  {%>
                    <%= "LINK\t" %>
    <%}            else if(type == FtpListResult.OTHERS) %>
                    <%= "OTHER\t" %>            
                  <%= ftplrs.getName() %>
    <%
    %>

  • Writing html page into word document

    HI,
    I want to write the HTML document using java code in to a word document.
    When I save the webpage as word document. It's properly saving the font...
    I almost did it with following code but the font is missing it is just writing all the text in single font.I want the exact replica of the html page in to the word document.Plz help me out with some input.
    Thanx in advance.
    Regards,
    Ashok.
    public String readContent(){
    String contText="";
    EditorKit kit = new HTMLEditorKit();
    Document doc = kit.createDefaultDocument();
    // The Document class does not yet
    // handle charset's properly.
    doc.putProperty("IgnoreCharsetDirective",Boolean.TRUE);
    try {
    // Create a reader on the HTML content.
    Reader rd = getReader(fileName);
    // Parse the HTML.
    kit.read(rd, doc, 0);
    // Iterate thsrough the elements
    // of the HTML document.
    //ElementIterator it = new ElementIterator(doc);
    //javax.swing.text.Element elem;
    //while ((elem = it.next()) != null) {
    //SimpleAttributeSet s = (SimpleAttributeSet)elem.getAttributes().getAttribute(HTML.Tag.A);
    // code to read the content
    int nleft = doc.getLength();
    Segment text = new Segment();
    int offs = 0;
    text.setPartialReturn(true);
    while (nleft > 0) {
    contText+=doc.getText(offs,nleft);
    System.out.println(contText);
    // do someting with text
    nleft -= text.count;
    offs += text.count;
    if(nleft > 0)break;
    /*if (s != null) {
    //System.out.println(s.getAttribute(HTML.Attribute.HREF));
    System.out.println(s.getAttribute(HTML.Attribute.HREF));
    } catch (Exception e) {
    e.printStackTrace();
    //System.exit(1);
    return contText;
    } //end of reading content method
    static Reader getReader(String uri)
    throws IOException {
    if (uri.startsWith("http:")) {
    // Retrieve from Internet.
    URLConnection conn = new URL(uri).openConnection();
    return new InputStreamReader(conn.getInputStream());
    } else {
    // Retrieve from file.
    return new FileReader(uri);

    Maybe Im missing something here, but where are you doing anything using MS Word? I see you write the text to std out but where does it go to a word document? How do you create the word document, using JNI or is it a java API?

  • Writing data programmatically into PDF template created in LiveCycle designer

    Hi!!!
    I have a PDF template designed in Adobe LiveCycle Designer 7.0. This template has form fields which needs to be filled with data programmatically (I don't want to open LiveCycle Designer 7.0 and from there do import/export). I want to write a program in java, which will fetch data from database and will merge this data into PDF form in respective fields.
    How this can be achieved? Do I have to write an XDP file? Is there any API which will create XDP out of the PDF template created in designer? If so, then how to merge the data from the XDP into the PDF programmatically.
    Thanks in advance.
    - Shriram

    [email protected] wrote:
    > If I correctly understand what you're trying to do then Adobe XPAAJ should be adquate:
    >
    >
    >
    > Below is a link to a "video" demonstration of building an application that uses XPAAJ:
    >
    >
    >
    > (I don't think your question about having to write an XDP file is crucial to what you're trying to do, but you don't need to write an XDP file -- it is a "save as" option within Designer. You can save a Designer file as either PDF or XDP. Or both, one after the other, if you need both.)
    Careful with the recommendations for XPAAJ. There are specific restrictions around whether you can
    use XPAAJ or not. Specifically, you have to own a copy of one of the server-based LiveCycle
    products. This does not include LiveCycle Designer, which is a client product.
    Maybe someone from Adobe can clarify.
    Justin Klei
    Cardinal Solutions Group
    www.cardinalsolutions.com

  • Converting a word 2000 file into pdf using Adobe Acrobat Standard X

    I reinstalled my Adobe Acrobat Standard X today, and tried to convert a *.doc word file into pdf, but the application could not open the word file and got stalled. I remembered that last time I installed the application the same probelm cropped up and I had to install a Microsoft patch that was required to do this, What is the patch file and how do I get it?

    I answer my question myself. I have solved it myself. The answer can be found by searching adobe website. But I give it here if it can be useful to others. Go to control panel. Go to Add or remove programs. Click on Modify in the listed Adobe program. Click Next in the box that appears. Select Modify. Click on + sign against pdF maker to expand. Click on X sign against 'this feature is not available' which shifts on to the little box on the left of Microsoft Office. Click on Apply. Quit. Once the Microsoft Office becomes disabled in Adobe, Word will open in all places.

  • Inserting HTML content into an animated DIV

    Can you, and if so how, insert HTLM content into an EGDE animated Div box? Specificaly an HTML table?  I can get the html code in the box but it won't read/render it as html code. In flash you can tell the program that the contents of the box is html code and it will read it as such but I don't see any way to do that here. I've tried several ways and I can get the code to display in the box but it won't render the code instruction in the boxCan it be done ??
    Thanks
    joel

    Hi,
    1) Your json file is not valid.
    You can copy and paste your datas here: http://jsonlint.com/
    Red commas must be deleted.
          "player": [
                "image": "images/player1.jpg",  //this is the URL I want to retrive
               "name": "player1",
                "image": "images/player2.jpg",
                "name": "player2", 
                "image": "images/player3.jpg",
                "name": "player3", 
                "image": "images/player4.jpg",
                "name": "player4",
    2)An example from http://docs.jquery.com/Ajax/jQuery.getJSON:
    3) compositionReady Tests.
    On compositionReady, i write:
    var profiles = {
                   "player": [
                        "image": "images/player1.jpg",
                        "name": "player1",
                         "image": "images/player2.jpg",
                         "name": "player2", 
                         "image": "images/player3.jpg",
                         "name": "player3", 
                         "image": "images/player4.jpg",
                         "name": "player4",
    console.log(profiles.player[1].image); // this line returns: "images/player2.jpg"
    Note: i deleted the first "[" and the last "]".

  • Storing / Retrieving PDF using JSP and Oracle

    Dear All
    I am building web application using Macromedia Dreamweaver , using JSP , Tomcat and Oracle 10gR1.
    I need to build a JSP to upload a PDF file to the database and have a way to retrieve it from the database ,, all through JSP .
    I need hints about the building architecture and how it is done ,, samples of code will be great.
    Thank You Very Much

    Use JSP, Servlet and some third party API (Apache Common File Upload) to store the PDF document in blob column.
    --Balaji S                                                                                                                                                                                                                                                           

  • Urgent ! writing html document into msword

    Hi,
    I would like to write html document into word document(save as).
    More over the word document is a template(with company's header and footer).the html code should go and sit in the template document.do I have to use some external pkg like jacob or it's possible in java.Plz any input would help me a lot.
    Regards,
    Ashok.

    Word is Windows creature and has perfect COM automaion interfaces, just write your application with Delphi. Other platforms have nothing to do with Word.

Maybe you are looking for

  • Sharpness of Photos in Lightroom 5.3

    Can anyone please provide an explanation as to why my pictures when edited in Lightroom 5.3 appear soft and seem to require too much sharpening for an acceptable screen view.    When pictures are subsequently made ready for printing from Lightoom 5.3

  • Select returns negative values for unsigned datatypes in MySQL DB

    Hi, I have a table in a MySQL database where some fields are declared as "unsigned". Example: CREATE TABLE countries ( Country_id SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, Number SMALLINT UNSIGNED NOT NULL My problem is when inside a .xs

  • SQ01 SAP adhoc query error

    Hi, We face a very peculiar problem. A particular user is not able to execute the SQ01 queries for some reasons. All the other users are able to execute the queries correctly. When this particular user is trying to execute the query, he gets an error

  • Two black cartridges 7520 one full other empty but not printing black

    My black photo is empty (not sure why, don't use photo) the larger one on the right hand side is almost full but it is not printing anything black.  colors are fine.   I tried playing with the setting but am at a loss.  Please help.  Thanks! This que

  • Create a custom widget

    I would like to create a "component" -- basically a drop-down menu.  Except that my drop-down menu will not select an item when a user clicks on it.  The user must click on it for 2 seconds and then it will be selected.  How can I create this custom