PDF Viewer DLL?

Moderator: Rathinagiri

User avatar
Roberto Lopez
HMG Founder
Posts: 3858
Joined: Wed Jul 30, 2008 6:43 pm
Has thanked: 6 times
Been thanked: 98 times

Re: PDF Viewer DLL?

Post by Roberto Lopez » Mon Feb 13, 2017 10:29 pm

KDJ wrote:
Mon Feb 13, 2017 10:24 pm
SumatraPDF uses MuPDF library to rendering.
I found something on this subject:
https://www.codeproject.com/Articles/49 ... -Invoke-in
https://www.codeproject.com/Articles/57 ... er-Control
Thanks. I'll take a look at it.
Regards/Saludos,

Roberto


(Veritas Filia Temporis)

User avatar
PeteWG
Posts: 89
Joined: Sun Mar 21, 2010 5:45 pm
Has thanked: 2 times
Been thanked: 14 times

Re: PDF Viewer DLL?

Post by PeteWG » Tue Feb 14, 2017 12:51 pm

Roberto Lopez wrote:
Mon Feb 13, 2017 10:28 pm
The only possible issue is that the user could click outside Sumatra window, being overlapped by HMG app, but, This could be solved using: EXECUTE FILE ... WAIT
Hi Roberto

you can use -plugin switch which give the ability to make SumatraPDF a child window of a given window, f.e. a window of your application.
In this way you have absolute control!

please see here
https://github.com/sumatrapdfreader/sum ... -arguments
(scroll down to "Developer options")

I have done it for one of my minigui applications and works ok.

I'm pretty sure you will easily realize how to make it, ;-)
however, If you need any details, about the way I have implemented it, I 'd be happy to provide them.


P.S. yes, SumatraPDF it's a very good piece of opensource software!

best regards,

---
Pete


User avatar
Pablo César
Posts: 3642
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil
Has thanked: 62 times
Been thanked: 92 times

PDF Viewer DLL?

Post by Pablo César » Tue Feb 14, 2017 1:47 pm

Yeah nice news !
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein

User avatar
Roberto Lopez
HMG Founder
Posts: 3858
Joined: Wed Jul 30, 2008 6:43 pm
Has thanked: 6 times
Been thanked: 98 times

Re: PDF Viewer DLL?

Post by Roberto Lopez » Wed Feb 15, 2017 12:59 am

PeteWG wrote:
Tue Feb 14, 2017 12:51 pm
Hi Roberto

you can use -plugin switch which give the ability to make SumatraPDF a child window of a given window, f.e. a window of your application.
In this way you have absolute control!
<...>
Thanks!

This morning I've was reading the document you point (Sumatra at GitHub) and (for some reason) I've missed '-plugin' option :)

As you said, this way, we are in full control of the users experience, without caring about PDF support available on their systems.

Thanks again!
Regards/Saludos,

Roberto


(Veritas Filia Temporis)

User avatar
Roberto Lopez
HMG Founder
Posts: 3858
Joined: Wed Jul 30, 2008 6:43 pm
Has thanked: 6 times
Been thanked: 98 times

Re: PDF Viewer DLL?

Post by Roberto Lopez » Wed Feb 15, 2017 1:24 am

And... a step further...

Since I like that ny apps be self-contained (a single exe file) I'm thinking on embed Sumatra portable on my source code and create it (if it does not exists) in the destination machine (a crazy idea... I know :) ).

I guess that I should create an utility that reads the binary file (Sumatra exe) and creates the source code of a Harbour array, containing an element for each byte in the binary (maybe using HEX).

Since I'm trying to not reinvent the wheel (if not strictly needed) my question is: Does such utility exists?

TIA.
Regards/Saludos,

Roberto


(Veritas Filia Temporis)

User avatar
srvet_claudio
Posts: 1832
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Has thanked: 24 times
Been thanked: 53 times
Contact:

Re: PDF Viewer DLL?

Post by srvet_claudio » Wed Feb 15, 2017 3:08 am

Roberto Lopez wrote:
Wed Feb 15, 2017 1:24 am
And... a step further...

Since I like that ny apps be self-contained (a single exe file) I'm thinking on embed Sumatra portable on my source code and create it (if it does not exists) in the destination machine (a crazy idea... I know :) ).

