Sign in to follow this  
Followers 0
albertmaathuis

printing text with without CR/LF

7 posts in this topic

Hi there,

I'm using the print udf and i wonder if it is possible to print a long line of text using line wrapping (that is the correct word I think)

e.g. í'm having a $text wich contains 500 characters or more including points, commas and so on, but no carrige return or linefeed characters.

What can I Use to print this line of text on a A4 printer and be sure the text is broken by the space and not in the middel of a word.

perhaps it's been asked before, but I cann't find it in the topics.

Share this post


Link to post
Share on other sites



albertmaathuis,

You might like to look at my StringSize UDF (the link is in my sig) which as well as returning the size of the text also returns the text itself with the wrapping @CRLF inserts. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

This may help

;$sSplitIndex : the Number from where the Space Split would be Started

Func _CRFromSpace($sString,$sSplitIndex=-1)
    If $sSplitIndex=-1 Then Return StringReplace($sString,' ',@CR)
    Local $nString=StringSplit($sString,' ',1)
    If @error Then Return SetError(1,@error,-1)
    Local $nLen=0
    For $i=1 To $nString[0]
        $nLen+=StringLen($nString[$i])+1
        If $nLen>$sSplitIndex Then
            Return StringReplace($sString,$nLen,@CR)
        EndIf
    Next
    $nLen-=1
    Return SetError(2,$nLen,-1)
EndFunc

Local $aRet=_CRFromSpace('Hello There My Name is Anthony Gonsalvis',17)
ConsoleWrite($aRet&@CR)
Edited by PhoenixXL

My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Share this post


Link to post
Share on other sites

Hello Melba23,

Thanks, it might help. But when I download the zip file it gives an error. Something wrong with the zipper?

Hello PhoenixXXL,

Also thanks, I will try your solution and see what happens.

Share this post


Link to post
Share on other sites

albertmaathuis,

I have just tested and it downloads fine for me. Perhaps try copy and paste from the forum post. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Hi,

I'm going to use the solution from PhoenixXL. Working on a 64 bit server might give me problems with the dll's used in M23 program.

I made a slight difference in the code, because i want it to brake the string before the last word. In that case I'm sure that my printer doesn't print outside its margins.

Thanks for the help; below is the code i'm going to use.

Global $previousspace,$newtext,$maxwidth

$text="Visit Vinsobres in the Drôme Provençale.The large weekly markets of Nyons and Vaison la Romaine can provide you with delicious local products. For the wine lovers, there are excellent wines. The red Vinsobres is classified as the first vintage of the Côtes du Rhône in the Drôme Provençale. On foot, by bike or by car, you can explore the many cultural and historic sites or enjoy the sun and the peace on the edge of the swimming pool."

$len=StringLen($text)
$maxwidth=50; This is the maximum width of the new text.

Do
$aRet=_CRFromSpace($text,$maxwidth)
$newtext=$newtext&@CRLF&StringLeft($text,$previousspace)
$len=StringLen($text)
$text=StringRight($text,$len-$previousspace)
until $len<$maxwidth
msgbox(0,"output",$newtext)

Func _CRFromSpace($sString,$sSplitIndex=-1)
    If $sSplitIndex=-1 Then Return StringReplace($sString,' ',@CR)
    Local $nString=StringSplit($sString,' ',1)
    If @error Then Return SetError(1,@error,-1)
    Local $nLen=0
    For $i=1 To $nString[0]; het aantal brokken van de string
        $nLen+=StringLen($nString[$i])+1; nlen is de teller van de spaties, de 1e spatie staat op 4, daarna op 9
        If $nLen>$sSplitIndex Then; splitindex is dat getal waarNA de string wordt afgebroken.
   Return StringReplace($sString,$previousspace,@CR); de string wordt nu nooit langer dan de opgegeven waarde
  Else
   $previousspace=$nLen
        EndIf
    Next
    $nLen-=1
    Return SetError(2,$nLen,-1)
EndFunc
Edited by Melba23
Added code tags

Share this post


Link to post
Share on other sites

albertmaathuis,

Working on a 64 bit server might give me problems with the dll's used in M23 program

No-one has ever reported any problem with the UDF when used with an x64 OS - please let me know if you do. :)

And when you post code in future, please use Code tags - put [autoit] before and [/autoit] after your posted code. I have done it for you above. ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Similar Content

    • mutleey
      By mutleey
      Hello everybody, I have a problem here ... I need to generate a form of sale and print quality using the form I could do is not getting good, I created a window without borders with the fields I need, then use the function _ScreenCapture_CaptureWnd () to generate a print of this window and send the image to the printer using the UDF printMGv2.au3, the problem is that to get a good quality I would have to create a huge window to get the print, any suggestions to print this form with a good quality?
      thank you...
      example of the form it takes:
       

    • tbaror
      By tbaror
      Hello,

      I have been asked to do a task with following job, read a simple list of peron from XL spreadsheet , next print each one of them in envelop format .
      My question would be is it possible to do such job and which Autoit objects should i use

      Please advice

      Thanks