Page 1 of 1
[Solved] PDF
Posted: Tue Jul 16, 2024 1:57 pm
by k3pto
I would like to show the first page of a few PDF files on screen at one time. So, I have two questions:
1) How can I display a pdf?
2) What type of window should I use: Screen, Canvas, Window? Or is there another?
The solution I chose was to download a program from the Windows store which converts a PDF to jpegs.
Re: PDF
Posted: Tue Jul 16, 2024 3:51 pm
by loulou2522
For your first question
RunProgram("c:\users\xxx\xxx.pdf" )
RunProgram("c:\users\xxx\yyy.pdf" )
that's open one session of pdf acrobat and you will see the first page of each pdf
For your second question
you must have to use comateplus to control acrobat reader
Code: Select all
;/////////////////////////////////////////////////////////////////////////////////
;***COMate*** COM automation through iDispatch.
;*===========
;*
;*Acrobat PDF demo - by Stefan Schnell.
;/////////////////////////////////////////////////////////////////////////////////
IncludePath "..\"
XIncludeFile "COMatePLUS.pbi"
Define.COMateObject PDFObject
If OpenWindow(0, 0, 0, 800, 800, "COMate PDF-Demo", #PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_MaximizeGadget|#PB_Window_MinimizeGadget)
pdfObject = Comate_CreateObject("AcroPDF.PDF.1", WindowID(0))
If pdfObject
pdfObject\SetProperty("src = 'C:\Users\xxx\Dxx\xx.PDF'")
pdfObject\Invoke("setShowToolbar(#True)")
pdfObject\Invoke("setView('Fitv')")
pdfObject\Invoke("setPageMode('none')")
pdfObject\Invoke("setLayoutMode('SinglePage')")
Debug pdfObject\Invoke("DESCRIPTION")
While WaitWindowEvent() <> #PB_Event_CloseWindow : Wend
CloseWindow(0)
pdfObject\Release()
Else
MessageRequester("COMate -Acrobat PDF demo", "Couldn't create the ActiveX object!")
EndIf
EndIf
Re: PDF
Posted: Wed Jul 17, 2024 10:52 am
by Axolotl
I use the external program SumatraPDF (windows only) to do this.
With a newer version you can control the behavior by DDE commands.
Code: Select all
; example call of the SendDDE command
SendDDE("[CmdCloseCurrentDocument]")
If someone is interested, I can extract some working code from my project.
The basic command would be like this (not complete code)
Code: Select all
; --- usually part of my Module ---
#SumatraPDF_Homepage$ = "https://www.sumatrapdfreader.org/free-pdf-reader"
#SumatraPDF_Classname$ = "SUMATRA_PDF_FRAME" ; used in FindWindow()
; set to the latest SumatraPDF.exe on your system
;
; Global m_Executable$ = "SumatraPDF-3.4.6-64.exe"
; window handle of the running SumatraPDF (don't use the New Window parameter!!
;
Global m_hwndViewer = 0 ; member of the module, init with ZERO
; coordinates and size of sumatra window
;
Global m_X = 32, m_Y = 32, m_W = 800, m_H = 1200
; --- internal procedures
Procedure SendDDE(Command$) ; send DDE command(s) to sumatra
Protected result, cds.COPYDATASTRUCT
If m_hwndViewer = 0 ; look for a running instance
m_hwndViewer = FindWindow_(#SumatraPDF_Classname$, 0)
EndIf
If m_hwndViewer ; send message to the running instance
cds\dwData = $44646557 ; <------------------------- constant (see Sumatra help file)
cds\cbData = StringByteLength(Command$) + 2 ; <---- unicode world (important + 2)
cds\lpData = @Command$ ; <------------------------ pointer to string
; If the receiving application processes this message, it should return TRUE; otherwise, it should return FALSE.
result = SendMessage_(m_hwndViewer, #WM_COPYDATA, 0, @cds)
Debug "SendDDE(" + Command$ + ") .. " + StringField("Failed.Ok.", 1+Bool(result), ".")
ProcedureReturn result
Else ; m_hwndViewer not valid (found, running, etc.)
Debug "SendDDE(" + Command$ + ") .. not executed, because cannot find Viewer --> " + m_hwndViewer
EndIf
ProcedureReturn #False
EndProcedure
Re: PDF
Posted: Fri Aug 09, 2024 6:54 pm
by Kwai chang caine
Yes really interesting

(In fact all the tip's for remote others programs is interesting for me

)
I have try and that works !!!
Incredible to see this old DDE protocol is always used !!!
Thanks a lot Axolotl for this tip's
