FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour Ver PDF dentro de la aplicaci贸n
Posts: 694
Joined: Fri Oct 07, 2005 06:58 AM
Ver PDF dentro de la aplicaci贸n
Posted: Tue Jun 07, 2016 04:24 PM

Hola,

Hasta ahora los pdf's los muestro dentro de la aplicaci贸n con el ActiveX de Acrobat Reader.
Pero cada vez que hay una actualizaci贸n del Acrobat Reader, suele generar problemas y ya no se ven los PDF.
Tengo que andar cambiando condiciones en Acrobat Reader para que se puedan ver y en cada versi贸n son distintas.

Me gustar铆a poder dejar de usar Acrobat, para dejar de tener problemas.
驴Alguno usa alg煤n visor de PDF dentro de las aplicaciones?, 驴C煤al?

Muchas gracias

Un saludo

Fernando Gonz谩lez Diez

ALSIS Sistemas Inform谩ticos
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Ver PDF dentro de la aplicaci贸n
Posted: Tue Jun 07, 2016 05:52 PM

Fernando,

Yo suelo usar Chrome como visor de PDFs.

Imagino que modificando samples\webexp.prg podrias usarlo de visor de PDFs.

No lo he probado pero deber铆a funcionar :-)

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: Ver PDF dentro de la aplicaci贸n
Posted: Tue Jun 07, 2016 05:59 PM
http://www.4shared.com/rar/8b-A7H06ba/SUMATRA.html

http://www.sumatrapdfreader.org/manual-pt.html


Code (fw): Select all Collapse
   LOCAL ImprimePDF := "C:\PDF\Nombre.PDF"

   //WinExec(oApp:cDir_001+"sumatra\sumatrapdf.exe -reuse-instance -lang pt "+ImprimePDF)   //-restrict -fullscreen
   WinExec( "C:\sumatra\sumatrapdf.exe -reuse-instance -lang en "+ImprimePDF)   //-restrict -fullscreen
Jo茫o Santos - S茫o Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: Ver PDF dentro de la aplicaci贸n
Posted: Tue Jun 07, 2016 06:09 PM
Jo茫o Santos - S茫o Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Ver PDF dentro de la aplicaci贸n
Posted: Tue Jun 07, 2016 07:46 PM
No ca铆 en la cuenta de que samples\webexp.prg usa Internet Explorer y no Chrome.

Buscando en google he encontrado esto que parece que puede servir:
Code (fw): Select all Collapse
set WshShell=WScript.CreateObject("WScript.Shell")
   strAnswer = InputBox("Please enter a name for your new file:")
   WshShell.run "chrome.exe"
   WScript.sleep 100
   WshShell.sendkeys "www.google.com" 
   WshShell.sendkeys "{ENTER}"
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 694
Joined: Fri Oct 07, 2005 06:58 AM
Re: Ver PDF dentro de la aplicaci贸n
Posted: Wed Jun 08, 2016 07:42 AM

Muchas gracias Karinha, pero la intenci贸n que tengo es que se vea dentro de la aplicaci贸n, como una ventana mas de la misma.

Muchas gracias Antonio, voy a probar lo del chrome.

Un saludo

Fernando Gonz谩lez Diez

ALSIS Sistemas Inform谩ticos
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Ver PDF dentro de la aplicaci贸n
Posted: Wed Jun 08, 2016 08:09 AM
Fernando,

Lo que no se es como podemos "incrustarlo" en la aplicaci贸n

Aqui tienes otro ejemplo parecido al anterior:
http://stackoverflow.com/questions/13401749/opening-browser-on-a-variable-page-using-vbscript
I found the easiest way is to do this:

set WshShell=WScript.CreateObject("WScript.Shell")
WshShell.run "chrome.exe"
WScript.sleep 400
WshShell.sendkeys "URL HERE"
WshShell.sendkeys "{ENTER}"
also just a fyi you can do this to close chrome:

