Index: pdfbox/src/test/java/org/apache/pdfbox/TestTextToPdf.java
===================================================================
--- pdfbox/src/test/java/org/apache/pdfbox/TestTextToPdf.java	(revision 0)
+++ pdfbox/src/test/java/org/apache/pdfbox/TestTextToPdf.java	(revision 0)
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.pdfbox;
+
+import java.io.IOException;
+import java.io.StringReader;
+import java.util.List;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.apache.pdfbox.pdmodel.PDDocument;
+import org.apache.pdfbox.pdmodel.PDDocumentCatalog;
+import org.apache.pdfbox.pdmodel.PDPage;
+import org.apache.pdfbox.TextToPDF;
+
+/**
+ * Test suite for TextToPDF.
+ */
+public class TestTextToPdf extends TestCase
+{
+    /**
+     * Test class constructor.
+     *
+     * @param name The name of the test class.
+     *
+     * @throws IOException If there is an error creating the test.
+     */
+    public TestTextToPdf( String name ) throws IOException
+    {
+        super( name );
+    }
+    
+    /**
+     * This test ensures that a PDF created from an empty String is still readable by Adobe Reader
+     */
+    public void testCreateEmptyPdf() throws Exception
+    {
+    	TextToPDF pdfCreator = new TextToPDF();
+    	StringReader reader = new StringReader("");
+    	PDDocument pdfDoc = pdfCreator.createPDFFromText(reader);
+    	reader.close();
+        pdfDoc.close();
+        
+        // In order for the PDF document to be openable by Adobe Reader, it needs
+        // to have some pages in it. So we'll check that.
+        PDDocumentCatalog docCatalog = pdfDoc.getDocumentCatalog();
+        List allPages = docCatalog.getAllPages();
+        assertNotNull("All Pages was unexpectedly null.", allPages);
+        assertEquals("Wrong number of pages.", 1, allPages.size());
+    }
+
+    /**
+     * Set the tests in the suite for this test class.
+     *
+     * @return the Suite.
+     */
+    public static Test suite()
+    {
+        return new TestSuite( TestTextToPdf.class );
+    }
+
+    /**
+     * Command line execution.
+     *
+     * @param args Command line arguments.
+     */
+    public static void main( String[] args )
+    {
+        String[] arg = {TestTextToPdf.class.getName() };
+        junit.textui.TestRunner.main( arg );
+    }
+}
Index: pdfbox/src/test/java/org/apache/pdfbox/TestAll.java
===================================================================
--- pdfbox/src/test/java/org/apache/pdfbox/TestAll.java	(revision 1042220)
+++ pdfbox/src/test/java/org/apache/pdfbox/TestAll.java	(working copy)
@@ -75,6 +75,7 @@
         suite.addTestSuite( TestPDDocumentInformation.class );
         suite.addTestSuite( org.apache.pdfbox.pdmodel.graphics.optionalcontent.TestOptionalContentGroups.class );
         suite.addTestSuite( org.apache.pdfbox.util.TestLayerUtility.class );
+        suite.addTestSuite( org.apache.pdfbox.TestTextToPdf.class );
         return suite;
     }
 }
Index: pdfbox/src/main/java/org/apache/pdfbox/TextToPDF.java
===================================================================
--- pdfbox/src/main/java/org/apache/pdfbox/TextToPDF.java	(revision 1042220)
+++ pdfbox/src/main/java/org/apache/pdfbox/TextToPDF.java	(working copy)
@@ -56,8 +56,8 @@
         PDDocument doc = null;
         try
         {
-
-            int margin = 40;
+        	
+            final int margin = 40;
             float height = font.getFontDescriptor().getFontBoundingBox().getHeight()/1000;
 
             //calculate font height and increase by 5 percent.
@@ -69,8 +69,17 @@
             PDPageContentStream contentStream = null;
             float y = -1;
             float maxStringLength = page.getMediaBox().getWidth() - 2*margin;
+            
+            // There is a special case of creating a PDF document from an empty string.
+            boolean textIsEmpty = true;
+            
             while( (nextLine = data.readLine()) != null )
             {
+            	
+            	// The input text is nonEmpty. New pages will be created and added
+            	// to the PDF document as they are needed, depending on the length of
+            	// the text.
+            	textIsEmpty = false;
 
                 String[] lineWords = nextLine.trim().split( " " );
                 int lineIndex = 0;
@@ -94,6 +103,8 @@
                            lengthIfUsingNextWord < maxStringLength );
                     if( y < margin )
                     {
+                    	// We have crossed the end-of-page boundary and need to extend the
+                    	// document by another page.
                         page = new PDPage();
                         doc.addPage( page );
                         if( contentStream != null )
@@ -122,6 +133,15 @@
 
 
             }
+            
+            // If the input text was the empty string, then the above while loop will have short-circuited
+            // and we will not have added any PDPages to the document.
+            // So in order to make the resultant PDF document readable by Adobe Reader etc, we'll add an empty page.
+            if (textIsEmpty)
+            {
+            	doc.addPage(page);
+            }
+            
             if( contentStream != null )
             {
                 contentStream.endText();
@@ -140,7 +160,7 @@
     }
 
     /**
-     * This will create a PDF document with a single image on it.
+     * This will create a PDF document with some text in it.
      * <br />
      * see usage() for commandline
      *
