PDF does not show up

Hi all,
The following is my code snippet in JSP for a project which i used to generate a PDF file. But the PDF does not show up . The Adobe loads and i get a pop-up saying
'Acrobat could not open 'Example[1].pdf' because it is either not a supported file type or because the file has been corrupted.'
This is the code snippet i used:
<%@ page import="java.io.*" %>
<%
String s = new String("Hai this is PDF Sample");
byte file[] = s.getBytes();
try
BufferedInputStream inputStream = new BufferedInputStream(new ByteArrayInputStream(file));
BufferedOutputStream outputStream = new BufferedOutputStream(response.getOutputStream());
response.setHeader ("Content-Disposition", "attachment; filename=Example.pdf");
response.setContentType("application/pdf ; charset=iso-8859-1");
int bytes = 0;
byte buffer[] = new byte[1024];
while((bytes = inputStream.read(buffer)) != -1)
outputStream.write(buffer,0,bytes);
inputStream.close();
outputStream.flush();
outputStream.close();
}catch
(Exception e){}
%>
Can anyone please help me out.
Thanks in Advance.
RDP.

FOP is an Apache project that lets you generate PDFs using XML and XSL.
Here's the servlet:
package common.servlets;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringReader;
import java.net.URLDecoder;
import java.util.Map;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.xml.transform.Result;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.sax.SAXResult;
import javax.xml.transform.stream.StreamSource;
import org.apache.fop.apps.Driver;
* A servlet that takes XML and XSL streams and sends back a PDF file,
* using Xalan and FOP.
public class PDFServlet extends HttpServlet
    /** Response content type */
    public static final String DEFAULT_RESPONSE_CONTENT = "application/pdf";
    /** Parameter/attribute name for XML input */
    public static final String DEFAULT_XML_NAME = "print.xml";
    /** Parameter/attribute name for XSL input */
    public static final String DEFAULT_XSL_NAME = "print.xsl";
    /** Default character encoding */
    public static final String DEFAULT_CHAR_ENCODING = "UTF-8";
    /** Transformation factory */
    private TransformerFactory transformerFactory;
     * Initialize the servlet
     * @throws ServletException if the initialization fails
    public void init() throws ServletException
        try
            this.transformerFactory = TransformerFactory.newInstance();
        catch (Exception e)
            throw new ServletException(e);
     *  Process a GET request
     * @param servlet request
     * @param servlet response
     * @throws ServletException if the servlet fails
     * @throws IOException if IO fails
    public void doGet(HttpServletRequest request,
                                 HttpServletResponse response)
        throws ServletException, IOException
        this.doPost(request, response);
     * Process a POST request by looking up the JSP using the source + action
     * parameters
     * @param servlet request
     * @param servlet response
     * @throws ServletException if the servlet fails
     * @throws IOException if IO fails
    public void doPost(HttpServletRequest request,
                       HttpServletResponse response)
        throws ServletException, IOException
        try
            Driver driver = new Driver();
            driver.setRenderer(Driver.RENDER_PDF);
            ByteArrayOutputStream baos  = new ByteArrayOutputStream();
            driver.setOutputStream(baos);
            Map parameters   = request.getParameterMap();
            String xmlString = null;
            if (parameters.containsKey(DEFAULT_XML_NAME))
                xmlString = request.getParameter(DEFAULT_XML_NAME);
            else
                xmlString = (String)request.getAttribute(DEFAULT_XML_NAME);
            String xslString = null;
            if (parameters.containsKey(DEFAULT_XSL_NAME))
                xslString = request.getParameter(DEFAULT_XSL_NAME);
            else
                xslString = (String)request.getAttribute(DEFAULT_XSL_NAME);
            if ((xmlString != null) && (xslString != null))
                xmlString = URLDecoder.decode(xmlString, DEFAULT_CHAR_ENCODING);
                xslString = URLDecoder.decode(xslString, DEFAULT_CHAR_ENCODING);
                Source xml = new StreamSource(new StringReader(xmlString));
                Source xsl = new StreamSource(new StringReader(xslString));
                Result fop = new SAXResult(driver.getContentHandler()); // Intermediate result
                Transformer transformer = this.transformerFactory.newTransformer(xsl);
                transformer.transform(xml, fop);
                response.setContentType(DEFAULT_RESPONSE_CONTENT);
                response.setContentLength(baos.size());
                response.getOutputStream().write(baos.toByteArray());
                response.getOutputStream().flush();
            else
                PrintWriter out = response.getWriter();
                if (xmlString == null)
                    out.println("Missing XML");
                if (xslString == null)
                    out.println("Missing XSL");
        catch (TransformerException e)
            e.printStackTrace(System.err);
            throw new ServletException(e);

