mark2004 Posted March 14, 2007 Share Posted March 14, 2007 I would like to display a PDF file in a GUI (much like what is done with GUICTRLCREATEPIC and a jpg). I've searched the archives and still haven't found a conclusive answer on this one. Any ideas?? Link to comment Share on other sites More sharing options...
Richard Robertson Posted March 14, 2007 Share Posted March 14, 2007 Try loading the ActiveX for Adobe. I can't tell you much about it because I don't use ActiveX. Link to comment Share on other sites More sharing options...
gadzail Posted March 15, 2007 Share Posted March 15, 2007 I would like to display a PDF file in a GUI (much like what is done with GUICTRLCREATEPIC and a jpg). I've searched the archives and still haven't found a conclusive answer on this one. Any ideas?? something like this? expandcollapse popup#include <GUIConstants.au3> ;Vars Dim $oMyError Dim $File Dim $Version ;Declare objects $oPDF = ObjCreate("AcroPDF.PDF.1"); $Version=$oPDF.GetVersions $oPDF.src="LittleBookOfRuby.pdf" ;PDF FILE 1 ;Main Gui GuiCreate("PDF Object", 802, 590,(@DesktopWidth-802)/2, (@DesktopHeight-590)/2 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS) $GUI_ActiveX = GUICtrlCreateObj ($oPDF, 10, 10 , 780 , 550) GUICtrlSetStyle ( $GUI_ActiveX, $WS_VISIBLE ) GUICtrlSetResizing ($GUI_ActiveX,$GUI_DOCKAUTO) ; Auto Resize Object GuiSetState(@SW_SHOW) MsgBox(4096,"Show Versions",$Version) GuiSetState(@SW_SHOWDEFAULT) Sleep(1500) $oPDF.src="test.pdf" ;PDF FILE 2 While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop EndSelect WEnd $oPDF = "" $GUIActiveX = "" Exit ;This is SvenP 's custom error handler Func MyErrFunc() $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) ; to check for after this function returns Endfunc Link to comment Share on other sites More sharing options...
gcriaco Posted March 15, 2007 Share Posted March 15, 2007 something like this? expandcollapse popup#include <GUIConstants.au3> ;Vars Dim $oMyError Dim $File Dim $Version ;Declare objects $oPDF = ObjCreate("AcroPDF.PDF.1"); $Version=$oPDF.GetVersions $oPDF.src="LittleBookOfRuby.pdf" ;PDF FILE 1 ;Main Gui GuiCreate("PDF Object", 802, 590,(@DesktopWidth-802)/2, (@DesktopHeight-590)/2 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS) $GUI_ActiveX = GUICtrlCreateObj ($oPDF, 10, 10 , 780 , 550) GUICtrlSetStyle ( $GUI_ActiveX, $WS_VISIBLE ) GUICtrlSetResizing ($GUI_ActiveX,$GUI_DOCKAUTO) ; Auto Resize Object GuiSetState(@SW_SHOW) MsgBox(4096,"Show Versions",$Version) GuiSetState(@SW_SHOWDEFAULT) Sleep(1500) $oPDF.src="test.pdf" ;PDF FILE 2 While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop EndSelect WEnd $oPDF = "" $GUIActiveX = "" Exit ;This is SvenP 's custom error handler Func MyErrFunc() $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) ; to check for after this function returns Endfunc Very cool example - Thanks (ottimo esempio - Grazie) Peppe Link to comment Share on other sites More sharing options...
mark2004 Posted March 16, 2007 Author Share Posted March 16, 2007 Thanks very much. I was looking for a way to do it without using adobe's reader and i figured out that this basically boils down to converting the pdf to a jpg first, then using GuiCtrlCreatePic. This way you don't have the menus etc associated with embedding an app in the GUI. Very cool code snippet. Its a great example of how to use ActiveX....I will probably refer to it often. something like this? expandcollapse popup#include <GUIConstants.au3> ;Vars Dim $oMyError Dim $File Dim $Version ;Declare objects $oPDF = ObjCreate("AcroPDF.PDF.1"); $Version=$oPDF.GetVersions $oPDF.src="LittleBookOfRuby.pdf" ;PDF FILE 1 ;Main Gui GuiCreate("PDF Object", 802, 590,(@DesktopWidth-802)/2, (@DesktopHeight-590)/2 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS) $GUI_ActiveX = GUICtrlCreateObj ($oPDF, 10, 10 , 780 , 550) GUICtrlSetStyle ( $GUI_ActiveX, $WS_VISIBLE ) GUICtrlSetResizing ($GUI_ActiveX,$GUI_DOCKAUTO) ; Auto Resize Object GuiSetState(@SW_SHOW) MsgBox(4096,"Show Versions",$Version) GuiSetState(@SW_SHOWDEFAULT) Sleep(1500) $oPDF.src="test.pdf" ;PDF FILE 2 While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop EndSelect WEnd $oPDF = "" $GUIActiveX = "" Exit ;This is SvenP 's custom error handler Func MyErrFunc() $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) ; to check for after this function returns Endfunc Link to comment Share on other sites More sharing options...
RulleStenen Posted August 7, 2007 Share Posted August 7, 2007 Thanks very much. I was looking for a way to do it without using adobe's reader and i figured out that this basically boilsdown to converting the pdf to a jpg first, then using GuiCtrlCreatePic. This way you don't have the menus etc associated withembedding an app in the GUI.Very cool code snippet. Its a great example of how to use ActiveX....I will probably refer to it often.Cool It´s Only Rock´n´Roll, But I Like It Link to comment Share on other sites More sharing options...
Richard Robertson Posted August 7, 2007 Share Posted August 7, 2007 How are you converting it to a JPG? If you have the ability to read it, why not output it in a text based format instead? Link to comment Share on other sites More sharing options...
Lee Evans Posted September 19, 2007 Share Posted September 19, 2007 I get the following error when I try to run the script example shown. C:\Program Files\AutoIt3\Examples\GUI\Advanced\PDF in GUI2.au3 (11) : ==> Variable must be of type "Object".: $Version=$oPDF.GetVersions $Version=$oPDF^ ERROR Do I need a specific version of Acrobat reader? Link to comment Share on other sites More sharing options...
ReFran Posted September 19, 2007 Share Posted September 19, 2007 (edited) If I remember right you need a Version >= 7 (Acrobat or Reader). HTH, Reinhard PS: By the way you shouldn't use .. = $oPDF.GetVersions. Adobe will discontinue, but in actual versions it works. Edited September 19, 2007 by ReFran Spined 1 Link to comment Share on other sites More sharing options...
therks Posted September 21, 2007 Share Posted September 21, 2007 I keep getting File does not begin with '%PDF-'. and then an empty window. Any ideas? I found this while Googling, but the files I'm trying work fine if I open them normally. Heck, the file I'm trying to open is "C:\Program Files\Adobe\Acrobat 7.0\Help\ENU\Reader.pdf" ... that's the HELP FILE for Acrobat! Hahaha. I only have problems if I try and open them with AutoIt.Hmm.. just to double check, I opened the file with a hex editor, and it does start with %PDF-. Now I'm really stumped. :\ My AutoIt Stuff | My Github Link to comment Share on other sites More sharing options...
Zedna Posted September 21, 2007 Share Posted September 21, 2007 $oPDF = ObjCreate("AcroPDF.PDF.1"); This is nice. Can be this PDF COM object downloaded from somewhere without buying full Adobe Acrobat? Is it in Adobe Acrobat Reader (not editor) install package? Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
ReFran Posted September 21, 2007 Share Posted September 21, 2007 $oPDF = ObjCreate("AcroPDF.PDF.1"); This is nice. Can be this PDF COM object downloaded from somewhere without buying full Adobe Acrobat? Is it in Adobe Acrobat Reader (not editor) install package? Works with Acrobat and Reader (versions >= 7). Will be installed from both apps. br, Reinhard Spined 1 Link to comment Share on other sites More sharing options...
ReFran Posted September 21, 2007 Share Posted September 21, 2007 (edited) I get the following error when I try to run the script example shown. C:\Program Files\AutoIt3\Examples\GUI\Advanced\PDF in GUI2.au3 (11) : ==> Variable must be of type "Object".: $Version=$oPDF.GetVersions $Version=$oPDF^ ERROR Do I need a specific version of Acrobat reader? Also with Acrobat/Reader 7 and higher you get this error message if the viewer is not configured to show the PDF in (IE) Browser, what normally is set as standard. Under "Edit" choose "BasicSetting" (last menuitem), select "Internet" and then mark [x] PDF in Viewer (MenuItem Free translated from a german version). For scripter this means, if you want to make shure that "embedded" works, you first have to check/influence the registry key. HTH, Reinhard Edited September 21, 2007 by ReFran Spined 1 Link to comment Share on other sites More sharing options...
therks Posted September 22, 2007 Share Posted September 22, 2007 Anybody else have the same problem as me? My AutoIt Stuff | My Github Link to comment Share on other sites More sharing options...
ReFran Posted September 22, 2007 Share Posted September 22, 2007 Anybody else have the same problem as me?I don't know what the problem is, but what happens if you type: "C:\Program Files\Adobe\Acrobat 7.0\Help\ENU\Reader.pdf"into the IE address line.Reinhard Spined 1 Link to comment Share on other sites More sharing options...
therks Posted September 22, 2007 Share Posted September 22, 2007 I don't know what the problem isI keep getting File does not begin with '%PDF-'. and then an empty window. but what happens if you type: "C:\Program Files\Adobe\Acrobat 7.0\Help\ENU\Reader.pdf"into the IE address line.It displays the PDF file in the browser frame. My AutoIt Stuff | My Github Link to comment Share on other sites More sharing options...
ReFran Posted September 22, 2007 Share Posted September 22, 2007 I keep getting File does not begin with '%PDF-'. and then an empty window. It displays the PDF file in the browser frame.Which Acrobat/Reader version (exact) you work with.Can you show your code-snippet you work with.br, reinhard Spined 1 Link to comment Share on other sites More sharing options...
ReFran Posted September 22, 2007 Share Posted September 22, 2007 (edited) Does this IE based solution work for you? #include <GUIConstants.au3> $Form1 = GUICreate("Browse PDF", 400,300,400,300) $Obj = ObjCreate("Shell.Explorer.2") $browser = GUICtrlCreateObj($Obj, 0, 0, 400, 300) GUISetState(@SW_SHOW) $Obj.Navigate('C:\Program Files\Adobe\Acrobat 7.0\Help\ENU\Reader.pdf') ;; $Obj.Navigate('C:\Programme\Adobe\Acrobat 7.0\Help\ENU\Reader.pdf') While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case Else ;;;;;;; EndSelect WEnd Exit Edited September 22, 2007 by ReFran Spined 1 Link to comment Share on other sites More sharing options...
therks Posted September 26, 2007 Share Posted September 26, 2007 Yup that works fine. Unfortunately doesn't help with what I needed, cus I was trying to avoid using IE, but thank you. My reader version is 7.0.0.0. My AutoIt Stuff | My Github Link to comment Share on other sites More sharing options...
ReFran Posted September 26, 2007 Share Posted September 26, 2007 Yup that works fine. Unfortunately doesn't help with what I needed, cus I was trying to avoid using IE, but thank you.My reader version is 7.0.0.0.You should update (see under help) at least to 7.0.9.However, with an embeded object like Reader and some other -direct with dll or indirect with IE - you get a repain problem. There has been a discussion here about this, but no solution.So I start it direct and move it to the position and size I want and influence the Reader direct.HTH, Reinhard Spined 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now