Jump to content

Recommended Posts

Posted (edited)

Today, in the end as well, worked out using the Acrobat Reader ActiveX COM Object "AcroPDF.PDF.1"

#include-once
#include <Constants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Misc.au3>
#include <MenuConstants.au3>
#include <WinAPI.au3>

;~ Thanks to BrewManNH
;~ http://www.autoitscript.com/forum/topic/134878-guiregistermsg-replacement-for-guictrlsetonevent-and-guigetmsg/
;~ Thanks to mikell
;~ http://www.autoitscript.com/forum/topic/161985-how-to-close-gui-with-guiregistermsg/


; Install a custom error handler
Global $oMyError = ObjEvent("AutoIt.Error", "_ComErrFunc")

Global $__hExampleGUI
Global $__idOPEN
Global $_fExit

Global $__hACROBAT_GUI = ''
Global $__idACROBAT_GUI_CTRL_AX = ''
Global $__oACROBAT_READER = ''

#include <GUIConstantsEx.au3>

;~ GUIRegisterMsg($WM_ERASEBKGND, "_WM_EXTRACTOR")
;~ GUIRegisterMsg($WM_PAINT, "_WM_EXTRACTOR")
;~ GUIRegisterMsg($WM_ACTIVATE, "_WM_EXTRACTOR")
;~ GUIRegisterMsg($WM_CAPTURECHANGED, "_WM_EXTRACTOR")
;~ GUIRegisterMsg($WM_DEVICECHANGE, "_WM_EXTRACTOR")
GUIRegisterMsg($WM_EXITSIZEMOVE, "_WM_EXTRACTOR")
GUIRegisterMsg($WM_COMMAND, "_WM_EXTRACTOR")
GUIRegisterMsg($WM_SYSCOMMAND, "_WM_EXTRACTOR")
GUIRegisterMsg($WM_HSCROLL, "_WM_EXTRACTOR")

_ExampleProgram_Gui()

While 1
    Sleep(10)
    If $_fExit Then
        _ACROBAT_GUI_DELETE()
        DeleteGui()
        Exit
    EndIf
WEnd


Func DeleteGui()
    GUIDelete($__hExampleGUI)
EndFunc   ;==>DeleteGui

Func _ExampleProgram_Gui()
    ; Create a GUI with various controls.
    $__hExampleGUI = GUICreate("Example")
    $__idOPEN = GUICtrlCreateButton("&Open", 310, 370, 85, 25)

    ; Display the GUI.
    GUISetState(@SW_SHOW, $__hExampleGUI)
EndFunc   ;==>_ExampleProgram_Gui



#Region ACROBAT FUNCTION
Func _AcrobatInit()
    $__oACROBAT_READER = ObjCreate("AcroPDF.PDF.1");
    Return $__oACROBAT_READER.GetVersions
EndFunc   ;==>_AcrobatInit

Func _Acrobat_Events(ByRef $aMSG)
    If $aMSG[1] = $__hACROBAT_GUI Then
        Switch $aMSG[0]
            Case $GUI_EVENT_CLOSE
                _ACROBAT_GUI_DELETE()
        EndSwitch
    EndIf
EndFunc   ;==>_Acrobat_Events

Func _ACROBAT_Destroy()
    $__oACROBAT_READER = ""
;~  MsgBox(1,'test','destroyed')
EndFunc   ;==>_ACROBAT_Destroy

Func _AcrobatShow($sFile, $sTitle = "PDF ", $iLeft = 50, $iTop = 0, $iWidth = 1000, $iHeight = 700)
    If FileExists($sFile) Then
        _AcrobatInit()

        ; Set option
        $__oACROBAT_READER.src = $sFile
        $__oACROBAT_READER.SetLayoutMode(4)
        $__oACROBAT_READER.SetPageMode(1)
        $__oACROBAT_READER.SetShowToolbar(0)
        $__oACROBAT_READER.SetView(1)

        ; Create GUI
        $__hACROBAT_GUI = GUICreate($sTitle, $iWidth, $iHeight, $iLeft, $iTop, BitOR($GUI_SS_DEFAULT_GUI, $WS_SIZEBOX, $WS_MAXIMIZEBOX))
        $__idACROBAT_GUI_CTRL_AX = GUICtrlCreateObj($__oACROBAT_READER, 5, 5, $iWidth - 20, $iHeight - 10)
        GUICtrlSetStyle($__idACROBAT_GUI_CTRL_AX, $WS_VISIBLE)

        GUISetState()
    EndIf
