Jump to content

Recommended Posts

Posted (edited)

Hello all,
 
I have to print a lot pdf labels during a day at work.
One of our customers delivers them as a pdf file on a single A4 page.
 
Every time when i need to print a specific label, i need to do the handling below to print
the selected label to our Dymo printer.
Can this be automated in a simple way?
 
1. Zoom opened pdf to 350%
2. Resize the window to fit the label
3. Select print
4. Choose printer
5. Select properties
6. Select left roll
7. Select the correct label size
8. Select current view
9. Press print......
 
If found the code below in the forum, is this, with some adjustments of course usable?
(Thanks to M23)
 

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

; Install a custom error handler
Global $oMyError = ObjEvent("AutoIt.Error","_ComErrFunc")
Global $iGUIWidth = 800, $iGUIHeight = 570, $fResized = False

_Show_PDF()

Func _Show_PDF()

    ; Get file to display
    Local $sFile = FileOpenDialog("Choose PDF", "C:\Temp", "PDF Files(*.pdf)", 3) ; put your own start folder here
    If @error Then
        MsgBox(0, "Error", "No file selected")
        Return
    EndIf

    ; Declare objects
    Local $oPDF = ObjCreate("AcroPDF.PDF.1");
    $oPDF.src = $sFile

    ; Create GUI
    GUICreate("Label Printer", 1580, 590, -1, -1, BitOr($GUI_SS_DEFAULT_GUI, $WS_SIZEBOX, $WS_MAXIMIZEBOX))
    Local $GUI_ActiveX = GUICtrlCreateObj($oPDF, 10, 10, 1560, 570)
    GUICtrlSetStyle($GUI_ActiveX, $WS_VISIBLE)
    GUICtrlSetResizing($GUI_ActiveX, $GUI_DOCKAUTO) ; Auto Resize Object
    GUISetState()

    ; When window is resized, run this function
    GUIRegisterMsg($WM_SIZE, "MY_WM_SIZE")

    While 1

        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch

        If $fResized = True Then
            ConsoleWrite($iGUIWidth & " - " & $iGUIHeight & @CRLF)
            $fResized = False
            WinMove($GUI_ActiveX, "", Default, Default, $iGUIWidth - 20, $iGUIHeight - 20)
        EndIf

    WEnd

    ; Clear up
    $oPDF = ""
    $GUIActiveX = ""

    Exit

EndFunc

Func MY_WM_SIZE($hWnd, $Msg, $wParam, $lParam)

    $iGUIWidth = BitAND($lParam, 0xFFFF)
    $iGUIHeight = BitShift($lParam, 16)
    $fResized = True

    Return $GUI_RUNDEFMSG

EndFunc   ;==>MY_WM_SIZE

Func _ComErrFunc()

  Local $HexNumber = Hex($oMyError.number,8)
  Msgbox(0,"AutoItCOM Test","We intercepted a COM Error !"       & @CRLF  & @CRLF & _
             "err.description is: "    & @TAB & $oMyError.description    & @CRLF & _
             "err.windescription:"     & @TAB & $oMyError.windescription & @CRLF & _
             "err.number is: "         & @TAB & $HexNumber              & @CRLF & _
             "err.lastdllerror is: "   & @TAB & $oMyError.lastdllerror   & @CRLF & _
             "err.scriptline is: "     & @TAB & $oMyError.scriptline     & @CRLF & _
             "err.source is: "         & @TAB & $oMyError.source         & @CRLF & _
             "err.helpfile is: "       & @TAB & $oMyError.helpfile       & @CRLF & _
             "err.helpcontext is: "    & @TAB & $oMyError.helpcontext _
            )
  SetError(1)

EndFunc
Edited by drbyte
Posted (edited)

look here: Debenu Quick PDF Library - UDF

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:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted (edited)

@mLipok,

Excuses for the late reply.....
I added the QuickPDF.au3 to the include directory and i ran the QuickPDF_Examples.au3.

At that moment i get a lot of errors of missing several .au3 files.

Edited by drbyte
Posted (edited)

Please post in Debenu Quick PDF Library - UDF

And give the entire console output.

 

Edited by mLipok
link fix

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:

  Reveal hidden contents

Signature last update: 2023-04-24

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
×
×
  • Create New...