title: Printing Right-To-Left in c#
body: <p>According to msdn:  <strike>http://www.microsoft.com/middleeast/msdn/arabicsupp.aspx</strike> <strong>(Link Expired!)</strong></p>
  <blockquote>
  <p>How GDI+ Support Arabic?</p>
  </blockquote>
  <p>GDI+ supports Arabic text manipulation including print text with RTL reading order for both output devices, Screen and Printer. The Graphics.DrawString method draws the specified text string at a designated x, y location or rectangle (according to its overloading), with the specified Brush and Font objects using the formatting attributes of the specified StringFormat object. The StringFormat object includes text layout information such as text reading order.</p>
  <blockquote>
  <p>Therefore, you can easily move the origin of the graphics object to be Right-Top, instead of Left-Top, to print out the Arabic text in the designated location on the screen smoothly, without having to calculate locations explicit.</p>
  </blockquote>
  <p>While this is true when setting (X,Y) coordination to (0,0) but if I want to increase X coordination to print at specific area on the paper, the X coordination will increase to the right side of the paper not to the left as it supposed to when printing in Right-to-left; which means print outside of the paper.
  See this demo:</p>
  <pre><code>static void Main(string[] args)
  {
      PrintDocument p = new PrintDocument();
      p.PrintPage += new PrintPageEventHandler(PrintPage);
      p.Print();
  }
  
  static void PrintPage(object sender, PrintPageEventArgs e)
  {
      string drawString = &quot;إختبار الرسم&quot;;
      SolidBrush drawBrush = new SolidBrush(Color.Black);
      Font drawFont = new System.Drawing.Font(&quot;Arail&quot;, 16);
      RectangleF recAtZero = new RectangleF(0, 0, e.PageBounds.Width, e.PageBounds.Height);
      StringFormat drawFormat = new StringFormat();
  
      drawFormat.FormatFlags = StringFormatFlags.DirectionRightToLeft;
  
      e.Graphics.DrawString(drawString, drawFont, drawBrush, recAtZero, drawFormat);
      RectangleF recAtGreaterThantZero = new RectangleF(300, 0, e.PageBounds.Width, e.PageBounds.Height);
      e.Graphics.DrawString(drawString, drawFont, drawBrush, recAtGreaterThantZero, drawFormat);
  }
  </code></pre>
  <p>How to  move the origin of the graphics object to be Right-Top instead of   Left-Top and when increase X coordination it advance the printing point to the left not to the right.</p>
  <p>PS: What I am doing now is setting X coordination to negative to force it move to left.
  <img src="https://i.stack.imgur.com/Lot47.png" alt="Simple digagram" /></p>