title: In PDFBox, how to change the origin (0,0) point of a PDRectangle object?
body: <p><em>The Situation:</em><br>
  In PDFBox, PDRectangle objects' default origin (0,0) seems to be the lower-left corner of a page.</p>
  
  <p>For example, the following code gives you a square at the lower-left corner of a page, and each side is 100 units long.</p>
  
  <pre><code>PDRectangle rectangle = new PDRectangle(0, 0, 100, 100);
  </code></pre>
  
  <p><em>The Question:</em><br>
  Is it possible to change the origin to the UPPER-LEFT corner, so that, for example, the code above will give you the same square at the UPPER-LEFT corner of the page instead?</p>
  
  <p><em>The reason I ask:</em> <br>
  I was using PDFTextStripper to get the coordinates of the text (by using the getX() and getY() methods of the extracted TextPosition objects).  The coordinates retrieved from TextPosition objects seem have an origin (0,0) at the UPPER-LEFT CORNER.  I want the coordinates of my PDRectangle objects have the same origin as the coordinates of my TextPosition objects.</p>
  
  <p>I have tried to adjust the Y-coordinates of my PDRectangle by "page height minus Y-coordinate".  This gives me the desired result, but it's not elegant.  I want an elegant solution.</p>
  
  <p><em>Note</em>:
  Someone has asked a similar question.  The answer is what I tried, which is not the most elegant.
  <a href="https://stackoverflow.com/questions/27719060/how-to-change-the-coordiantes-of-a-text-in-a-pdf-page-from-lower-left-to-upper-l">how to change the coordiantes of a text in a pdf page from lower left to upper left</a></p>