EndFunc   ;==>_AcrobatShow


Func _ACROBAT_Refresh()
    If IsObj($__oACROBAT_READER) Then
        Local $hPreviouslyGui = GUISwitch($__hACROBAT_GUI)
        GUISetState(@SW_LOCK)
        Local $iGUI_PDFWidth = WinGetPos($__hACROBAT_GUI)[2] - 20
        Local $iGUI_PDFHeight = WinGetPos($__hACROBAT_GUI)[3] - 40
        Local $sFile = $__oACROBAT_READER.src

        ; this below line do not works with Acro Reader
        ; Local $iCurrentPage = $__oACROBAT_READER.GetNumber
        Local $iCurrentPage = 0
        _ACROBAT_Destroy()
        GUICtrlDelete($__idACROBAT_GUI_CTRL_AX)
        _AcrobatInit()
        $__idACROBAT_GUI_CTRL_AX = GUICtrlCreateObj($__oACROBAT_READER, 5, 5, $iGUI_PDFWidth, $iGUI_PDFHeight)
        $__oACROBAT_READER.src = $sFile
;~      $__oACROBAT_READER.SetCurrentPage($iCurrentPage)
        GUISetState(@SW_UNLOCK)
        GUISwitch($hPreviouslyGui)
    EndIf
EndFunc   ;==>_ACROBAT_Refresh

Func _ACROBAT_GUI_DELETE()
    _ACROBAT_Destroy()
    if IsHWnd($__hACROBAT_GUI) then GUIDelete($__hACROBAT_GUI)
EndFunc   ;==>_ACROBAT_GUI_DELETE

#EndRegion ACROBAT FUNCTION

#Region MSG and ERROR  HANDLER
Func _WM_EXTRACTOR($hWnd, $iMsg, $wParam, $lParam)
;~  ConsoleWrite('! $hWnd = ' & $hWnd & '    $iMsg = ' & $iMsg & '('&HEX($iMsg)&')'& '    $wParam = ' & $wParam & '    $lParam = ' & $lParam & @CRLF)
    If $hWnd = ControlGetHandle($__hACROBAT_GUI, '', $__idACROBAT_GUI_CTRL_AX) Then
        ConsoleWrite('! --------------  $hWnd = ' & $hWnd & '    $iMsg = ' & $iMsg & '(' & Hex($iMsg) & ')' & '    $wParam = ' & $wParam & '    $lParam = ' & $lParam & @CRLF)
    EndIf
    If $hWnd = $__hACROBAT_GUI Then
        Switch $iMsg
            Case $WM_COMMAND
                #cs
                    Case $WM_ACTIVATE
                    Local $test = BitAND($wParam, 0x00000004)
                    if $test <> 0 then
                    MsgBox(1,'$WM_ACTIVATE','test')
                    _ACROBAT_Refresh()
                    EndIf
                    Case $WM_ERASEBKGND
                    WinGetHandle("[ACTIVE]")
                    if $__hACROBAT_GUI <> _WinAPI_GetWindow ( $__hACROBAT_GUI, $GW_HWNDPREV ) then
                    ConsoleWrite('!  Case $WM_ERASEBKGND' & @CRLF)
                    _ACROBAT_Refresh()
                    _WinAPI_RedrawWindow($__hACROBAT_GUI,0,0,$RDW_NOERASE)
                    EndIf
                    Case $WM_PAINT
                    _WinAPI_RedrawWindow($__hACROBAT_GUI,0,0,$RDW_NOERASE)
                    Case $WM_CAPTURECHANGED
                    _ACROBAT_Refresh()
                    Case $WM_DEVICECHANGE
                    _ACROBAT_Refresh()
                #ce
            Case $WM_EXITSIZEMOVE
                _ACROBAT_Refresh()
            Case $WM_SYSCOMMAND
;~              Local $test = BitAND($wParam, 0xFFF0)
                Local $test = BitAND($wParam, 0x0000FFFF)
                Switch $test
                    Case $SC_CLOSE
                        _ACROBAT_GUI_DELETE()
                    Case $SC_CONTEXTHELP
                    Case $SC_DEFAULT
                    Case $SC_HOTKEY
                    Case $SC_HSCROLL
                    Case $SC_KEYMENU
                    Case $SC_MAXIMIZE
                        _ACROBAT_Refresh()
                    Case $SC_MINIMIZE
                    Case $SC_MONITORPOWER
                    Case $SC_MOUSEMENU
                    Case $SC_MOVE
;~                      _ACROBAT_Refresh()
                    Case $SC_NEXTWINDOW
;~                      _ACROBAT_Refresh()
                    Case $SC_PREVWINDOW
;~                      _ACROBAT_Refresh()
                    Case $SC_RESTORE
                        _ACROBAT_Refresh()
                    Case $SC_SCREENSAVE
                    Case $SC_SIZE
                    Case $SC_TASKLIST
                    Case $SC_VSCROLL
                EndSwitch
        EndSwitch
    EndIf


    If $hWnd = $__hExampleGUI Then
        Switch $iMsg
            Case $WM_COMMAND
                Local $nID = BitAND($wParam, 0x0000FFFF)
                Local $hCtrl = $lParam
                Switch $nID
                    Case $__idOPEN
                        if not IsObj($__oACROBAT_READER) then
                            _AcrobatShow(FileOpenDialog("Choose PDF", "C:\Temp", "PDF Files(*.pdf)", 3)) ; put your own start folder here)
                        EndIf
                EndSwitch

            Case $WM_SYSCOMMAND
                Local $test = BitAND($wParam, 0xFFF0)
                Switch $test
                    Case $SC_CLOSE
                        $_fExit = True
                    Case $SC_CONTEXTHELP
                    Case $SC_DEFAULT
                    Case $SC_HOTKEY
                    Case $SC_HSCROLL
                    Case $SC_KEYMENU
                    Case $SC_MAXIMIZE
                    Case $SC_MINIMIZE
                    Case $SC_MONITORPOWER
                    Case $SC_MOUSEMENU
                    Case $SC_MOVE
                    Case $SC_NEXTWINDOW
                    Case $SC_PREVWINDOW
                    Case $SC_RESTORE
                    Case $SC_SCREENSAVE
                    Case $SC_SIZE
                    Case $SC_TASKLIST
                    Case $SC_VSCROLL
                EndSwitch
        EndSwitch
    EndIf

    Return $GUI_RUNDEFMSG
EndFunc   ;==>_WM_EXTRACTOR

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   ;==>_ComErrFunc

#EndRegion MSG and ERROR  HANDLER

Any comments are welcome.

Cheers

mLipok

Edited by mLipok
fix code highlighitng

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

  • 2 weeks later...
Posted (edited)

Below I would like to introduce a new version of "AcrobatReaderViewer.au3," which uses my new UDF file:

"GUIRegisterMsg_API.au3"

 

mLipok

 

EDIT: added link

EDIT: I forgot about example:

#include "AcrobatReaderViewer.au3"
#include "GUIRegisterMsg_API.au3"

Global $oMyError = ObjEvent("AutoIt.Error", "_ComErrFunc")

Global $_hExampleGUI
Global $_idOPEN
Global $_bExit

Main()