WshShell.sendkeys "%{F4}"
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Ver PDF dentro de la aplicaci贸n
Posted: Wed Jun 08, 2016 08:15 AM
Aqui tenemos un ejemplo de como usar wscript.shell desde Harbour:

viewtopic.php?p=50307

Code (fw): Select all Collapse
oRemoteShell:=CreateObject("WScript.Shell")
oRemoteShell:Run("ShutDown -s -m \\NombrePC",0,.F.)
oRemoteShell:=nil
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 694
Joined: Fri Oct 07, 2005 06:58 AM
Re: Ver PDF dentro de la aplicaci贸n
Posted: Thu Jun 09, 2016 03:13 PM

Hola Antonio,

Ya usaba createobject("WScrip.Shell")

Pero con chrome lo lanza en una ventana independiente, e intentar capturar esa ventana e incrustarla dentro de mi aplicaci贸n, no creo que vaya a tener un resultado muy correcto.

Ya prob茅 con Excel a capturar e incrustar y tuve que desistir porque perd铆an la posibilidad de abrir otra vez excel de forma independiente. Y para que excel tratar谩 cada apertura de forma independiente, hab铆a que cambiar el registro de windows. En definitiva un l铆o para el objetivo que persegu铆a.

Leyendo en internet, para conseguir que chrome se comporte igual que internet explorer y su activex, hay que variar tambi茅n varias cosas en el registro.

Voy a seguir buscando otras posibilidades, antes de cambiar en el registro de windows como act煤a una aplicaci贸n externa. No vaya a ser en que la pr贸xima actualizaci贸n ya no sirva esa variaci贸n en el registro y no sirva para nada lo que hice.

Un saludo

Fernando Gonz谩lez Diez

ALSIS Sistemas Inform谩ticos
Posts: 1515
Joined: Thu Oct 30, 2008 02:37 PM
Re: Ver PDF dentro de la aplicaci贸n
Posted: Thu Jun 09, 2016 03:24 PM

Hola Fernando,

Todos hemos lidiado con hacking, pero este caso de la incrustacion pdf es summum.

Bueno... he entrado a darte otra alternativa. 驴 Qu茅 tal transformar los .pdf en .jpg y mostrarlos con un control image ?

Saludos

Posts: 694
Joined: Fri Oct 07, 2005 06:58 AM
Re: Ver PDF dentro de la aplicaci贸n
Posted: Thu Jun 09, 2016 05:23 PM

Muchas gracias,

Es una posibilidad a valorar. No es lo tenia pensado, pero puede servir.

Lo pruebo a ver como se ve

Un saludo

Fernando Gonz谩lez Diez

ALSIS Sistemas Inform谩ticos
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Ver PDF dentro de la aplicaci贸n
Posted: Thu Jun 09, 2016 06:42 PM
Fernando, quiz谩s te pueda servir esta solucion: usar un objeto TRichEdit

Veo que tienes la version 16.04
En la carpeta samples tienes un ejemplo TestRtf5.prg
En la function New
Al crear el control quitale la carga del fichero de ejemplo

Code (fw): Select all Collapse
聽 聽@ 聽200, 0 RICHEDIT5 oRTF VAR cRTF OF oWnd //FILE "TestRTF.RTF"


y en la activacion de la MdiChild

Code (fw): Select all Collapse
ACTIVATE WINDOW oWnd MAXIMIZED ON INIT oRTF:InsertObject("d:\fwh\fwhteam\samples\testrtf.pdf")


Creo que como ejemplo de inicio para ello te puede servir ( usa siempre el path entero para el fichero a cargar: Word, excel, pdf )



Code (fw): Select all Collapse
ACTIVATE WINDOW oWnd MAXIMIZED ON INIT oRTF:InsertObject("d:\fwh\fwhteam\samples\testrtf.xlsx")


Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noci贸n del tiempo

El secreto de la felicidad no est谩 en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 694
Joined: Fri Oct 07, 2005 06:58 AM
Re: Ver PDF dentro de la aplicaci贸n
Posted: Fri Jun 10, 2016 08:50 AM

