Sample project how to use Itext (pdf) in webdynpro

Hi all,
Have someone a sample how to use Itext in a webdynpro.
Richard

Hi Roberto and Bala,
Sorry, I was thinking the wrong way!!
Please can you check my source, I a'm get an error by opening the new window. the error : D:\PDFfromJava.pdf (The system cannot find the file specified)
this my source:
    //@@begin wdDoInit()
    wdContext.currentPersonalDataElement().setFirstName("Richard");
    wdContext.currentPersonalDataElement().setLastName("Middelburg");
     Document document = new Document();
     try {
      PdfWriter.getInstance(document, new FileOutputStream("D:
PDFfromJava.pdf"));
       document.open();
       document.add(new Paragraph("Hi, this is demo PDF file from JAVA!"));
     catch(DocumentException de) {
     //     wdComponentAPI.getMessageManager().reportException(de.getMessage(),false);
     wdContext.currentContextElement().setTest("fout1");
     }catch(IOException ioe) {
     //     wdComponentAPI.getMessageManager().reportException(ioe.getMessage(),false);
     wdContext.currentContextElement().setTest("fout2");
     File file = new File("D:
PDFfromJava.pdf");// from iText library
     try
          IWDResource wr = WDResourceFactory.createCachedResource(getBytesFromFile(file), "PDF Report", WDWebResourceType.PDF);
          IWDWindow w = wdComponentAPI.getWindowManager().createNonModalExternalWindow(wr.getUrl(0), "PDF Report");
          w.show();
     catch (Exception e)
          wdComponentAPI.getMessageManager().reportException(e.getLocalizedMessage(), false);
          wdContext.currentContextElement().setTest("fout3");
    //@@end
//@@begin others
  public static byte[] getBytesFromFile(File file) throws IOException {
                InputStream is = new FileInputStream(file);
                // Get the size of the file
                long length = file.length();
                // You cannot create an array using a long type.
                // It needs to be an int type.
                // Before converting to an int type, check
                // to ensure that file is not larger than Integer.MAX_VALUE.
                if (length > Integer.MAX_VALUE) {
                     // File is too large
                // Create the byte array to hold the data
                byte[] bytes = new byte[(int)length];
                // Read in the bytes
                int offset = 0;
                int numRead = 0;
                while (offset < bytes.length
                         && (numRead=is.read(bytes, offset, bytes.length-offset)) >= 0) {
                     offset += numRead;
                // Ensure all the bytes have been read in
                if (offset < bytes.length) {
                     throw new IOException("Could not completely read file "+file.getName());
                // Close the input stream and return bytes
                is.close();
                return bytes;
  //@@end
Richard

Similar Messages

  • How to use deafult pdf viewer ? when i give windows in my pc pdf file open in firefox deafultly but suddenly its not working how to fix this ?

    please tell me how to use default pdf reader in firefox ? when i give windows in my pc pdf file open in firefox deafultly but suddenly its not working how to fix this ? pdf not open when i give ok with preview in firefox its not open its offer again same message

    In order to change the default pdf reader please see: [[View PDF files in Firefox without downloading them]]
    In order to change the file association: [[Applications panel - Set how Firefox handles different types of files]]

  • How to use HTML Tags in webdynpro java

    Hi,
         Can any body tell me how to use HTML Tags in webdynpro java.
    If u provide me with sample code it will become more usefull.
    Thanks & Regards,
    SN

    HI,
    Please find the steps:
    Create a html file and store in your webdynpro project
    Add the html contents in your file
    & Create a IFRAME UI element and refer you html file
    Now you able to see the html in webdynpro
    Thanks & Regards,
    Ram

  • How to use Java code inside WebDynpro-ABAP

    Hi,
        How to use Java code inside WebDynpro-ABAP.
    Could any one provide sample code.
    Cheers,
    Sam

    Hi Sam,
    We can't Bring Java Inside the ABAP. Both are running in different Environments.
    and also ABAP Codes are runs on BASIS.
    -Basis is a middleware between ABAP codes and Ur OS.
    -Contains set of programs to load,RUN,intepret the ABAP program..
    So Both are Different.
    Regards,
    Ramganesan K.

  • How to use EPCF eventing in Webdynpro

    Hi All,
    I have made a Webdynpro application as an iview in portal. Now i need to accomplish client eventing between this iview and any other portal iview. I learned from this link
    http://help.sap.com/saphelp_nw04/helpdata/en/d8/6ee03fc2269615e10000000a155106/frameset.htm
    that, this can be done through EPCF.
    I can very well write use the EPCM objects in EP components with the help of Javascript tags.
    But, I learned from my Webdynpro friends and these links
    Re: Javascript in webdynpro application.
    Re: Javascript
    Re: how to make use of javascript functionality in WD application?
    that, Webdynpro is strictly NOT the place for Javascript.
    So, Where and How to use EPCF APIs in Webdynpro?
    Shortly, In an Webdynpro application, where and how can i insert the following line of code.
    WDPortalEventing.subscribe("urn:com.sap.tc.webdynpro.test.portal","TestEvent",wdThis.wdGetTestEventAction());
    Please help me in this regard..
    Vijay.K

    Hi,
    Check this,
    /message/205009#205009 [original link is broken]
    Write that subcribe in the doinit method and handle the event in the action handler
    Check also this
    webdyn iviews and portal eventing:WebDynpro iViews and Portal Eventing
    /message/554249#554249 [original link is broken]
    Communication between 2 IViews on 2 different Pages
    Regards,
    Vijayakhanna Raman
    Message was edited by: Vijayakhanna Raman

  • New a vmware project (create hello world plug-in project),how to use it as a normal plug-in on orchestrator??

    in use:
    eclipse sdk (indigo 3.7.2) windows 7 64bit
    vcenter orchestrator 5.1 (windows 2008 R2)
    vmware - vco- plug-in SDK 5.1
    i installed vmware-vco plug-in sdk 5.1 to eclipse 3.7.2,then i created a vmware project(choose create hello world plug-in project)
    how to do next??
    I  export the project as a jar file,rename it as .dar ,and put it to the vmware/infrastructure/orchestrator/app-server/server/vmo/plugins,,
    then i upload the .dar file,,it reminds me installed failed....
    thanks so much!!!

    i don't think you have to rename the jar and create a dar. Once you have build successful you should get the dar file.
    Online Documentation - vRealize Orchestrator Plug-in SDK 5.5 - VMware Developer Center

  • Sample for how to use DirLstWrite

    I am looking for a sample how to use DirLstWrite. I took a DIAdem training course at the end of March in Michigan for 5 days, my teacher's name is David xxx. He supposes to send me an exsample. I have not received it. Does anyone know his email? My email is [email protected]

    Hello,
    I don't know who the person was that was teaching the class in Michigan, but here is an example of how to use the DirLstWrite command in DIAdem:
    Call DirLstWrite("C:\Datafiles","Test*.dat","filename","test.lst",0)
    Here is a description of the different items that this command is made off:
    Call - VBS function, calls a DIAdem function
    DirLstWrite - Command for storing file names in an ASCII file
    "C:\Datafiles" - Directory in which to search for the data files that need to be put into the LST file
    "Test*.dat" - Parameter to describe the file name(s) that need to be put into the LST file
    "filename" - Parameter that determines how the results will be sorted in the LST file (by file name, by file leng
    th, by extension, by date/time of creation)
    "test.lst" - name of the LST file
    0 - Parameter that determines if the files found with the DirLstWrite function will be added to an exisitng list file or put into a new file (if a file of the same name already exists, it will be overwritten)
    The result of the above example will be this:
    Test1.dat
    Test12.dat
    TestA.dat
    TestC.dat
    I hope this helps. Please let me know if you need additional information.
    Otmar
    Otmar D. Foehner
    Business Development Manager
    DIAdem and Test Data Management
    National Instruments
    Austin, TX - USA
    "For an optimist the glass is half full, for a pessimist it's half empty, and for an engineer is twice bigger than necessary."

  • How to use a PDF template with OA Framework

    I have a question that is hopefully quite simple. I am using JDeveloper to add a button to a page that will create a PDF document.
    According the the documentation it should be quite easy to merge a PDF template file with an XML data file to produce an output PDF file.
    The problem I have is that although I can create the XML data file OK - the output PDF file is not produced (the file gets created but it is 0 bytes - I don't get an error message though). Can someone tell me what I'm doing wrong?
    My code is as follows:
    try
    DataProcessor dataProcessor = new DataProcessor();
    dataProcessor.setDataTemplate("/oraapp02/apphrutv1/hrutv1comn/work_accident.xml");
    Hashtable parameterTable = new Hashtable();
    parameterTable.put("hendelse","3574");
    dataProcessor.setParameters(parameterTable);
    dataProcessor.setConnection(jdbcConnection);
    dataProcessor.setOutput("/oraapp02/apphrutv1/hrutv1comn/accidentout.xml");
    dataProcessor.processData();
    } catch (SQLException e)
    throw new OAException("Couldn't create xml file. SQL Error="+e.getMessage(),OAException.ERROR);
    } catch (XDOException e) {
    throw new OAException("XDOException" + e.getMessage(),OAException.ERROR);
    } catch (ClassNotFoundException e) {
    System.out.println("ClassNotFoundException " + e.getMessage());
    //OK - we created the XML file, now let's send it into the pdf template:
    FormProcessor fProcessor = new FormProcessor();
    fProcessor.setTemplate("/oraapp02/apphrutv1/hrutv1comn/NAV.pdf");
    fProcessor.setData("/oraapp02/apphrutv1/hrutv1comn/accidentout.xml");
    fProcessor.setOutput("/oraapp02/apphrutv1/hrutv1comn/NAVout.pdf");
    fProcessor.process();
    I haven't registered the PDF template file in Oracle Applications - but that shouldn't be the problem should it? Or is it better to use a PDF template that is registered in Oracle Applications?

    Can you give me some tips on setting up the appropriate libraries to use the DataProcessor class? I have tried the BIP libraries and the classes from JAVA_TOP but I always get the same error when the constructor of DataProcessor is called:
    java.lang.NoSuchMethodError: oracle.apps.fnd.i18n.common.util.DateFormatMaskConverter.getJavaDateFormatFromOracle(Ljava/lang/String;Ljava/util/Locale;Z)Ljava/lang/String;
         at oracle.apps.fnd.i18n.common.util.FormatMaskUtil.isOracleCompatible(FormatMaskUtil.java:693)
         at oracle.apps.fnd.i18n.common.util.FormatMaskUtil.detectDateFormatMaskType(FormatMaskUtil.java:580)
         at oracle.apps.xdo.dataengine.Format.<init>(Format.java:68)
         at oracle.apps.xdo.dataengine.XMLPGEN.<init>(XMLPGEN.java:65)
         at oracle.apps.xdo.dataengine.DataProcessor.<init>(DataProcessor.java:168)
    I have been successful in displaying a PDF file in an OAF page but I had to generate the xml data using a PL/SQL package rather than the data template. I know it works because Concurrent Requests using the XDODTEXE executable work and this uses DataProcessor.

  • How to use the PDF creator

    Ok so i get how to create a PDF file but the problem is when my professor opens it up on his computer it shows up blank why is that? i can't fail a class because my work won't show up on his PC.

    So you are adding pages to an existing PDF document. How are you creating the new pages (what application) and how are you producing the modified document in PDF format?
    When you upload your modified document are you doing this via email or uploading to an FTP site?
    BTW, we can do this much faster if you would provide all the information I've requested otherwise we'll keep going back and forth.
    Message was edited by: Kappy

  • How to use security zone in WebDynpro

    Hi.
    I want to use security zone in WebDynpro for java like PDK.
    Is it possible?
    if possible, plz explain detail how to use security zone.

    Hi,
       You can locate the <i>portalapp.xml</i> file for a WD project inside the <i>gen_wdp</i> folder. Check if you can add the <i><component-config></i> tag and others in the <i><webdynpro></i> section of the file.
    Regards,
    Satyajit.

  • How to use two BAPIs in webdynpro Applicaiton?

    Hi All,
    I'm developing one webdynpro application which is using BAPI_FLIGHT_GETLIST for gettting list of flights and then using an other bapi BAPI_FLIGHT_GETDETAIL for getting details of particular flight which is selected from getlist bapi.
    how can use these two BAPI in single application? How to get the flight details after selecting the one row in getlist view?
    please provide me the procedure.
    Regards
    Srikanth

    hi
    First create two models Bapi_flight_getlist, Bapi_flight_getDetails.
    Add these models in your component.
    Do the model binding on Component Controller.
    Comp.Controller>apply template>servicecontroller>flightlist>choose
    Airlineid
    Maxrows
    Expand Output node.
    select Flight_List node.
    ServiceController will automatically generate the method,choose ok.
    Repeat the same for second bapi also.
    choose
    Airlineid
    Connectionid
    Flightdate
    and select Flightdata
    (you can find it by expanding output node).
    after completion of all these steps u will have Getdetilas and getlist bapi details in comp.Controller.
    To avoid overloading in selecting particular node specify different name for node.(eg:output-->output1)
    Contextmapping.
    you do the contextmapping between Comp.Controller and view by choosing appropriate details from comp.controller.
    now you will have GetDetail and GetList nodes data.
    do the view binding.
    Apply template-->select Airlineid
    Maxrows from getlist node.
    again do the
    Apply template-->select Flightdata from getdetailnode.
    onleadselect of table you call the execute methods from comp.controller generated by service Controller.
    Layouttab>table>properties-->onleadselect Event
    create action for it.
    in onleadselect<actionname>
    wdThis.wdGetFirstCompController().executeBapi_Flight_Getdetail_Input();
    wdThis.wdGetFirstCompController().executeBapi_Flight_Getlistl_Input();
    in the output Getlist table will be displayed.
    by clicking on table row,onLeadselectaction will be called.
    you will get the flightdetails.
    i hope this will solve your problem.
    Regards
    sowmya

  • How to use interactice pdf forms correctly in mac?

    A pdf form i created in windows using acrobat 9 pro with some javascript works fine on windows but doesn't work in mac OS. Can anyone please guide me how to rectify this problem?

    I created the pdf forms in acrobat in Windows and i did use the javascript for calculation purpose and on Preview on Mac the calculation is just not happening at all. I also used radio buttons which work fine on windows but on Mac, the tick marks show but the javascript associated with radio buttons is not working at all. Is there a solution to this issue? Any kind of suggestion will be most helpful.

  • How to use a pdf in flash site?

    How do I link a pdf file to a button so it opens when user
    clicks?

    Use getURL("yourpdf.pdf") in the button's actions.
    Dan Mode
    --> Adobe Community Expert
    *Flash Helps*
    http://www.smithmediafusion.com/blog/?cat=11
    *THE online Radio*
    http://www.tornadostream.com
    <--check this
    *Must Read*
    http://www.smithmediafusion.com/blog
    "finnsgirl" <[email protected]> wrote in
    message
    news:f0afkc$cpt$[email protected]..
    > How do I link a pdf file to a button so it opens when
    user clicks?

  • How to use standard pdf forms for HR

    Hi
    We just upgraded our system from 4.6C to ECC6.0. We just did technical upgrade. IF we want to use SAP provided pdf forms for any HR applications like w-2's or something else.. what do  we need.. Can we use them with out ADS ? and without a Java server?
    Thanks

    Hello,
    you need a Java server and need ADS configured. To do this is not easy for me as a application developer, but it is easy for the basis guys. Ask one to make this ready for you. Esitmated time is like 3-5 days. ADS is free for printing (replaces SAPscripts and Smartforms by Adobe forms).
    For HR forms I recommend create your custom ones, because you can develop it very quickly and it will meet any specific requirements of your business. This way you will spare much time and psychic sanity searching and changing SAP HR standard (my 2 yrs experience).
    Have a nice day, Otto
    p.s.: If you have further interest in Adobe, move your questions to Adobe forms forum under NetWeaver.

  • How to use a pdf file just like a jsp file?

    Hi! My question is quite simple, I was wondering if it is possible to use PDF files as if they were html forms and post the data to a servlet with PDFBox? I read the spec and it seems that PDFBox is meant to treat local pdf files, am I right?
    I guess what I will have to do is save the pdf file once the user has finished entering data in it with a unique file name, and then treat the local pdf file with PDFBox... Is that the way to go or is there an other way to use pdf forms just like an html forms and then treat the data in a servlet?
    Thanks!

    Cross-post
    http://forum.java.sun.com/thread.jspa?threadID=617229

Maybe you are looking for