Similar Messages

  • Exporting pdf does NOT show my headers and footers

    I export number files to my administrators. I've noticed when I print my file directly from my computer in iWork/Numbers it prints and show the footer and header. However, when I send a bcc to myself when I attach the pdf file to my administrator, it does not show or print my headers and footers. Any ideas?

    Re-reading the original question, it does appear that Gogoette is exporting to PDF then attaching the file to an email versus using the "Send via email as PDf" operation. In that case, setting it to Page View for the export will solve the problem. I had originally thought "Send via email as PDF" was being used. What I noticed is that it doesn't give you the choice of page versus sheet view but if you first go through the motions of exporting, it sets it up. In prior threads about exporting to PDF, we have all recommended using Print, not export, and choosing Print to PDF (rather than to a printer) as the best way to create a PDF. It gives more flexibility, such as allowing you to choose which pages to "print to PDF".

  • Acrobat  adobe  pdf  does  not  show  up  canon  scanner  using

    Hi-I have just installed adobe acrobat pro 6-the problem is i want to scan in some documents and turn them into PDF's but my adobe acrobat does not realise or show that i have a scanner (canon 5000F).I have contacted canon-and they suggested i downloaded some new software for the scanner but when i try and install the new softawre it will not install and just starts up the printer utility thing at the top.They also suggested i try to uninstall the drivers for the scanner first but again when i download the uninstall utility and try to run it it does not run/set up but just starts the printer utility thing again.How can i make adobe acrobat pro 6 realise i have a scanner so as i can scan in documents to turn them into PDF's ? Any suggestions plaese
    thanks
    rick

    Concentrate on getting the scanner working without any Adobe software. Once you can scan to a file, any OSX program (except Adobe) that can read the file can generate PDF files via the Print command.

  • Exporting a PDF for print, the PDF does not show a shadow effect

    I have a drop shadow effect on an EPS object and some type that does not appear when I export the file as a PDF for print. The settings I have it set to are: Adobe PDF Preset: "High Quality Print", Interactive Elements: "Include Appearance", and Color Conversion: "No Color Conversion".
    If anyone could help me I would greatly appreciate it!

    Will,
    Yes, I set my transparency blending space to CMYK. It didn't work.
    I don't have a particular reason I am using an EPS over AI other than that's the type of file this object (logo) was saved as. I can get an AI. Is there any particular reason you recommend not using an EPS?

  • 8859-1  PDF does not show french characters.

    Hi All,
    I am stuck in this issue for 2 days now and finally i decided to post it here.
    I have created a custom oracle report(10G) with BI to open in PDF. The XML prolog Value is defined as <?xml version="1.0" encoding="iso-8859-15"?>
    Now when i run the report in R12 the pdf file shows junk character for french characters(É shown as "%o"). These characters are displayed properly if i look at the XML file. When we run that output from the server we get the weird characters but if we take the same output (XML) file and run it locally using desktop publisher the PDF document shows the French characters
    I check the nls_characterset and it is defined as AL32UTF8(which supports french)
    I read some articles they advise to copy fonts from *$FND_TOP/resource* to *$OA_JRE_TOP* and *$AF_JRE_TOP(lib/fonts)* , but it does no work.
    Also, one of the article says to add files in $JAVA_HOME. But i was not able to find JAVA_HOME and the dba says we have $JAVA_TOP and we are not suppose to change anything here.
    we are using EBS R12.1.3
    oracle reports : 10.1.2.0.2
    Any help on this will be appreciated.
    Regards,
    K

    I believe your only option is to setup Pasta
    How to Setup Pasta Quickly and Effectively [ID 356501.1]
    How to Generate PDF Output With UTF8 in R12? [ID 778970.1]
    HTH
    Srini

  • PDF does not show correct font with RTF template

    Hi,
    I have some doubts regarding fonts in PDF reports.
    when we create any XML report of PDF output type with RTF template, does the font used in the template has to be uploaded to the server?
    I have create a RTF template to produce PDF output with arabic text in Times New Roman font but when i preview the template it shows courier font.
    Please help.

    Hi,
    The document id is discussing general issues with Oracle Reports.
    But my basic question is that Do i need to upload font to XML Publisher when i am using RTF template.
    Or it is RDF report only for which i have to work with uifont.ali
    Please reply.

  • PDF does not show 2 nodes

    Hi
    I have a pdf where under the main node that is  bound to the inetractive form, I have placed two notes.
    Each note is of cardinality 0.n.
    The problem I have is the following: when the pdf is created, only the first subform with the first node is filled with
    data. The second subform however just displays empty rows, the number of which correspond exacly to the number of elements the node has.
    Any suggestion?
    Thank  you and regards
    yuval

    Hi
    The solution I found was to create a node for each subform.
    Apparently in Adobe Interactive Form you simply cannot use the same attribute twice.
    Have fun
    regards
    Yuval

  • When making a PDF version, the PDF does not show my footer. What's up with that?

    Pulling a single page from a book written in Pages, I copy and drop a single page to andother pages document, then from there I export a PDF of that one page document. When the PDF is viewed, there is no header or footer present. What is up with that? I want the doc to look like the original. THX mc

    Pages version? Did you have header and footer on in the new document?
    You could try using Print (Cmd + P) > Click PDF button > Save as PDF. It worked fine on Snow Leopard with Pages 08 and also with Pages 09

  • Adobe PDF Does Not Appear In printer List

    My computer runs Windows XP. Acrobat Standard 6 is installed. "Adobe pdf" does not show in the list of printers. I have installed all available updates, but it still does not show in printer list. I have done a google search on this and have come up with nothing. Any assistance would be greatly appreciated.

    Try to re-install it, after deleting all folders from previous instalation. If still not works, lets see, are you the adm of your network? If not, may this is a network permission while trying to install a new printer. It can be different versions of acrobats installed at same computer too.

  • When printing an AutoCAD-exported PDF file, the paper version has lines that screen does not show

    Hello,
    We were contacted by our customer, a landscape architectural company that uses our product, M-Color, (http://m-color.com) to plot AutoCAD drawings with required preferences and effects.
    However, they provided us with a sample PDF files, that contain examples of scanned drawings, that have some "ghost lines" at the drawings that the screen does not show.
    We tracked the issue and it appears to be an issue with Adobe Reader pringing. We tried many versions from 8.0 version onwards to the latest versions available in public, all represent the same issue.
    This may be an issue of the original drawing having some line that was not marked ending at some point.
    The zip file within the link below has three PDF files, two from the company that brought this issue to our awareness and the one with name "scanstation" is printed by me, and then scanned with markings to explain the issue.
    Any ideas what would be the best solution to solve this issue?
    https://skydrive.live.com/redir?resid=FF1904428CF64324!1445&authkey=!AMwkjv9QMg-Gawg

    Edit>Preferences>Accessibility... Replace Document Colors (use custom colors - black on white)
    That usually fixes ghosting...

  • I really need someone to help me. I have been trying to figure out how to select a PDF document to convert to a Word doc. When I go to select a PDF file, all that shows up is the WORD docs. does not show ANY of my PDF files... Please help me figure out wh

    I really need someone to help me. I have been trying to figure out how to select a PDF document to convert to a Word doc. When I go to select a PDF file, all that shows up is the WORD docs. does not show ANY of my PDF files... Please help me figure out what is going on? We have it set on auto renewal so I know its not that we haven't renewed this subscription, because we pay automatically.

    Hi olivias,
    It sounds like there may be some confusion on your system about what application should be associated with PDF files. You can reset filename associations by following the steps in these articles (depending on your operating system):
    How to change the default application for a file type | Macworld
    http://windows.microsoft.com/en-us/windows/change-default-programs#1TC=windows-7
    Please let us know if you have additional questions.
    Best,
    Sara

  • Adobe Illustrator CS5 does not show PDF thumbnails when browsing

    When I am browsing through PDF files to open one of them in Adobe Illustrator CS5 it does not show the thumbnail.  When I am browsing in Adobe Acrobat it does show the thumbnails.  If I have Adobe Acrobat open and am browsing through files and the thumbnails are showing then if I open Adobe Illustrator and browse for a file the thumbnail does show up. 
    How can I get Illustrator to always show the PDF thumbnails.  I have to frequently browse through thousands of PDF files and it is imperative that I can see the thumbnail for these PDF files.  I primarily use Illustrator to edit PDF files.
    The computer is Windows 7 Enterprise 64 bit edition.  Thumbnails barely work when browsing files through Explorer.  Some thumbnails will show, but not very many of them and it is extremely slow to load the thumbnails that will display.

    Bob,
    So I am assuming you are talking about viewing the files using this method first:
    To use the 32-bit version of Windows Explorer, follow these steps:
    Click Start, click Run, type the following in the Open box, and then click OK:
    Drive_Letter:\windows\syswow64\explorer.exe /separate
    Note The placeholder Drive_Letter represents the drive where the x64-based version of Windows is installed.
    Please let me know if I am missing what you are saying here.

  • Background does not show up when creating a PDF in InDesign

    I have placed the same image in Illustrator and the PDF does show up the image.

    Ooh. Ok. Thank you! I'm using InDesign CS5.5, Acrobat 10.1.6. Mac OSX (10.6.8).
    Layer 1: background (TIFF): does not show up
    Layer 2: Type and logos (EPS): do show up in my pdf.
    -When I select Overprint Preview in Indesign the background is missing.
    -I have created pdfs in different presets (smallest, high quality, etc) and still background does not show up.
    -When I place ONLY the background on a new InDesign document, it does show up in the PDF.
    -I have created a pdf with the background in Illustrator and it does show in my PDF.
    Thanks!

  • HT4075 when i drag the pdf file over other (in previewer) to merge it does not show green circle with plus one. what to do?

    when i drag the pdf file over other (in previewer) to merge it does not show green circle with plus one. what to do?

    Hello djensen1x,
    Could you please let me know what version of Acrobat are you using.
    Also, tell me your workflow of combining those PDF files?
    Please share the screenshot of the error message that you get.
    Hope to get your response.
    Regards,
    Anubha

  • Newest Adobe Reader not working with 8.1 IOS...Adobe icon does not show when pdf docs are saved...also printing pdf documents take forever.  I uninstallled and reinstalled...issues continue

    Latest AdobeReader not working properly with 8.1 IOS...Adobe icon does not show on saved PDF's and printing from PDFs takes forever. I uninstalled and reinstalled latest Reader

    zoer1,
    Adobe icon does not show on saved PDF's
    Would you provide more details about the problem?  A screenshot would be helpful.
    The following FAQ document describes the steps to add a screenshot to your forum message.
    How to add a screenshot to a forum message from iPad/iPhone
    Regarding printing PDF documents...It depends on the PDF document that you are trying to print.  In general, it will take longer to print more complex and larger PDF documents.
    If you are willing to share your PDF document (that takes forever to print) with us at [email protected], we can test it with the same version (11.6.3) of Adobe Reader on different iOS versions (iOS 7.x vs. iOS 8.x).  Please include the link to this forum (https://forums.adobe.com/thread/1616231) in your email message for reference.
    Actual printing is handled by iOS (not by Adobe Reader) via AirPrint over Wi-Fi connection.  We've heard from other users about iOS 8 Wi-Fi connectivity problems.
    You may also want to search for similar issues on Apple Support Communities.

Maybe you are looking for

  • Photo stream doesn't work

    Dear all, I make a photo (on Iphone 4 or Ipad2) and these photos do not appear anywhere else, while Photo stream is put On. on all three devices (ipad, iPhone, Mac Book Pro iPhoto). Do I miss a button? Is it because I migrated from mobileme to iCloud

  • Error 673492112 occurred SQLSetConnectAttr failed

    I get the following error occasionally. Error 673492112 occurred. Description: Connect - [Microsoft][ODBC Microsoft Access Driver] The database has been placed in a state by an unknown user that preventes it from being opened or locked.[Microsoft][OD

  • Regarding sample code to update partner function using SD_PARTNER_UPDATE

    Hi All, Please provide some sample code to update/add partner function using FM 'SD_PARTNER_UPDATE'. regards Vishnu

  • ODAC vs oracle client on Windows server 2008

    Hello, Apologies in advanced if this is a silly question. I am currently working with a .NET application team that connects to oracle. I am attempting to host there application on my servers. I have tested connectivity to there DB with SQLplus using

  • Organizer will not open on PSE 8 Mac, how do i access?

    I just installed PSE 8 for Mac. I chose this version of PSE for the organizer which I was trained in and intend to transfer files from I -Photo (someway) to PSE. Anyway the issue now is that there is no organizer tab to set up organization. There is