Skip navigation
Currently Being Moderated

submit a PDF as a PDF to a servlet, and how to get my PDF from servlet

Apr 24, 2008 10:02 PM

Hi all as the title above,

i have a button typeformat as PDF and sent to a URL( which is my servlet )
after this step how to get the PDF from my servlet.

the PDF has sent to my servlet and stop, so is there any way to get the PDF i sent ?

can someone help me?

thanks
 
Replies
  • Currently Being Moderated
    Apr 25, 2008 9:54 AM   in reply to (guanwei)
    You can use the following code:

    byte[] content = getRequestBufferAsBytes(request);
    ...then do whatever you want

    public static byte[] getRequestBufferAsBytes(HttpServletRequest request) throws IOException, ServletException
    {
    //
    // get the RequestBuffer
    //
    ServletInputStream oInput = request.getInputStream();
    long nContentLength = request.getContentLength();
    String contentType = request.getContentType();

    if (nContentLength <= 0)
    return null;

    byte[] cContent = new byte[(int)nContentLength];
    //
    // read the content in 512 bytes chunks
    // a single read does not get all the characters
    //
    int nRead = 0;
    int nToRead = (int)nContentLength;
    int nBlkSize = 512;
    byte[] cTemp = new byte[512];
    do {
    int n = 0;
    int i = 0;
    if (nToRead - nRead < 512)
    nBlkSize = nToRead - nRead;

    n = oInput.read( cTemp,0,nBlkSize);
    for (i = 0; i < n; i++)
    cContent[i+nRead] = cTemp[i];
    nRead += i;
    } while (nRead < nToRead);
    //cContent[nRead] = (byte)'\0';
    Long nBytesRead = new Long( nRead );


    return cContent;
    }

    Jasmin
     
    |
    Mark as:
  • Currently Being Moderated
    Apr 26, 2008 1:05 AM   in reply to (guanwei)
    Just a note: do you realise that the free Adobe Reader can't by
    default submit in PDF format, users may need to buy Acrobat?

    Aandi Inston
     
    |
    Mark as:
  • Currently Being Moderated
    Apr 27, 2008 5:25 AM   in reply to (guanwei)
    Aandi, this is false. From WITHIN THE BROWSER Reader CAN do an HTTP post of the PDF. It's only outside the browser that you will either need Acrobat or a Reader Extended PDF to submit the PDF.
     
    |
    Mark as:
  • Currently Being Moderated
    Apr 28, 2008 10:54 PM   in reply to (Lee_Sutton)
    Is that right? I hadn't heard about that. When did it come in?

    Aandi Inston
     
    |
    Mark as:
  • Currently Being Moderated
    Aug 21, 2008 8:40 AM   in reply to (guanwei)
    Note that the "cContent" returned in Jasmin's code above (byte[]) can be passed into a LiveCycle process variable declared as "document".

    -Joel
     
    |
    Mark as:
  • Currently Being Moderated
    Oct 20, 2008 3:44 PM   in reply to (guanwei)
    If you are calling a LiveCycle process, there is no need for the all code shown above, you can simply use the following command...

    Document document = new Document(request.getInputStream());

    Where Document is a com.adobe.idp.Document object.

    Gareth
     
    |
    Mark as:
  • Currently Being Moderated
    Dec 15, 2008 6:35 AM   in reply to (guanwei)
    Hello
    I have a similar requirement and appreciate if any of you could give me a possible solution. I have a PDF form which I would like to post as a PDF document itself to a Servlet on Submit. The servlet has java mail program which would email this PDF document to a specified email address.

    I tried setting the Submit As property to PDF in the button properties and the URL to my servlet. However, for testing purposes, when I have written this code request.getQueryString(); to see what the servlet is receiving, it prints null and am not sure how to get this filled out PDF document emailed on Submit.

    Appreciate your response.
     
    |
    Mark as:
  • Currently Being Moderated
    Dec 15, 2008 6:52 AM   in reply to (guanwei)
    What if you try to get the length of the Document variable. Is it null?

    Document document = new Document(request.getInputStream());
    long size = document.length();

    Jasmin
     
    |
    Mark as:
  • Currently Being Moderated
    Dec 15, 2008 11:03 AM   in reply to (guanwei)
    Hello Jasmin
    Thanks for your response. I tried using the code in my servlet. But, I am not able to create the document object.I imported the package java.swing.text.Document but not able to instantiate the Document object. so, I changed it to

    DefaultDocument document = new DefaultDocument();
    DocumentType size = document.getDoctype();
    System.out.println(size);

    which still prints null. Note: The submit as property in the button object is set to "PDF". I changed it to URL encoded HTTP post and this still prints null. Not sure, what is going on. Appreciate any help.
     
    |
    Mark as:
  • Currently Being Moderated
    Dec 15, 2008 12:36 PM   in reply to (guanwei)
    The Document object is an Adobe data type (com.adobe.idp.Document).

    It's located in the adobe-livecycle-client.jar under C:\Adobe\LiveCycle8.2\LiveCycle_ES_SDK\client-libs\common

    Jasmin
     
    |
    Mark as:
  • Currently Being Moderated
    Dec 16, 2008 10:05 AM   in reply to (guanwei)
    For information about the com.adobe.idp.Document, read this topic -- "Passing data to LiveCycle ES services using the Java API" located at:

    http://livedocs.adobe.com/livecycle/8.2/programLC/programmer/help/0002 69.html

    For more information about using the LiveCycle ES Java APIs, see this URL -- "Invoking LiveCycle ES Using the Java API" at

    http://livedocs.adobe.com/livecycle/8.2/programLC/programmer/help/0002 63.html
     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)