Func Main()
    _GUIRegisterMsg_API_Start()
    ; here you add support for _MY_CURRENT_GUI_WM_EXTRACTOR
    _GUIRegisterMsg_API_AddFunc(_MY_CURRENT_GUI_WM_EXTRACTOR)
    ; here you add support for _ACROBAT_WM_EXTRACTOR
    _GUIRegisterMsg_API_AddFunc(_ACROBAT_WM_EXTRACTOR)

    ; here you can chceck what happen when you remove Remove Function from $__aGUIRegisterMsg_API[] by using _GUIRegisterMsg_API_RemoveFunc
    ; _GUIRegisterMsg_API_RemoveFunc(_ACROBAT_WM_EXTRACTOR)

    _ExampleProgram_Gui()

    While 1
        Sleep(10)
        If $_bExit Then
            _ACROBAT_GUI_DELETE()
            DeleteGui()
            Exit
        EndIf
    WEnd

EndFunc   ;==>Main
Exit

#Region EXAMPLE GUI
Func DeleteGui()
    GUIDelete($_hExampleGUI)
EndFunc   ;==>DeleteGui

Func _ExampleProgram_Gui()
    ; Create a GUI with various controls.
    $_hExampleGUI = GUICreate("Example")
    $_idOPEN = GUICtrlCreateButton("&Open", 310, 370, 85, 25)

    ; Display the GUI.
    GUISetState(@SW_SHOW, $_hExampleGUI)
EndFunc   ;==>_ExampleProgram_Gui
#EndRegion EXAMPLE GUI

#Region _MY_CURRENT_GUI_WM_EXTRACTOR
Func _MY_CURRENT_GUI_WM_EXTRACTOR($hWnd, $iMsg, $wParam, $lParam)
    If $hWnd = $_hExampleGUI Then
        Switch $iMsg
            Case $WM_COMMAND
                Local $nID = BitAND($wParam, 0x0000FFFF)
                Local $hCtrl = $lParam
                Switch $nID
                    Case $_idOPEN
                        If Not IsObj($__oACROBAT_READER) Then
                            _AcrobatShow(FileOpenDialog("Choose PDF", "C:\Temp", "PDF Files(*.pdf)", 3)) ; put your own start folder here)
                        EndIf
                EndSwitch

            Case $WM_SYSCOMMAND
                Local $test = BitAND($wParam, 0xFFF0)
                Switch $test
                    Case $SC_CLOSE
                        $_bExit = True
                    Case $SC_CONTEXTHELP
                    Case $SC_DEFAULT
                    Case $SC_HOTKEY
                    Case $SC_HSCROLL
                    Case $SC_KEYMENU
                    Case $SC_MAXIMIZE
                    Case $SC_MINIMIZE
                    Case $SC_MONITORPOWER
                    Case $SC_MOUSEMENU
                    Case $SC_MOVE
                    Case $SC_NEXTWINDOW
                    Case $SC_PREVWINDOW
                    Case $SC_RESTORE
                    Case $SC_SCREENSAVE
                    Case $SC_SIZE
                    Case $SC_TASKLIST
                    Case $SC_VSCROLL
                EndSwitch
        EndSwitch
    EndIf


EndFunc   ;==>_MY_CURRENT_GUI_WM_EXTRACTOR

#EndRegion _MY_CURRENT_GUI_WM_EXTRACTOR

btw.

_EXAMPLE_RegisterMsg() is not used so I removed them.

AcrobatReaderViewer.au3.Download.html

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

  • 1 month later...
Posted

No.

This is just a viewer based on Acrobat Reader ActiveX control.

But you  can try to use my Debenu Quick PDF UDF

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

  • 3 years later...
Posted

old topic but... is there a way to open password-protected PDF by providing the password internally?

it would be not strong protection but for some user impossible to crack the way of open some confidential information ....

  • 2 months later...
Posted
  On 9/19/2017 at 3:30 PM, mike13 said:

old topic but... is there a way to open password-protected PDF by providing the password internally?

it would be not strong protection but for some user impossible to crack the way of open some confidential information ....

Expand  

I'm just looking for the same right now

Posted

@Qwerty212 There aren't any command line parameters for opening a PDF like that in Acrobat. If you're looking to manipulate it, I've used a python library to concatenate encrypted PDFs and I post the name of it tomorrow. If you just want to open it, start it minimized, wait for the popup, fill it out, and maximize it again. Alternately, decrypt it with a python library and encrypt it again when you are done :)

