Paul
Yes it would do - The original RTL problem has now been solved with all your help.
However all the "xxxx PRINT" commands seem to be ASCII/ANSI orientated so I cannot use them (as far as I know).
I have requested a new feature for an "xxxx PRINT" to work with Unicode as the fonts I normally use have hundreds of Glyphs. (I know there are API commands like "GetCharacterPlacement" but they are way out of my league for a simple non-Latin printing program.)
Announcement
Collapse
No announcement yet.
XPrint - How do I print Right to Left Text?
Collapse
X
-
Is this the sort of thing you want? Print right to left reflected?
Code:'PBCC5 program #COMPILE EXE #DIM NONE FUNCTION PBMAIN () AS LONG XPRINT ATTACH CHOOSE XPRINT GET PPI TO x&,y& GRAPHIC BITMAP NEW 5000, 500 TO hBmp& 'a bitmap big enough to hold whatever text you might print PrintScale!= x&/72 'The approximate difference in scale, the screen is usually 72dpi, should be looked up in final code FONT NEW "Courier New",18 * PrintScale!,1,0,1,0 TO hFont& '18 point (quarter inch high), bold, MyText$="Text to print backwards red?." GRAPHIC ATTACH hBmp&, 0 GRAPHIC SET FONT hFont& GRAPHIC COLOR %BLACK,%WHITE GRAPHIC TEXT SIZE MyText$ TO w&,h& GRAPHIC PRINT MyText$ 'position on page to print the text WhereToX&=800 WhereToY&=400 'now copy the bitmap from the graphic to the printer but do it backwads. XPRINT STRETCH hBmp&,0,(0,0)-(w&-1,h&-1) TO (WhereToX&+w&-1,WhereToY&)-(WhereToX&,WhereToY&+h&-1) XPRINT FORMFEED XPRINT CLOSE END FUNCTION
Leave a comment:
-
MCM
1. Use a richedit control yourself[
(Later: I have just RTFM'd - yes, you can print from the control: now for some heavy reading to try and understand how to do it)
2. You can use Wide Character (Unicode) windows and controls
Bob
Leave a comment:
-
It seems that the only quick & flexible solution for all Non-ANSI text is "rtf" and SHELL to MSWord (which is what I do at the moment).
1. Use a richedit control yourself. There have to be at least twenty examples of same here.
2. You can use Wide Character (Unicode) windows and controls. Demo: Directory List with Non-ASCII (Unicode) characters in file names 5-31-08
MCM
Leave a comment:
-
I cannot do l what I want - RTL is possible as explained above but I have just found that the "XPRINT" command can only handle ASCII (not actually specified in the Help but xref's to LPRINT which is ASCII only - I suspect that the Help really meant ANSI).
It seems that the only quick & flexible solution for all Non-ANSI text is "rtf" and SHELL to MSWord (which is what I do at the moment).
Leave a comment:
-
Very many thanks - I think you have all given me enough to get started with XPRINT
Bob
Leave a comment:
-
Robert this might help
Code:XPRINT TEXT SIZE thetext$ TO xx!,yy! XPRINT GET CLIENT TO ww!,hh! 'according to xprint scale XPRINT GET POS TO x!,y! 'current line info (column pos unimportant) x!=(ww!-xx!) 'figure the starting pos for text XPRINT SET POS (x!,y!) 'set the position XPRINT thetext$
Leave a comment:
-
Apparently not, you're getting a copy of the DC with the statement:Code:#COMPILE EXE #DIM ALL #INCLUDE "win32api.inc" DECLARE FUNCTION SetLayout LIB "gdi32.dll" ALIAS "SetLayout" (BYVAL hdc AS DWORD, BYVAL dwLayout AS DWORD) AS DWORD %LAYOUT_BITMAPORIENTATIONPRESERVED = &H8 FUNCTION PBMAIN () AS LONG LOCAL hDC AS DWORD, oldDir AS DWORD XPRINT ATTACH DEFAULT IF ERR = 0 AND LEN(XPRINT$) > 0 THEN XPRINT COLOR RGB(225,225,255) XPRINT GET DC TO hDC ' prints on the left side of the page XPRINT "This is your printer talking" oldDir = SetLayout (hDC, %LAYOUT_BITMAPORIENTATIONPRESERVED) ' also prints on the left side of the page XPRINT "This is your printer talking" XPRINT FORMFEED ' Issue a formfeed SetLayout hDC, oldDir XPRINT CLOSE ' Deselect the printer END IF END FUNCTION
Leave a comment:
-
That setlayout thing might be just what the doctor ordered... when you combine it with...
Syntax
XPRINT GET DC TO hDC???
Remarks
If no host printer is currently attached, zero is returned. The DC handle may be used with various Windows API functions to perform specialized operations on the host printer page.
If you can't find that info in the help file, you'll have to ask support.
Leave a comment:
-
Colin,
May be the answer but unfortunately I have never used DC's in any of my programs (except one but I don't actually put anything in it as it is required by a Win API function).
Does it actually mirror everything AFTER the contents of a DC have been created or does it just lay down the contents Right to Left as you create them?
A mirrored "ABCD" is different to a RTL "DCBA"
(Later:I was thinking mirror'ed text
BobLast edited by Robert Wallace; 19 Feb 2009, 12:49 PM.
Leave a comment:
-
I was thinking mirror'ed text.
SetLayout
The SetLayout function changes the layout of a device context (DC).Code:DWORD SetLayout( HDC hdc, // handle to DC DWORD dwLayout, // layout options );
- Parameters
- hdc
- [in] Handle to the DC.
- dwLayout
- [in] Specifies the DC layout. This parameter can be one or more of the following values. Value Meaning
- LAYOUT_BITMAPORIENTATIONPRESERVED Disables any reflection during BitBlt and StretchBlt operations.
- LAYOUT_RTL Sets the default horizontal layout to be right to left.
- [in] Specifies the DC layout. This parameter can be one or more of the following values. Value Meaning
- hdc
- Return Values
- If the function succeeds, it returns the previous layout of the DC.
- If the function fails, it returns GDI_ERROR. To get extended error information, call GetLastError.
- Remarks
- The layout specifies the order in which text and graphics are revealed in a window or a device context. The default is left to right. The SetLayout function changes this to be right to left, which is the standard in Arabic and Hebrew cultures.
I'm just not certain if that is what he was looking to do.
Leave a comment:
- Parameters
-
Michael - your first assumption was the right one - Good idea.
Funnily enough I use STRREVERSE$ a lot in my normal work but for LATIN text
(Later: Must use your second suggestion as well because the text starts on the RH side of the page so it is effectively Right Justified)
Many thanks.
Leave a comment:
-
Wait a minute... did you mean right-justified?
This has come up here before. IIRC the solution was to measure the text, subtract from the right margin to find the starting point, and print the string left-justified there.
Leave a comment:
-
I don't know there is a 'native' capability to do so using XPRINT, but you could always reverse the characaters of the string (STRREVERSE$) and XPRINT that.
Leave a comment:
-
XPrint - How do I print Right to Left Text?
I have never used Xprint up to now as most of my printing requirements are Right to Left.
I have RTFM'd but I cannot find anything - is it possible?Tags: None
Leave a comment: