Jump to content

Recommended Posts

Posted (edited)

I was allways wondering How to get reference to AcrobatReader  object and after all to the PDF file embeded in IE.

Today I was here:

http://www.vitoplantamura.com/index.aspx?page=axvncviewer

 

there is such a interesting html:

  Quote

<html>
<body>

<script language="JavaScript">

function rsChange ()
{
    var ax = document.all.TestObj;
    if ( ax.readyState == 4 )
    {
        if ( ax.IsInitialized == false )
        {
            window.setTimeout( "rsChange();", 100 );
        }
        else
        {
            ax.Server = "192.168.1.3";
            ax.Connect ();
        }
    }
}

</script>

<OBJECT language='javascript' ID='TestObj' CLASSID='CLSID:36D64AE5-6626-4DDE-A958-2FF1D46D4424' WIDTH='640px' HEIGHT='480px' onreadystatechange='rsChange();'></OBJECT>

<br><br><br>

Don't forget to do a "REGSVR32 UltraVncAx.dll", before viewing this page.<br>
The timer trick in the rsChange() function is required to get the windowful ActiveX initialized properly, before letting the ActiveX create the VNC client child window.

</body>
</html>

 

When I analyze this then I start to wonder about this line:

  Quote

 var ax = document.all.TestObj;

 

EDIT: above fraction was only an introduction, describing where it came my question.

 

And now then the question arise :

How I can use document.all to get the refrence to specified AxObject in this Case I mean to AcrobatReader opened in IE ?

EDIT: of course I mean a case when I have opened document in IE.

 

 

Edited by mLipok
added TAG

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
#include <IE.au3>

Local $oIE_PDF = _IECreate("http://lipok.pl/test2.pdf", 0 , 1 , 0 )
MsgBox(0, '1', 'wait')
$oIE_PDF.document.GotoFirstPage
MsgBox(0, '2', '$oIE_PDF.document.GotoFirstPage')
$oIE_PDF.document.SetZoom(200)
MsgBox(0, '3', '$oIE_PDF.document.SetZoom(200)')
$oIE_PDF.document.SetZoom(20)
MsgBox(0, '4', '$oIE_PDF.document.SetZoom(20)')
$oIE_PDF.document.LoadFile("http://lipok.pl/test.pdf")
MsgBox(0, '5', '$oIE_PDF.document.LoadFile("http://lipok.pl/test2.pdf")')
$oIE_PDF.document.LoadFile(@ScriptDir & "\test3.pdf")
MsgBox(0, '6', '$oIE_PDF.document.LoadFile(@ScriptDir & "\test3.pdf")')

_IEQuit($oIE_PDF)

What you think about ?

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)

Here is some other example (Remark/Beware: Printer is used).

#include <IE.au3>
#include <MsgBoxConstants.au3>


Local $oIE_PDF = _IECreate("http://lipok.pl/test.pdf", 0 , 1 , 0 )

Local $oPDF = $oIE_PDF.document
If @error Then Sleep(100)
ObjName_FlagsValue($oPDF)
MsgBox(0, '0', '$oPDF.src = ' & $oPDF.src)

$oPDF.GotoFirstPage
MsgBox(0, '1', '$oPDF.GotoFirstPage')
$oPDF.SetZoom(200)
MsgBox(0, '2', '$oPDF.SetZoom(200)')
$oPDF.printAll()
MsgBox(0, '2a', '$oPDF.printAll()')
$oPDF.SetZoom(20)
MsgBox(0, '3', '$oPDF.SetZoom(20)')
$oPDF.LoadFile("http://lipok.pl/test2.pdf")
MsgBox(0, '4', '$oPDF.LoadFile("http://lipok.pl/test2.pdf")'& @CRLF & '$oPDF.src = ' & $oPDF.src)
$oPDF.LoadFile(@ScriptDir & "\test3.pdf")
MsgBox(0, '5', '$oPDF.LoadFile(@ScriptDir & "\test3.pdf")' & @CRLF & '$oPDF.src = ' & $oPDF.src )

_IEQuit($oIE_PDF)

Func ObjName_FlagsValue(ByRef $oObj)
    Local $sInfo = ''

    $sInfo &= '+>' & @TAB & 'ObjName($oObj,1) {The name of the Object} =' & @CRLF & @TAB & ObjName($oObj, $OBJ_NAME) & @CRLF

    ; HELPFILE REMARKS: Not all Objects support flags 2 to 7. Always test for @error in these cases.
    $sInfo &= '+>' & @TAB & 'ObjName($oObj,2) {Description string of the Object} =' & @CRLF & @TAB & ObjName($oObj, $OBJ_STRING)
    If @error Then $sInfo &= '@error = ' & @error
    $sInfo &= @CRLF & @CRLF

    $sInfo &= '+>' & @TAB & 'ObjName($oObj,3) {The ProgID of the Object} =' & @CRLF & @TAB & ObjName($oObj, $OBJ_PROGID)
    If @error Then $sInfo &= '@error = ' & @error
    $sInfo &= @CRLF & @CRLF

    $sInfo &= '+>' & @TAB & 'ObjName($oObj,4) {The file that is associated with the object in the Registry} =' & @CRLF & @TAB & ObjName($oObj, $OBJ_FILE)
    If @error Then $sInfo &= '@error = ' & @error
    $sInfo &= @CRLF & @CRLF

    $sInfo &= '+>' & @TAB & 'ObjName($oObj,5) {Module name in which the object runs (WIN XP And above). Marshaller for non-inproc objects.} =' & @CRLF & @TAB & ObjName($oObj, $OBJ_MODULE)
    If @error Then $sInfo &= '@error = ' & @error
    $sInfo &= @CRLF & @CRLF

    $sInfo &= '+>' & @TAB & 'ObjName($oObj,6) {CLSID of the object''s coclass} =' & @CRLF & @TAB & ObjName($oObj, $OBJ_CLSID)
    If @error Then $sInfo &= '@error = ' & @error
    $sInfo &= @CRLF & @CRLF

    $sInfo &= '+>' & @TAB & 'ObjName($oObj,7) {IID of the object''s interface} =' & @CRLF & @TAB & ObjName($oObj, $OBJ_IID)
    If @error Then $sInfo &= '@error = ' & @error
    $sInfo &= @CRLF & @CRLF

    MsgBox($MB_SYSTEMMODAL, "ObjName:", $sInfo)
EndFunc   ;==>ObjName_FlagsValue

 

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

Thanks to Mod for moving this topic to Examples forum (I posted it in "Developer General Discussion").

 

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 guess you are asking in relation to this:

I will back to this above topic soon.

 

Edited by mLipok
typo

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

Here are some further interesting information:

http://www.programering.com/a/MzM3UDNwATc.html

 

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

  • 5 years later...
Posted (edited)

Today thanks to @Danyfirex help, and thanks to this topic, I was able to make better AcrobatReader Viewer.

Quick example:
 

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

Example()

Func Example()
    ; This particular object is declared as ObjEvent() need to stored the Object, #forceref to avoid Au3Check warning.
    Local $oErrorHandler = ObjEvent("AutoIt.Error", _ErrFunc)
    #forceref $oErrorHandler

    ; Create a simple GUI for our output
    Local $hGUI = GUICreate("Embedded Web control Test", 640, 580, -1, -1, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS, $WS_CLIPCHILDREN))

    Local $oIE = ObjCreate("Shell.Explorer.2")
    Local $iID = GUICtrlCreateObj($oIE, 5, 5, 640 - 10, 580 - 10)
    #forceref $iID
    GUICtrlSetResizing(-1, $GUI_DOCKAUTO)
    GUISetState(@SW_SHOW) ;Show GUI
    Local $s_PDF_FileFullPath = FileOpenDialog("Choose PDF", "C:\Temp", "PDF Files(*.pdf)", 3)
    Local $oPDF
    If FileExists($s_PDF_FileFullPath) Then
        $oIE.navigate($s_PDF_FileFullPath)
;~      ObjName_FlagsValue($oIE)
        $oPDF = $oIE.document ; https://www.autoitscript.com/forum/topic/177368-how-to-get-reference-to-pdf-object-embeded-in-ie/?do=findComment&comment=1272692
;~      ObjName_FlagsValue($oPDF)
;~      $oPDF.LoadFile($s_PDF_FileFullPath)
        $oPDF.GotoFirstPage
;~      $oPDF.SetZoom(200)
;~      $oPDF.SetZoom(20)

        $oPDF.SetLayoutMode('SinglePage')
        $oPDF.SetPageMode('none')
        $oPDF.SetShowToolbar(0)
        $oPDF.SetShowScrollbars(0)
        $oPDF.SetView('FitBH')
        $oPDF.SetViewScroll('FitBH',10)
;~      $oPDF.SetViewRect(100,100,100,100)
;~      $oPDF.SetCurrentHighlight(10,10,50,50)

    EndIf

    Local $a_Msg
    ; Loop until the user exits.
    While 1
        $a_Msg = GUIGetMsg($GUI_EVENT_ARRAY)

        If $a_Msg[1] = $hGUI Then
            Switch $a_Msg[0]
                Case $GUI_EVENT_CLOSE
                    ExitLoop
                Case $GUI_EVENT_MAXIMIZE, $GUI_EVENT_RESIZED, $GUI_EVENT_RESTORE ; , $GUI_EVENT_PRIMARYDOWN
                    $oPDF.SetLayoutMode('SinglePage')
                    $oPDF.SetPageMode('none')
                    $oPDF.SetShowToolbar(0)
                    $oPDF.SetShowScrollbars(0)
                    $oPDF.SetView('FitBH')
                    $oPDF.SetViewScroll('FitBH',10)