Muy interesante Cristobal,

Lo pruebo ahora mismo

Un saludo

Fernando Gonz谩lez Diez

ALSIS Sistemas Inform谩ticos
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Ver PDF dentro de la aplicaci贸n
Posted: Fri Jun 10, 2016 09:26 AM
Fernando


#command @ <nTop>, <nLeft> RICHEDIT5 [ <oRTF> VAR ] <uVar> ;
[ <dlg: OF, WINDOW, DIALOG> <oWnd> ] ;
[ SIZE <nWidth>, <nHeight> ] ;
[ FONT <oFont> ] ;
[ <pixel: PIXEL> ] ;
[ MESSAGE <cMsg> ] ;
[ <lHScroll: HSCROLL> ] ;
[ <readonly: READONLY, NO MODIFY> ] ;
[ WHEN <uWhen> ] ;
[ VALID <uValid> ] ;
[ ON CHANGE <uChange> ] ;
[ <lDesign: DESIGN> ] ;
[ <lHighlight: HIGHLIGHT> ] ;
[ <file: FILE, FILENAME> <cFileName> ] ;
[ RTFSIZE <nRTFSize> ] ;
[ <lNoURL: NO URL> ] ;
[ <lNoScroll: NO SCROLL> ] ;
[ <lNoBorder: NOBORDER, NO BORDER> ] ;
[ MARGINLEFT <nLeftMargin> ]


Como curiosidad, tambi茅n permite insertar "presentaciones" PowerPoint
Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noci贸n del tiempo

El secreto de la felicidad no est谩 en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Ver PDF dentro de la aplicaci贸n
Posted: Fri Jun 10, 2016 07:59 PM
He desarrollado un peque帽o programa como ejemplo del uso del control TRichEdit5, para visualizar el contenido de los ficheros
( En los ficheros DBF hay que hacer Double-Click para verlos con XBrowse )

El .EXE constru铆do

https://bitbucket.org/fivetech/fivewin- ... explor.exe

Y aqu铆 est谩 el codigo:

Code (fw): Select all Collapse
// FWExplorer
// Cnl - 10/06/2016

#include "fivewin.ch"
#include "RichEdi5.ch"

//----------------------------------------------------------------------------//

REQUEST HB_CODEPAGE_ESWIN

Static oRTF
Static cRTF
Static nFilter
Static cDirName
Static aFilesTxt
Static aFilesImg
Static aFilesObj
Static aFilesAll

//----------------------------------------------------------------------------//

function Main()

聽 聽local aImages
聽 聽local oWnd
聽 聽local oFont
聽 聽local oBrush
聽 聽local oBrw
聽 聽local nWBrw 聽 := 300

聽 聽aFilesTxt := { "RTF", "TXT", "PRG", "C", "CPP", "H", "CH", "RC", "INI", "BAT", "MAK", "XML", "LOG" }
聽 聽aFilesImg := { "BMP", "PNG", "JPG", "ICO", "DIB", "PCX", "GIF", "WMF" }
聽 聽aFilesObj := { "DOC", "XLS", "PPT", "PDF", "DOCX", "XLSX" }
聽 聽aFilesAll := { "DBF" }

聽 聽FW_SetUnicode( .t. )
聽 聽HB_CDPSELECT( "ESWIN" )
聽 聽HB_SETCODEPAGE( "UTF8" ) // Harbour (not xHarbour) to display unicode filenames
聽 聽
聽 聽nFilter 聽:= 0
聽 聽cDirName := hb_CurDrive() + ":\" + CurDir()
聽 聽aImages 聽:= ReadFolder()

