Jump to content
martin

printing using UDF and a dll

Recommended Posts

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

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!

Share this post


Link to post
Share on other sites

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.

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).

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

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...