;~                  $oPDF.SetViewRect(100,100,100,100)
;~                  $oPDF.SetCurrentHighlight(10,10,50,50)
            EndSwitch
        EndIf

    WEnd

    GUIDelete()
EndFunc   ;==>Example

; User's COM error function. Will be called if COM error occurs
Func _ErrFunc($oError)
    ; Do anything here.
    ConsoleWrite(@ScriptName & " (" & $oError.scriptline & ") : ==> COM Error intercepted !" & @CRLF & _
            @TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _
            @TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _
            @TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _
            @TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _
            @TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _
            @TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _
            @TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _
            @TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _
            @TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF)
EndFunc   ;==>_ErrFunc


Func ObjName_FlagsValue(ByRef $oObj)
    Local $sInfo = ''

    $sInfo &= '+>' & @TAB & 'ObjName($oObj,1) {The name of the Object} =' & @CRLF & @TAB & ObjName($oObj, $OBJ_NAME) & @CRLF

    ; HELPFILE REMARKS: Not all Objects support flags 2 to 7. Always test for @error in these cases.
    $sInfo &= '+>' & @TAB & 'ObjName($oObj,2) {Description string of the Object} =' & @CRLF & @TAB & ObjName($oObj, $OBJ_STRING)
    If @error Then $sInfo &= '@error = ' & @error
    $sInfo &= @CRLF & @CRLF

    $sInfo &= '+>' & @TAB & 'ObjName($oObj,3) {The ProgID of the Object} =' & @CRLF & @TAB & ObjName($oObj, $OBJ_PROGID)
    If @error Then $sInfo &= '@error = ' & @error
    $sInfo &= @CRLF & @CRLF

    $sInfo &= '+>' & @TAB & 'ObjName($oObj,4) {The file that is associated with the object in the Registry} =' & @CRLF & @TAB & ObjName($oObj, $OBJ_FILE)
    If @error Then $sInfo &= '@error = ' & @error
    $sInfo &= @CRLF & @CRLF

    $sInfo &= '+>' & @TAB & 'ObjName($oObj,5) {Module name in which the object runs (WIN XP And above). Marshaller for non-inproc objects.} =' & @CRLF & @TAB & ObjName($oObj, $OBJ_MODULE)
    If @error Then $sInfo &= '@error = ' & @error
    $sInfo &= @CRLF & @CRLF

    $sInfo &= '+>' & @TAB & 'ObjName($oObj,6) {CLSID of the object''s coclass} =' & @CRLF & @TAB & ObjName($oObj, $OBJ_CLSID)
    If @error Then $sInfo &= '@error = ' & @error
    $sInfo &= @CRLF & @CRLF

    $sInfo &= '+>' & @TAB & 'ObjName($oObj,7) {IID of the object''s interface} =' & @CRLF & @TAB & ObjName($oObj, $OBJ_IID)
    If @error Then $sInfo &= '@error = ' & @error
    $sInfo &= @CRLF & @CRLF

    MsgBox($MB_SYSTEMMODAL, "ObjName:", $sInfo)
EndFunc   ;==>ObjName_FlagsValue

 

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

I am using the free Foxit Reader. Your script generates a number of Unknown name COM errors, but embeds the

(Foxit?) object, loads and displays properly the PDF.

Great job, I can use this in my app :thumbsup:

Posted (edited)

You have Commercial ActiveX component for Foxit Reader ?
Or you are just using

https://www.foxitsoftware.com/pdf-reader/

?

 

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)

As I remember old version of FoxIt reader had exposed ActiveX interface, the current one needs commercial license, and maybe because of this fact I'm not able to get it works.
Current version of FoxIt Reader open PDF as default in windows, but in my script still AcrobatReader is used... interesting.

 

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
  On 3/22/2021 at 9:34 AM, dmob said:

does this mean that IE object loads the default PDF handler?

Expand  

It should but not in my case.... 🤔

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

It could be interesting.

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

I've tested in a machine without foxit or acrobat and it does not show the PDF file. It show as a download progress file and then request to open with a default pdf viewer in my case SumatraPDF. Of course it will not work because there is not any object registered/associated to .pdf like acrobat and foxit do.

 

Saludos

Posted (edited)
  On 3/22/2021 at 9:54 AM, dmob said:

It would be interesting to try it on a machine without Foxit or Acrobat installed. I'll try to find time....

Expand  

Please check:

with Foxit Reader.

I will wait for your's response in Acrobat Reader - ActiveX Viewer.

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

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