@Test
public void spaceTrimPdfDocumentTest() throws DocumentException, IOException {

    Document doc = new Document(PageSize.A4, 50, 30, 50, 30);
    PdfWriter writer = PdfWriter.getInstance(doc, new FileOutputStream(new File(OUTSPTRIMDOC)));
    doc.open();
    Phrase under = new Phrase();
    under.setFont(new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.UNDERLINE));
    under.add(new Chunk(" 1                                                      1                                                                                                                             9      "));
    doc.add(under);
    doc.close();
    writer.close();
    PdfReader reader = new PdfReader(OUTSPTRIMDOC);
    MyTextRenderListener listener = new MyTextRenderListener();
    PdfContentStreamProcessor processor = new PdfContentStreamProcessor(listener);
    PdfDictionary pageDic = reader.getPageN(1);
    PdfDictionary resourcesDic = pageDic.getAsDict(PdfName.RESOURCES);
    processor.processContent(ContentByteUtils.getContentBytesForPage(reader, 1), resourcesDic);
    //should be 60, as in @spaceTrimColumnTextTest
    //Assert.assertTrue("Unexpected text length", listener.getText().length() == 60);
    Assert.assertTrue("Unexpected text length", listener.getText().length() == 77);
}