聽 聽DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14
聽 聽//DEFINE BRUSH oBrush FILE "..\bitmaps\backgrnd\stone.bmp"
聽 聽
聽 聽DEFINE WINDOW oWnd TITLE " FWExplorer: Visor de Documentos - [ TRichEdit Control ]"
聽 聽oWnd:SetFont( oFont )
聽 聽
聽 聽SET MESSAGE OF oWnd TO "" 2015
聽 聽DEFINE BUTTONBAR oWnd:oBar SIZE 70, 32 2015

聽 聽DEFINE BUTTON OF oWnd:oBar PROMPT "Exit" 聽 CENTER ACTION ( oWnd:End() ) 聽 
聽 聽DEFINE BUTTON OF oWnd:oBar PROMPT "Rtf" 聽 聽CENTER ACTION ( nFilter := 1, ;
聽 聽 聽 聽 聽 oBrw:aArrayData := ReadFolder(), oBrw:Refresh( .t. ), VerDoc( oBrw ) )
聽 聽DEFINE BUTTON OF oWnd:oBar PROMPT "Text" 聽 CENTER ACTION ( nFilter := 11, ;
聽 聽 聽 聽 聽 oBrw:aArrayData := ReadFolder(), oBrw:Refresh( .t. ), VerDoc( oBrw ) )
聽 聽DEFINE BUTTON OF oWnd:oBar PROMPT "Images" CENTER ACTION ( nFilter := 2 , ;
聽 聽 聽 聽 聽 oBrw:aArrayData := ReadFolder(), oBrw:Refresh( .t. ), VerDoc( oBrw ) )
聽 聽DEFINE BUTTON OF oWnd:oBar PROMPT "Object" CENTER ACTION ( nFilter := 3 , ;
聽 聽 聽 聽 聽 oBrw:aArrayData := ReadFolder(), oBrw:Refresh( .t. ), VerDoc( oBrw ) )
聽 聽DEFINE BUTTON OF oWnd:oBar PROMPT "Dbf" 聽 聽CENTER ACTION ( nFilter := 4 , ;
聽 聽 聽 聽 聽 oBrw:aArrayData := ReadFolder(), oBrw:Refresh( .t. ), VerDoc( oBrw ) )
聽 聽DEFINE BUTTON OF oWnd:oBar PROMPT "All" 聽 聽CENTER ACTION ( nFilter := 0 , ;
聽 聽 聽 聽 聽 oBrw:aArrayData := ReadFolder(), oBrw:Refresh( .t. ), VerDoc( oBrw ) )
聽 聽DEFINE BUTTON OF oWnd:oBar PROMPT "Folder" CENTER ;
聽 聽 聽 ACTION ( cDirName := cGetDir( "Select Folder", GetCurDir() + "\" ), ;
聽 聽 聽 聽 聽 聽 聽 聽SetCurDir( cDirName ), ;
聽 聽 聽 聽 聽 聽 聽 聽oBrw:aArrayData := ReadFolder(), oBrw:Refresh( .t. ), VerDoc( oBrw ) )

聽 聽@ oWnd:nHeight,0 XBROWSE oBrw SIZE nWBrw,-oWnd:nHeight ;
聽 聽 聽 PIXEL OF oWnd DATASOURCE aImages COLUMNS 1 CELL LINES NOBORDER

聽 聽WITH OBJECT oBrw
聽 聽 聽 :aCols[ 1 ]:cHeader := "Files"
聽 聽 聽 :nStretchCol 聽 := 1
聽 聽 聽 :bChange 聽 聽 聽 := { | o | VerDoc( o ) }
聽 聽 聽 :bLDblClick 聽 聽:= { | o | LookOthers( oBrw ) }
聽 聽 聽 :bClrStd 聽 聽 聽 := { || { If( oBrw:aRow[ 3 ] == 1, CLR_BLUE, CLR_HRED ), CLR_WHITE } }聽
      :bKeyDown      := { |n,f| if( n = VK_RETURN, Eval( oBrw:bLDblClick ), ) }
聽 聽 聽 :CreateFromCode()
聽 聽END

聽 聽WITH OBJECT oWnd
聽 聽 聽 :nWidth 聽 聽 := ScreenWidth() 聽* 0.6
聽 聽 聽 :nHeight 聽 聽:= ScreenHeight() * 0.6
聽 聽END

聽 聽@ oWnd:nHeight, nWBrw RICHEDIT5 oRTF VAR cRTF OF oWnd ;
聽 聽 聽SIZE oWnd:nWidth - (nWBrw+18), oBrw:nHeight*1.82 PIXEL NOBORDER HSCROLL

聽 聽ACTIVATE WINDOW oWnd CENTERED ON INIT VerDoc( oBrw ) ;
聽 聽ON PAINT ( oRTF:SetSize( oWnd:nWidth - (nWBrw+18), oBrw:nHeight-2 ) ) //ON INIT oWnd:SetControl( oRTF )
聽 聽
聽 聽RELEASE FONT oFont
聽 聽//RELEASE BRUSH oBrush

return nil

//----------------------------------------------------------------------------//

Function VerDoc( oBrw )

聽 聽local nOpc 聽 聽 聽:= 0
聽 聽local lText 聽 聽 := .F.
聽 聽
聽 聽if !Empty( Ascan( aFilesTxt, Upper( cFileExt( oBrw:aRow[ 2 ] ) ) ) )
聽 聽 聽 nOpc 聽:= 1
聽 聽endif
聽 聽if Empty( nOpc )
聽 聽 聽 if !Empty( Ascan( aFilesImg, Upper( cFileExt( oBrw:aRow[ 2 ] ) ) ) )
聽 聽 聽 聽 聽nOpc 聽:= 2
聽 聽 聽 endif
聽 聽endif
聽 聽if Empty( nOpc )
聽 聽 聽 if !Empty( Ascan( aFilesObj, Upper( cFileExt( oBrw:aRow[ 2 ] ) ) ) )
聽 聽 聽 聽 聽nOpc 聽:= 3
聽 聽 聽 endif
聽 聽endif
聽 聽
聽 聽oRTF:SetClear()
聽 聽oRTF:SelectAll()
聽 聽oRTF:Del()

聽 聽Do Case
聽 聽 聽 Case nOpc = 1

聽 聽 聽 聽 聽if Upper( cFileExt( oBrw:aRow[ 2 ] ) ) <> "RTF"
聽 聽 聽 聽 聽 聽 lText 聽:= .T.
聽 聽 聽 聽 聽 聽 oRTF:SetText( MemoRead( AllTrim( oBrw:aRow[ 2 ] ) ) )
聽 聽 聽 聽 聽else
聽 聽 聽 聽 聽 聽 oRTF:LoadFromRTFFile( AllTrim( oBrw:aRow[ 2 ] ) ) 聽 聽 聽 聽 
聽 聽 聽 聽 聽endif
聽 聽 聽 
聽 聽 聽 Case nOpc = 2
聽 聽 聽 
聽 聽 聽 聽 聽oRTF:InsertPictureFile( AllTrim( oBrw:aRow[ 2 ] ) )

聽 聽 聽 Case nOpc = 3
聽 聽 聽 聽 聽
聽 聽 聽 聽 聽oRTF:InsertObject( AllTrim( oBrw:aRow[ 2 ] ) + Chr(0) ) 聽 聽 聽
聽 聽 聽 聽 聽
聽 聽 聽 Otherwise
聽 聽 聽 
聽 聽 聽 聽 聽oRTF:LoadRTF( AllTrim( oBrw:aRow[ 2 ] ) ) 聽 聽 聽

聽 聽EndCase

Return nil

//----------------------------------------------------------------------------//

Static Function LookOthers( oBrw )

聽 聽local nOpc 聽 聽 聽:= 0
聽 聽
聽 聽if !Empty( Ascan( aFilesTxt, Upper( cFileExt( oBrw:aRow[ 2 ] ) ) ) )
聽 聽 聽 nOpc 聽:= 1
聽 聽endif
聽 聽if Empty( nOpc )
聽 聽 聽 if !Empty( Ascan( aFilesImg, Upper( cFileExt( oBrw:aRow[ 2 ] ) ) ) )
聽 聽 聽 聽 聽nOpc 聽:= 2
聽 聽 聽 endif
聽 聽endif
聽 聽if Empty( nOpc )
聽 聽 聽 if !Empty( Ascan( aFilesObj, Upper( cFileExt( oBrw:aRow[ 2 ] ) ) ) )
聽 聽 聽 聽 聽nOpc 聽:= 3
聽 聽 聽 endif
聽 聽endif
聽 聽if Empty( nOpc )
聽 聽 聽 if Upper( cFileExt( oBrw:aRow[ 2 ] ) ) = "DBF"
聽 聽 聽 聽 聽XBrowse( oBrw:aRow[ 2 ] )
聽 聽 聽 else
聽 聽 聽 聽 聽MsgInfo( "Format not supported", oBrw:aRow[ 2 ] )
聽 聽 聽 endif
聽 聽endif

Return nil

//----------------------------------------------------------------------------//

static function ReadFolder()

聽 聽local aImages 聽:= {}
聽 聽local aSub 聽 聽 := { "*" }
聽 聽local c
聽 聽local x
聽 聽local cPath 聽 聽:= cDirName
聽 聽local aDir
聽 聽local aAlls 聽 聽:= {}

聽 聽AEVal( aFilesTxt, { | a | AAdd( aAlls, a ) } )
聽 聽AEVal( aFilesImg, { | a | AAdd( aAlls, a ) } )
聽 聽AEVal( aFilesObj, { | a | AAdd( aAlls, a ) } )
聽 聽AEVal( aFilesAll, { | a | AAdd( aAlls, a ) } )

聽 聽Do Case
聽 聽 聽 Case nFilter = 0
聽 聽 聽 聽 聽 聽aSub 聽 聽:= { "*" }
聽 聽 聽 Case nFilter = 1
聽 聽 聽 聽 聽 聽aSub 聽 聽:= { "rtf" } 
聽 聽 聽 Case nFilter = 11
聽 聽 聽 聽 聽 聽aSub 聽 聽:= aClone( aFilesTxt )
聽 聽 聽 聽 聽 聽aSub 聽 聽:= ADel( aSub, 1 )
聽 聽 聽 聽 聽 聽ASize( aSub, Len( aSub ) - 1 )
聽 聽 聽 Case nFilter = 2
聽 聽 聽 聽 聽 聽aSub 聽 聽:= aClone( aFilesImg )
聽 聽 聽 Case nFilter = 3
聽 聽 聽 聽 聽 聽aSub 聽 聽:= aClone( aFilesObj )
聽 聽 聽 Case nFilter = 4
聽 聽 聽 聽 聽 聽aSub 聽 聽:= { "dbf" } 
聽 聽EndCase
聽 聽
聽 聽for each c in aSub
聽 聽 聽 aDir 聽 聽 := Directory( cPath + "\*." + c )
聽 聽 聽 AEval( aDir, { | a | AAdd( aImages, { Lower( a[ 1 ] ), ;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽Lower( TrueName( cPath + "\" + a[ 1 ] ) ), 0 } ) } )
聽 聽next
聽 聽For x = 1 to Len( aImages )
聽 聽 聽 if !Empty( Ascan( aAlls, Upper( cFileExt( aImages[ x ][ 2 ] ) ) ) )
聽 聽 聽 聽 聽aImages[ x ][ 3 ] := 1
聽 聽 聽 endif
聽 聽Next x
聽 聽
聽 聽ASort( aImages,,,{ | x, y | Lower( x[ 1 ] ) < Lower( y[ 1 ] ) } )

return aImages

//----------------------------------------------------------------------------//












Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noci贸n del tiempo

El secreto de la felicidad no est谩 en hacer lo que te gusta, sino en que te guste lo que haces