All my code provided is Public Domain... but it may not work. ;) Use it, change it, break it, whatever you want.

  Reveal hidden contents
  • 3 weeks later...
Posted
  On 9/25/2019 at 12:46 AM, seadoggie01 said:

@Qwerty212 There aren't any command line parameters for opening a PDF like that in Acrobat. If you're looking to manipulate it, I've used a python library to concatenate encrypted PDFs and I post the name of it tomorrow. If you just want to open it, start it minimized, wait for the popup, fill it out, and maximize it again. Alternately, decrypt it with a python library and encrypt it again when you are done :)

Expand  

I would really appreciate it.

I need to open pdf's files from an ftp (ideally without downloading them to the local disc).

I have tried to use a secured version of SumatraPDF, but it can not open password protected files and it can not also play embedded media inside the pdfs, so I thought that creating a GUI with Acrobat Reader embedded might be a good alternative.

 

Greets from Barcelona

Posted

@Qwerty212 The python library I used was PyPDF2. It's very quick and seems quite reliable. :) Good luck!

All my code provided is Public Domain... but it may not work. ;) Use it, change it, break it, whatever you want.

  Reveal hidden contents
Posted
  On 10/10/2019 at 12:36 PM, Qwerty212 said:

I need to open pdf's files from an ftp (ideally without downloading them to the local disc).

Expand  

You can do this with QucikPDF UDF.....

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)

I do not know... never tried before.

Just ask in the support topic, but could you post any example pdf file? 

Edit:

as far I only embend xml, and html file in pdf.

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

  • 1 year later...
Posted (edited)

For current AcrobatReader UDF BETA version check the attached file.

 

AcrobatReader.zipFetching info...

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)

I have still few problems with this implementation, which I try to describe later this weekend.

 

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)

I get 5 of these at lines 112 to 116, but it does open the pdf file.

image.png.9bd7c2c78d9275a873631a6659afd469.png

 

image.png.56dca654b72b025b8341845001ddd0ec.png

 

 

 

 

 

 

Edited by dmob
Sorry I attached wrong images, cant seem to remove them.
Posted

Here is second example like a "Slide Show"

AcrobatReader_Example_2_Folder_SlideShow.au3Fetching info...

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
  On 3/26/2021 at 3:19 PM, dmob said:

image.png.9bd7c2c78d9275a873631a6659afd469.png

Expand  

This is because this few lines use properties or method which exist only for ArobatReader object, and not for Foxit.
Just comment these few lines.

 

Check here:

https://developers.foxitsoftware.com/resources/pdf-sdk-activex/FoxitPDFActiveX_5_9_Manual.pdf

and take a look here:
https://www.vbforums.com/showthread.php?882115-PDF-Reader-ActiveX-Control

Also take a look here:
https://github.com/pvginkel/PdfiumBuild/tree/master/Builds/2018-04-08
https://github.com/pvginkel/PdfiumViewer
 

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
  On 3/26/2021 at 2:35 PM, mLipok said:

I have still few problems with this implementation, which I try to describe later this weekend.

Expand  

please check:

  On 3/29/2021 at 10:07 PM, mLipok said:

Here is second example like a "Slide Show"

AcrobatReader_Example_2_Folder_SlideShow.au3 560 B · 0 downloads

Expand  

This example ask for directory with PDF files.
It shows how how the window is still "blinking" when the next PDF files are loaded,

Any one have any idea how to prevent "blinking".

?
 

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
  On 3/26/2021 at 3:19 PM, dmob said:

I get 5 of these at lines 112 to 116, but it does open the pdf file.........

Expand  

In edit you wrote that "Sorry I attached wrong images, cant seem to remove them."

 

Try to edit post and then focus on the panel below the text you edit.
There are listed all files and screenshot.

image.png.2db2d9cd22994b8074c61100b3214a1e.png

image.png.ea7516725b4d5db4da47547675dca933.png

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