I guess that I should create an utility that reads the binary file (Sumatra exe) and creates the source code of a Harbour array, containing an element for each byte in the binary (maybe using HEX).

Since I'm trying to not reinvent the wheel (if not strictly needed) my question is: Does such utility exists?

TIA.
Roberto,

1) embed your file as raw resource ( resource type ID are defined in i_controlmisc.ch ):
MyRawRes RT_RCDATA MyfileX.exe

2) load resource:
cData := HMG_LoadResourceRawFile ( "MyRawRes", RT_RCDATA )

3) save the resource:
hFile := FCreate("MyFile.exe")
Fwrite( hFile, cData )
FClose( hFile )
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com

User avatar
andyglezl
Posts: 786
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Has thanked: 7 times
Been thanked: 11 times
Contact:

Re: PDF Viewer DLL?

Post by andyglezl » Wed Feb 15, 2017 3:21 am

by Roberto Lopez » Tue Feb 14, 2017 6:24 pm
Since I like that ny apps be self-contained (a single exe file) I'm thinking on embed Sumatra portable on my source code and create it (if it does not exists) in the destination machine (a crazy idea... I know :) ).
Hola a todos
Yo ya tenía un tiempo que no participaba...

Roberto
Esa "loca idea" yo también la tuve hace algún tiempo y después de probar y probar y probar,
logre hacerlo de esta forma. (NOTA: solo que el archivo pesaba 529 kb)
Espero que les sirva
-------------------------------------------------------------------------------------------------------------------
Hello everyone
I already had a time that did not participate ...

Robert
That "crazy idea" I also had it some time ago and after trying and testing and trying,
Can do it this way. (NOTE: only the file weighed 529 kb)
I hope it works for you


MiArchivo.RC
-------------------------------------------
MIARCH TXT miarchivo.exe
-------------------------------------------

en mi programa...
-------------------------------------------
FUNCTION CreaExe( )
LOCAL xData1
xData1 := HMG_LoadResourceRawFile( "MIARCH", "TXT" )
HB_MEMOWRIT( "miarchivo.exe", xData1 )
RETURN nil
Andrés González López
Desde Guadalajara, Jalisco. México.

User avatar
mol
Posts: 2597
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Has thanked: 50 times
Been thanked: 22 times
Contact:

Re: PDF Viewer DLL?

Post by mol » Wed Feb 15, 2017 6:21 am

Attach small working sample when it will be ready, please :-)

User avatar
PeteWG
Posts: 89
Joined: Sun Mar 21, 2010 5:45 pm
Has thanked: 2 times
Been thanked: 14 times

Re: PDF Viewer DLL?

Post by PeteWG » Wed Feb 15, 2017 10:37 am

Roberto Lopez wrote:
Wed Feb 15, 2017 1:24 am
Since I'm trying to not reinvent the wheel (if not strictly needed) my question is: Does such utility exists?
TIA.
No need to reinvent "this wheel"!
I would never stop to say that "harbour has it all" (or almost all, anyway) :-)
Personally, I do use a #pragma trick to attach binaries (or anything) to the final executable.

f.e. in one application that makes use of "curl.exe" I did:

Code: Select all

#include "fileio.ch"
-------------------------------------------------------------------------------------------------
   IF ! hb_vfExists( "curl.exe" )
      hb_MemoWrit( "curl.exe", CurlExe() )
      // give OS a little time to "see"  the newly created file
      hb_IdleSleep( 0.5 ) 
      // hide the file from user's sight to protect it from "accidents"
      hb_vfAttrSet( "curl.exe",  HB_FA_HIDDEN + HB_FA_READONLY + HB_FA_SYSTEM )
   ENDIF


STATIC FUNCTION CurlExe()
#pragma __binarystreaminclude "CURL.EXE" | RETURN %s
--------------------------------------------------------------------------------------------------
NOTE: the binary that is going to be attached, must be available and visible during compile/link time, so I put it into project's /source folder.

NOTE 2: it's obvious that the attached file is piling up onto the final executable, and in the case of sumatraPDF (latest portable version is about ~6.5MiB), this attaching-technic will significantly affect the size of the executable with all the contingent consequences that such a growth may have during runtime.

best regards,

---
Pete

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest