Jump to content

Recommended Posts

Posted

Hello,
this udf + dll is the maximum for printing without using other applications (word - excel - pdf - etc.)
The only lack is the impossibility of being able to set the size of the sheet!
I have to print a report on an A2 sheet how do I do it?
Thank you

  • 4 weeks later...
Posted

I don't know why setting the paper size wasn't ever included in the udf, but if you still need this I will try to add something. If I don't see a reply over the next week then I will do nothing on the assumption that I am too late to help.

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.
  • 2 weeks later...
  • 3 months later...
Posted
On 31/03/2018 at 4:57 PM, CarontePizzuto said:

 

Thank you so much Martin.

I apologize if I have not answered before but I have been very busy.

I solved using the dll "PSCRIPT.dll" (http://www.pagescript32.com/)

 

@CarontePizzuto, could you post your code?

  • 3 months later...
  • 3 months later...
Posted (edited)

Hi Martin,

I use your DLL for a little project where we are printing some labels with the help of a brother label printer.

I create a QR code with createQRw.au3 and add some text to the right of it.

There are two things I still have a problem. First of all I would like (also) have the ability to set the paper size to a specific value so that the user hasn't to do so. Cause when the length of the label isn't right the QR code has not a square size and won't be recognized by our scanner.

The second thing is a problem I hope you have an idea. On some computers my script prints an empty second page and I don't know why. Even when the printer settings and the text to be printed and all computers are teh same. Do you have any hints for me Martin?

(I'am using the _PrintImage function. It also prints a second page when printing a tiny pic which fits into the page bounderies)

Is there an ability to force the printer to only print one page?

 

many thanks in advance Martin

Sundance

Edited by Sundance
spelling
  • 3 months later...
  • 1 month later...
  • 6 months later...
Posted

Hi all,

I'm using this for printing to various label printers. I need one line of text to be rotated 180 degrees. How would I go about doing this as it's not totally obvious?

Many thanks.

  • 4 months later...
Posted (edited)

I have been using this UDF, quite successfully, for some time, but I have found the following issues:

First, _PrintPageOrientation doesn't seem to have any effect, printing to PDF or to my Brother printer (HL-1850).
2nd, _PrintDllStart always fails if I previously do a screen capture with _ScreenCapture_CaptureWnd.

I am using Windows 7.

Here is sample code that illustrates these problems.

#include <ListViewConstants.au3>
#include <printMGv2.au3>
#include <ScreenCapture.au3>
#include <WindowsConstants.au3>
#include <GUIConstants.au3>
#include <GUIConstantsEx.au3>

Local $Frm1 = GUICreate("Test", 1200, 650, -1, -1)
Local $LVhdrs = " Rec. |Last|First"
Local $idListview = GUICtrlCreateListView($LVhdrs, 10, 10, 1200, 600, BitOR($GUI_SS_DEFAULT_LISTVIEW,$WS_VSCROLL))
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_LV_ALTERNATE)
GUICtrlSetBkColor(-1, 0xFFFFFF) ; 0xEAEAEA)
Local $idListview_Handle = GUICtrlGetHandle($idListview)
Local $btnSave = GUICtrlCreateButton("Save (Screen Capture)", 400, 620, 150, 22)
Local $btnPrint = GUICtrlCreateButton("Print", 600, 620, 150, 22)

Local $aLVRowID[20]

For $ii = 0 To UBound($aLVRowID)-1
    $aLVRowID[$ii] = GUICtrlCreateListViewItem($ii+1 & "|" & "Last Name " & $ii+1 & "|" & "First Name " & $ii+1, $idListview)
    GUICtrlSetBkColor(-1, 0xEBEBEB) ; 0xFCF6EA)
Next

GUISetState(@SW_SHOW)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            GUIDelete($Frm1)
            ExitLoop
        Case $btnSave
            SaveImage($idListview_Handle)
        Case $btnPrint
            PrintIt()
    EndSwitch
WEnd

Func SaveImage($hHandle)

    Local $sFileName = FileSaveDialog("Save Screen Capture", @MyDocumentsDir, "(*.jpg;*.jpeg;*.bmp;*.tif;*.tiff)",  $FD_PROMPTOVERWRITE + $FD_PATHMUSTEXIST)
    If @error Then
        Return
    Else
        sleep (1000) ; give time for dialog to disappear before starting screen capture
    EndIf

    ;_ScreenCapture_SetJPGQuality(80) ; default is 100
    _ScreenCapture_CaptureWnd ($sFileName, $hHandle, 0, 0, -1, -1, False)
    ShellExecute($sFileName) ; display saved image using default viewer

EndFunc

Func PrintIt()
Local $msg

$hDll = _PrintDllStart($msg);this must always be called first
if $hDll < 1 then
    MsgBox(48,"Printer Error", "Error from dllstart = " & $msg)
    Return
EndIf

