title: PDFBox: Unable to save pdf while running on tomcat
body: <p><a href="https://pdfbox.apache.org/cookbook/documentcreation.html" rel="nofollow">This PDFBOX Example</a> when i run from the main method &amp; run java application then it successfully saving pdf document. But if the same code while running from  doGet method of servlet on Tomcat server, then its NOT saving the pdf file. Very confuse can you help me why? do i have to add some external libarary to support for Tomcat server, please help..</p>
  
  <p>Note : </p>
  
  <ul>
  <li>i have debugged doGet method its getting call not throuwing any</li>
  <li><p>exception Tomcat 6, PDFBox 1.87, all PDFbox dependecies i have
  included in classpath</p>
  
  <pre><code>/* this is the servlet method which is saving pdf file, but the same if run from Main then it saves the "hello world.pdf"*/ 
  public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException {
        try { 
            PDDocument  document = new PDDocument();
               PDPage page = new PDPage();
               document.addPage( page ); 
               // Create a new font object selecting one of the PDF base fonts
               PDFont font = PDType1Font.HELVETICA_BOLD; 
               // Start a new content stream which will "hold" the to be created content
               PDPageContentStream contentStream = new PDPageContentStream(document, page); 
               // Define a text content stream using the selected font, moving the cursor and drawing the text "Hello World"
               contentStream.beginText();
               contentStream.setFont( font, 12 );
               contentStream.moveTextPositionByAmount( 100, 700 );
               contentStream.drawString( "Hello World1" );
               contentStream.endText(); 
               // Make sure that the content stream is closed:
               contentStream.close(); 
               // Save the results and ensure that the document is properly closed:
               document.save( "Hello World.pdf");
  
               document.close();
  
               response.setContentType("text/html"); 
            PrintWriter out = response.getWriter();   
                out.println("&lt;iframe height=\"100%\"   width=\"100%\" src=\"http://eurecaproject.eu/files/4613/9886/3802/report3.pdf\" &gt;&lt;/iframe&gt;");
  
  
      } catch (Exception e) {
          // TODO Auto-generated catch block
  
          System.out.println(e);
      }   
  
  }
  </code></pre></li>
  </ul>