Sign in to follow this  
Followers 0
ttleser

Printing problems

7 posts in this topic

Greetings all.

I'd created a GUI program that'll allow me to fill out some fields and then it'll send the output to a txt file, then using the _fileprint function print it out to a dot-matrix printer on a pre-printed multipart-form. Basically the program does a "fill in the blanks" printout.

Unfortunately I've run into a few snags.

1. The pre-printed form wasn't designed so that the "blanks" are on a certain font/line spacing format. Form is NOT printer friendly.

2. Using the _fileprint function uses notepad, which unfortunately doesn't allow for paragraph formatting (like reducing the spacing between lines).

I've got the output pretty close to the fields on the form, but I've got some lines that the text is printed through the blank line (ex. Hello) or the text is printed quite a bit above the line.

2ne example below:

Hello

____

I'm using Lucida Sans Typewriter, font size 10 for the font to print in Notepad as it's a monospaced (Fixed size) font that allows me to make sure my horizontial spacing is maintained, where normal fonts the space is some weird half/quarter sized space. It screws up horizontial alignment.

The program, aside from the printing alignment issue, works just how I'd like it to, nice and quick.

Any thoughts on how I could get around this problem?

Share this post


Link to post
Share on other sites



Greetings all.

I'd created a GUI program that'll allow me to fill out some fields and then it'll send the output to a txt file, then using the _fileprint function print it out to a dot-matrix printer on a pre-printed multipart-form. Basically the program does a "fill in the blanks" printout.

Unfortunately I've run into a few snags.

1. The pre-printed form wasn't designed so that the "blanks" are on a certain font/line spacing format. Form is NOT printer friendly.

2. Using the _fileprint function uses notepad, which unfortunately doesn't allow for paragraph formatting (like reducing the spacing between lines).

I've got the output pretty close to the fields on the form, but I've got some lines that the text is printed through the blank line (ex. Hello) or the text is printed quite a bit above the line.

2ne example below:

Hello

____

I'm using Lucida Sans Typewriter, font size 10 for the font to print in Notepad as it's a monospaced (Fixed size) font that allows me to make sure my horizontial spacing is maintained, where normal fonts the space is some weird half/quarter sized space. It screws up horizontial alignment.

The program, aside from the printing alignment issue, works just how I'd like it to, nice and quick.

Any thoughts on how I could get around this problem?

I would expect that you will always have problems using _Fileprint.

I suggest (of course I do) that you try my printing udf because then you can print at an exact position on the paper and you can check the width or height of some text and you could change the font size to make it fit. It would be harder to do but a lot more accurate and versatile.

The Print udf is in my sig and the thread has an example printout. Filling out standard forms is one of the things the udf has been already been used for.


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

Thank Martin, I'm looking it over right now.

I'm not to good just looking at AU3's without the it being in the help file with examples.

But I did manage to look at your example of your graph and it's slow creeping up with me..

One question, wouldn't it make sense to be able to print out a "gridwork" of lines so that I could print that out and hold it over my multipart form and be able to see where my blanks line up to?

Any thoughts on how I could print out a alignment/reference gridwork?

Share this post


Link to post
Share on other sites

Thank Martin, I'm looking it over right now.

I'm not to good just looking at AU3's without the it being in the help file with examples.

But I did manage to look at your example of your graph and it's slow creeping up with me..

One question, wouldn't it make sense to be able to print out a "gridwork" of lines so that I could print that out and hold it over my multipart form and be able to see where my blanks line up to?

Any thoughts on how I could print out a alignment/reference gridwork?

That would be quite simple. (Why do I say things like that?) Anyway, here goes

#include "PrintMGV2.au3"
Global $mmssgg, $Yoffset, $Xoffset, $pght, $pgwd, $n

Global $hp = _PrintDllStart($mmssgg);this must always be called first
if $hp = 0 then
    consolewrite("Error from dllstart = " & $mmssgg & @CRLF)
    Exit
endif
;if you don't want the default printer use one of these
;$newselect = _PrintSelectPrinter($hp,$printername);sets printername to be used
;or
;_PrintSetPrinter($hp);lets you choose the printer


_PrintPageOrientation($hp,1);portrait

_PrintStartPrint($hp)
$Yoffset = _PrintGetYOffset($hp)
$Xoffset = _PrintGetXOffset($hp)
;get printer paper dimensions
$pght = _PrintGetpageheight($hp) - $Yoffset
$pgwd = _PrintGetpageWidth($hp) - $Xoffset

_PrintSetLineWid($hp,2);set line width to 0.2mm
_PrintSetLineCol($hp,0);set black lines
;draw vertical linesa every 20 mm
for $n = 200 to $pgwd step 200
    _PrintLine($hp,$n,0,$n,$pght)
    _printText($hp,Stringformat("%d",$n/10),$n,$Yoffset)
Next
;draw horizontal lines every 20mm
for $n = 200 to $pght step 200
    _PrintLine($hp,0,$n,$pght,$n)
    _printText($hp,Stringformat("%d",$n/10),$Xoffset,$n)
Next



_PrintEndPrint($hp)
_printDllClose($hp)

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

Actually, duh.... I've got a better way.

