Search code examples
printingmfcright-to-left

How to support right to left printing in mfc application


I have a problem in printing right to left in my application. I use the codejock report control; it prints the left to right view very well and this is an example:

enter image description here

When the layout is rtl the control renders very well on the screen and also the print preview is fine, but printing results in a distorted document like the following:

enter image description here

I have tried to override the OnPrepareDC of the view and used the pDC->SetLayout(LAYOUT_RTL) but it failed, I need help on how to fix this.


Solution

  • Actually I have found a solution for RTL printing issue.

    the reason of the problem is that not all the printer's drivers support mirroring so calling the SetLayout(RTL) function on the printer's DC will not work in all printer's drivers.

    The first step is not to call SetLayout(RTL) at all, then you should override drawing methods in report paint manager class to set the alignment of each drawing rectangle when you are in RTL printing mode.