Popular Post martin Posted August 9, 2007 Popular Post Share Posted August 9, 2007 (edited) This is a printing UDF which allows you to print text in any font, size and colour at any position on the page, draw lines, curves, elipses, pies in any colour, and print images. Useful for labels, reports, graphs and standard forms. Can also print barcodes. It uses my printmg.dll. It is not intended to do the sorts of thing you can do with the Word UDF by big_daddy. Note the dll is 32 bit and so only works with 32 bit applications.printout from the code in the example in the download. Functions available are -Start using/Finish using the UDF _PrintDllStart _PrintDllClose _PrintVersion - Returns version of UDF or dll _PrintSetTitlePrinter control _PrintStartPrint _PrintAbort _PrintEndPrint _PrintNewPagePrinter selection, getting & setting parameters _PrintListPrinters - lists all installed printers _PrintSetPrinter - manual printer selection dialogue _PrintSelectPrinter - programmatically set the printer. _PrintGetPageWidth _PrintGetPaperWidth _PrintGetPageHeight _PrintGetPaperHeight _PrintGetHorRes _PrintGetVertRes _PrintGetXOffset _PrintGetYOffset _PrintPageOrientation - set portrait or landsacpeText printing _PrintSetFont - Font, size, attributes and colour _PrintText - At x,y and angle. _PrintGetextWidth _PrintGetTextHeightGraphics _PrintSetLineCol _PrintSetLIneWid _PrintSetBrushCol - sets the colour used for filling _PrintLine _PrintEllipse - Filled ellipse or circle _PrintPie - for filled pie slice _PrintArc - Elliptical or circular arcs _PrintRectangle - filled rectangle _PrintRoundedRectangle _PrintImage - prints jpg, bmp and ico files (Has problems with some icons bigger than 64 x 64) _PrintImageFromDC Latest change = 25th February 2011 Added example to the download which was missing.Get the UDF, dll and example from here. ================================================================= See also these udf's for printing from AutoIt using the Windows API and not using a dll. by GRS - http://www.autoitscript.com/forum/topic/...m-autoit/page__view__findpost_ by Prog@ndy -http://www.autoitscript.com/forum/topic/...gdi-udfs/page__view__findpost_ and this one which embeds a dll in the script for creating pdf files. printing to a pdf by taietel see Edited May 27, 2013 by martin LukeLe, robertocm, Barney and 2 others 3 2 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. Link to comment Share on other sites More sharing options...
Gif Posted August 9, 2007 Share Posted August 9, 2007 This is a simple example of printing using my print UDF which uses a dll. It is not intended to do the sorts of thing you can do with the Word UDF by big daddy, but it allows you to print text in any font, size and colour and to draw straight lines in any colour. Useful for labels, reports and so on. #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) ConsoleWrite('dll version is' & _PrintVersion($hp,1) & @CRLF) _PrintSetPrinter($hp);choose the printer if you don't want the default printer _PrintStartPrint($hp) $title = 'Printing with a dll' $twid = _PrintGetTextWidth($hp,$title) $tht = _PrintGetTextHeight($hp,$title) _PrintSetLineWid($hp,10) _PrintSetLineCol($hp,0x00ff00) $pw = _PrintGetPageWidth($hp) $tx = Int(($pw - $twid) /2) $ty = 100 _PrintText($hp,$title,$tx,$ty) ;Draw a box around the text _PrintLine($hp,$tx-50,$ty-50,$tx + $twid + 50,$ty - 50) _PrintLine($hp,$tx + $twid + 50,$ty - 50,$tx + $twid + 50,$ty + $tht + 50) _PrintLine($hp,$tx - 50,$ty + $tht + 50,$tx-50,$ty-50) _PrintSetLineCol($hp,0x0000ff) _PrintLine($hp,$tx + $twid + 50,$ty + $tht + 50,$tx - 50,$ty + $tht + 50) _PrintEndPrint($hp) _PrintDllClose($hp);this must always be called last Functions available are - _PrintDllStart _PrintDllClose _PrintSetPrinter _PrintGetPageWidth _PrintGetPageHeight _PrintGetHorRes _PrintGetVertRes _PrintStartPrint _PrintSetFont _PrintNewPage _PrintEndPrint _PrintText _PrintGetextWidth _PrintGetTextHeight _PrintLine _PrintGetXOffset _PrintGetYOffset _PrintSetLineCol _PrintSetLIneWid The link below is for a compressed link. If you download it, extract the link then double click on it and it will get the zip containing the UDF and the dll. The whole thing is a bit underdeveloped. If there is any interest then I will put some effort into it. (Yes, I know it would be better if I didn't use a dll.) Great job! Link to comment Share on other sites More sharing options...
martin Posted August 13, 2007 Author Share Posted August 13, 2007 Great job! Thanks Gif, I hope it works for people.First post is updated with additions. 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. Link to comment Share on other sites More sharing options...
Michel Claveau Posted August 13, 2007 Share Posted August 13, 2007 Hi! Run OK on a french-XP. Thanks. Link to comment Share on other sites More sharing options...
martin Posted August 13, 2007 Author Share Posted August 13, 2007 Hi! Run OK on a french-XP.Thanks. Naturelment! 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. Link to comment Share on other sites More sharing options...
Michel Claveau Posted August 13, 2007 Share Posted August 13, 2007 (edited) Hi! What is the statut (licensing...) of the DLL? Can I use with freedom? Edited August 13, 2007 by Michel Claveau Link to comment Share on other sites More sharing options...
Michel Claveau Posted August 13, 2007 Share Posted August 13, 2007 OK in french-XPNaturelment!I want said than I had try with accent & euro caracter, with success.I don't had try with "Arial Unicode" & very specials unicodes caracters.(* sorry for my bad english *) Link to comment Share on other sites More sharing options...
martin Posted August 13, 2007 Author Share Posted August 13, 2007 (edited) What is the statut (licensing...) of the DLL?Can I use with freedom?The dll is for you to use as you want. If it causes any problems at all then I will try to fix it but I do not take any responsibility for any problems and I make no guarantees about its capabilities or fitness for purpose.I want said than I had try with accent & euro caracter, with success.I don't had try with "Arial Unicode" & very specials unicodes caracters.I haven't tried any special Unicode examples either. Edited August 13, 2007 by martin 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. Link to comment Share on other sites More sharing options...
Michel Claveau Posted August 13, 2007 Share Posted August 13, 2007 The dll is for you to use as you want.OK. I want sell it 1,000,000,000,000$ (or more).Thanks. For info, I had try to call the DLL with (from) Python (+ctypes).And it's run perfectly. Link to comment Share on other sites More sharing options...
martin Posted August 13, 2007 Author Share Posted August 13, 2007 OK. I want sell it 1,000,000,000,000$ (or more).Thanks. Oooh, it's worth much more than that!For info, I had try to call the DLL with (from) Python (+ctypes).And it's run perfectly. I wrote it because I thought it would be useful for AutoIters, but it can be used with anything. Nice to know it worked with Python. 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. Link to comment Share on other sites More sharing options...
Michel Claveau Posted August 13, 2007 Share Posted August 13, 2007 Re I don't find anyway for PageSet (type / size). Lapse of memory? Too much difficult? Am I blind? Link to comment Share on other sites More sharing options...
Michel Claveau Posted August 13, 2007 Share Posted August 13, 2007 I found a little error. in printMGv2.au3, for _PrintRectangle, you write "Ellipse" in lieu of "Rectangle" (in DLL.call) (the word rectangle is good in the DLL) Link to comment Share on other sites More sharing options...
martin Posted August 13, 2007 Author Share Posted August 13, 2007 (edited) ReI don't find anyway for PageSet (type / size).Lapse of memory?Too much difficult? Am I blind?You should be able to set the page if you use _PrintSetPrinter. Next to the combobox to choose a printer there should be a Properties button. This will access the printer properties and you should be able to set the page size.If this doesn't work let me know.Edit: spelling Edited August 13, 2007 by martin 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. Link to comment Share on other sites More sharing options...
martin Posted August 13, 2007 Author Share Posted August 13, 2007 (edited) I found a little error.in printMGv2.au3, for _PrintRectangle, you write "Ellipse" in lieu of "Rectangle" (in DLL.call)(the word rectangle is good in the DLL)Thanks Now fixed. Mod uploaded. Edited August 13, 2007 by martin 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. Link to comment Share on other sites More sharing options...
Michel Claveau Posted August 13, 2007 Share Posted August 13, 2007 A bug! _PrintPageOrientation(.. break AutoIt (with Python : "exception code 0xeedfade") Link to comment Share on other sites More sharing options...
martin Posted August 13, 2007 Author Share Posted August 13, 2007 (edited) A bug! _PrintPageOrientation(.. break AutoIt (with Python : "exception code 0xeedfade")Yes it is a sort of bug. The page orientation should only be set before _PrintStartPrint or after _PrintEndPrint, so did you try changing the orientation after a _PrintStartPrint?I will make it so that if _PrintStartPrint is active then _PrintPageOrientation returns an error. Edited August 13, 2007 by martin 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. Link to comment Share on other sites More sharing options...
Michel Claveau Posted August 14, 2007 Share Posted August 14, 2007 Hi, Martin! You are right : call Portrait (orientation) before PrinterBegin run correctly. Apologies for trouble. Link to comment Share on other sites More sharing options...
GioVit Posted September 9, 2007 Share Posted September 9, 2007 This is the most useful UDF I have ever had I'll use it to fill pre-printed forms in my company. Thanks for sharing regards Link to comment Share on other sites More sharing options...
martin Posted September 9, 2007 Author Share Posted September 9, 2007 This is the most useful UDF I have ever hadI'll use it to fill pre-printed forms in my company.Thanks for sharingregardsOh, thanks, it's always nice to know it's been useful. (When I see a reply in my threads I expect to find there has been a problem! Better not speak too soon though.) 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. Link to comment Share on other sites More sharing options...
SAG Posted October 5, 2007 Share Posted October 5, 2007 Great work! Nearly what I was looking for but.... If I have a text file, can your DLL and UDF can be used to change the default printer and print the file? Thanks Sean Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now