Prev |  | Next

## 3.35. Text - Rotated and Overhead

### Overview

Some documents have a vertical text in the margin which is needed for identification in subsequent steps of the post-processing. Also, table headers with vertical text are used occasionally.

To test text which is rotated by an arbitrary angle, the same test methods are available as for “normal” text.

### Example

The document used by the next example contains two vertical texts:

And this is the test using a page region for the vertical text:

    // Comparing upright text in a part of a PDF page
    @Test
    public void hasRotatedTextInRegion() throws Exception {
      String filename = "verticalText.pdf";

      int leftX  =  40;
      int upperY =  45;
      int width  =  45;
      int height = 110;
      PageRegion pageRegion = new PageRegion(leftX, upperY, width, height);

      String textBottomToTop = "Text from bottom to top.";
      String textTopToBottom = "Text from top to bottom.";
      AssertThat.document(filename)
                .restrictedTo(FIRST_PAGE)
                .restrictedTo(pageRegion)
                .hasText()
                .containing(textBottomToTop, WhitespaceProcessing.IGNORE)
                .containing(textTopToBottom, WhitespaceProcessing.IGNORE)
      ;
    }

The parser extracts vertical text using a lot of line breaks. Therefore, it is absolutely necessarry to use `WhitespaceProcessing.IGNORE`.

Note that the vertical text is still text with the writing direction LTR (left-to-right). PDFUnit also supports RTL (right-to-left) text; see chapter 3.34: “Text - Right to Left (RTL)”.

Prev | Up | Next
3.34. Text - Right to Left (RTL) | Home | 3.36. Version Info