Local $prnChoice = _PrintSetPrinter($hDll) ; opens choose printer dialogue
If $prnChoice = 0 Then
    _PrintDllClose($hDll)
    Return
EndIf

_PrintStartPrint($hDll)

_PrintPageOrientation($hDll, 1) ;  0 = portrait, 1 = landscape *** DOESN'T SEEM TO WORK...

MsgBox(0,"","Now printing")

_PrintEndPrint($hDll)
_PrintDllClose($hDll);this must always be called last

EndFunc

 

Edited by geller
Posted

After further experimentation, it seems that the problem lies with the ScreenCapture UDF, not the Print UDF, as SQlite will also not start up after _ScreenCapture was invoked. However, this problem seems to occur only when running uncompiled script. Once compiled, it seems to work OK.

  • 2 weeks later...
Posted

I've started trying to work with this again and I've noticed a new problem that I don't think has been reported: it ignores all printing defaults set in the printer properties and does some other defaults. I'm working with a label printer and I've set speed and density in the printing defaults, but this UDF just does whatever it wants. Am I missing something?

  • 5 months later...
Posted

Thank for your work on creathing this UDF and DLL.

But, the UDF does not support Unicode Encoding. All text is converted to ANSI before printing.

Hope to see an update of dll and this UDF, supporting multi-encoding in the future.

Thanks!

  • 1 month later...
Posted (edited)

Hi, Martin

I found a need for this UDF yesterday. I needed to create a way of making a page of small labels (to price things I will be selling). I got it working just fine and THANK YOU FOR MAKING THIS UDF, IT HELPED ME TREMENDOUSLY! I did find a couple interesting complications that I didn't expect. I thought I should mention them, not sure if they are noteworthy.

1. I tried to make a GUI with Koda using pixels to space plan the sheet. However, the pixel numbers for the GUI didn't line up with the pixel spacing with your UDF (I assume it has to do with DPI, not GUI pixels). I had to use the good old trial-and-error method to get the correct font size, bold setting and spacing on the x and y axis. But after about 30 pieces of paper (small price to pay🤑), I got it perfect. My final product looks very professional. Am I correct about the DPI vs. pixels theory?

2. My initial runs were scripted with a simple .au3 file. Later, I converted that .au3 file into a function. I ran into all kinds of crashes, errors or nothing happening. I tried to pass variables into the function or make them global, but I couldn't make the function work. My best solution was to make an independent .exe (using your same UDF) for the final print phase and have it read the data from a .txt file. Using your UDF as a standalone file reading data, it works great. But I had lots of problems using it inside a function. The problem was probably my code, but I got it working, so I'm happy. Edit: Tonight, I was re-working some of the code and discovered exactly what my problem here was. The independent .exe was compiled as 32-bit (to be compatible with the .dll). When I run the code as an .au3, AutoIt runs scripts 64-bit by default (I chose this when installing AutoIt). Compiling the separate script works very well.

Thanks again! I really love this UDF! If it weren't for this UDF, I would still be manually typing up every label in MS Word (very tedious).

Edited by abberration
Discovered the exact reason for my problem #2.
  • 1 month later...
Posted

Hello

print to pdf file

does not print yellow. Why?

#include <printMGv2.au3>

_TextToPrint('CutePDF Writer')

Func _TextToPrint($sNamePrint)
    Local $aTextP = FileReadToArray(@ScriptDir & '\text.txt')
    Local $hOD = _PrintDllStart()
    _PrintSelectPrinter($hOD, $sNamePrint)
    _PrintPageOrientation($hOD, 1)
    _PrintStartPrint($hOD)
    Local $y = 60, $iC = 0
    Local $aCol[4] = [0xFF0000, 0x0000FF, 0xFFFF00, 0x000000];blue red yellow black
    For $n = 0 To UBound($aTextP) - 1
        If $iC = 4 Then $iC = 0
        _PrintSetFont($hOD, 'Courier', 12, $aCol[$iC])
        $iC += 1
        _PrintText($hOD, $aTextP[$n], 35, $y)
        $y += 43
    Next
    _PrintEndPrint($hOD)
    _PrintNewPage($hOD)
    _PrintDllClose($hOD)
EndFunc   ;==>_TextToPrint

 

  • 7 months later...
Posted (edited)
2 minutes ago, Parsix said:

links are dead

Do you think any one will guess which link you mean

Please use this feature:

image.png.f878b7c366a0f2339c122f3598766615.png

 

Edited by mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

Spoiler

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

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2023-04-24

Posted
On 8/10/2007 at 2:06 AM, martin said:

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
_PrintSetTitle
Printer control
_PrintStartPrint
_PrintAbort
_PrintEndPrint
_PrintNewPage
Printer 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 landsacpe
Text printing
_PrintSetFont - Font, size, attributes and colour
_PrintText - At x,y and angle.
_PrintGetextWidth
_PrintGetTextHeight
Graphics
_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

Download Links are dead

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...