I measured each field from top and the left side of the paper. Have a function in my script to convert it from inches to MM . Have a option for users to print a "alignment" page on the printer to verify that the printer is printing properly on the page, if not save the "off of alignment" value and have that factored into the printing of the form.

BTW, I've messed with your script a little (done a little printing) and so far I'm loving it. Followed your example and it's pretty easy to do. :)

Question..

If I have a line of code that tells it to printtext X of 50 and Y of 200. Then the next line of code is printtext X of 50 and Y of 100. That won't screw anything up will it? I'm at home right now and haven't tested it yet. What I mean is that I don't have to think of the printing as a top to down, left to right flow correct?

Share this post


Link to post
Share on other sites

Actually, duh.... I've got a better way.

I measured each field from top and the left side of the paper. Have a function in my script to convert it from inches to MM . Have a option for users to print a "alignment" page on the printer to verify that the printer is printing properly on the page, if not save the "off of alignment" value and have that factored into the printing of the form.

BTW, I've messed with your script a little (done a little printing) and so far I'm loving it. Followed your example and it's pretty easy to do. :)

Question..

If I have a line of code that tells it to printtext X of 50 and Y of 200. Then the next line of code is printtext X of 50 and Y of 100. That won't screw anything up will it? I'm at home right now and haven't tested it yet. What I mean is that I don't have to think of the printing as a top to down, left to right flow correct?

_PrintText prints text where you tell it to. You can print the page number at the bottom, then print the title at the top then print some text in the middle then draw a line under the title. Any order you want. If you say print where you already printed then it will print on top of the previous text.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

Any thoughts why when I added some of your print functions to my script that the $BS_multiline & $ES_Right stopped working? It's giving me an error saying that:

WARNING: $BS_MULTILINE: possibly used before declaration.

WARNING: $ES_RIGHT: possibly used before declaration.

Where before I added Martin's new printing function I never got the error. All I did was add to my existing script:

#Include <printMGv2.au3>
Global $hp
Local $mmssgg,$marginx,$marginy

$hp = _PrintDllStart($mmssgg);this must always be called first
if $hp = 0 then
    consolewrite("Error from dllstart = " & $mmssgg & @CRLF)
    Exit
endif

&

Func PrintAlignment()
;   _PrintSetPrinter($hp)
    _PrintSetLineWid($hp,1);set line width to 0.2mm
    _PrintSetLineCol($hp,0);set black lines
    _PrintPageOrientation($hp,1);portrait

    _PrintStartPrint($hp)
    $Yoffset = _PrintGetYOffset($hp)
    $Xoffset = _PrintGetXOffset($hp)
;get printer paper dimensions
    $pght = _PrintGetpageheight($hp) - $Yoffset
    $pgwd = _PrintGetpageWidth($hp) - $Xoffset
    $Title = "Top of Page"
    $tw = _PrintGetTextWidth($hp,$Title)
    _PrintSetFont($hp,'Arial',12,0,"bold")
    _PrintText($hp,$Title,Int($pgwd/2 - $tw/2)+$UserXOffset,$YOffset)
    _PrintLine($hp,Int($pgwd/2)-50+$UserXOffset,Int($pght/2)+$UserYOffset,Int($pgwd/2)+50+$UserXOffset,Int($pght/2)+$UserYOffset)
    _PrintLine($hp,Int($pgwd/2)+$UserXOffset,Int($pght/2)-50+$UserYOffset,Int($pgwd/2)+$UserXOffset,Int($pght/2)+50+$UserYOffset)
    _PrintEndPrint($hp)
    $UserXOffsetInches = InputBox("Left to Right Alignment","Left to Right Alignment."&@CRLF&@CRLF&"The alignment page is printing. Measure 4 1/4 inches"&@CRLF&"from the left edge of the page to the vertical line."&@CRLF&@CRLF&"Enter the decimal value of the difference. Put a minus sign "&@CRLF&"in front if the line needs to goto the left."&@CRLF&@CRLF&"Enter Zero to reset previous numbers, leave blank to leave it as-is.","","",325,200)
    $UserYOffsetInches = InputBox("Left to Right Alignment","Top to Bottom Alignment."&@CRLF&@CRLF&"Measure 5 1/2 inches from the top edge of the page to "&@CRLF&"the horizontal line."&@CRLF&@CRLF&"Enter the decimal value of the difference. Put a minus sign in front if the line needs to goto the top"&@CRLF&@CRLF&"Enter Zero to reset previous numbers, leave blank to leave it as-is.","","",325,200)
    $UserXOffset = $UserXOffsetInches*254
    $UserYOffset = $UserYOffsetInches*254
EndFunc

All I wanted to test so far was being able to print an alignment page, a large "+" in the center of the page for adjustment. Obviously if I dim the multiline and ES_RIGHT I won't get the error, but my buttons lose a multiline look.

Here's a sample of one of my button statements.

$ClearPersonal_btn = GUICtrlCreateButton ("Clear Personal Info", 130, 380, 90, 35,$BS_MULTILINE)

Thoughts?

Edit: ok, I got around it. I simply added $BS_MULTILINE = 0x2000 & $ES_RIGHT = 0x0002 to the beginning of my code and I got around it. Still curious why it broke.

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