PDF Viewer DLL?
Moderator: Rathinagiri
- Roberto Lopez
- HMG Founder
- Posts: 4004
- Joined: Wed Jul 30, 2008 6:43 pm
Re: PDF Viewer DLL?
Claudio, Andrés, Pete,
Many thanks to all for your propossed solutions.
Apparently, my idea was not so crazy after all
Pete:
Regarding the size, Sumatra can be reduced by about 50% with UPX (using --best parameter).
And I have to test yet the '--ultra-brute' switch, that could reduce it even more.
Thanks again to all.
Many thanks to all for your propossed solutions.
Apparently, my idea was not so crazy after all
Pete:
Regarding the size, Sumatra can be reduced by about 50% with UPX (using --best parameter).
And I have to test yet the '--ultra-brute' switch, that could reduce it even more.
Thanks again to all.
Regards/Saludos,
Roberto
(Veritas Filia Temporis)
Roberto
(Veritas Filia Temporis)
- Roberto Lopez
- HMG Founder
- Posts: 4004
- Joined: Wed Jul 30, 2008 6:43 pm
Re: PDF Viewer DLL?
Using '--ultra-brute' switch Sumatra reduces to 2.5 MB (not such a big problem).Roberto Lopez wrote: ↑Wed Feb 15, 2017 1:05 pm Pete:
Regarding the size, Sumatra can be reduced by about 50% with UPX (using --best parameter).
And I have to test yet the '--ultra-brute' switch, that could reduce it even more.
Regards/Saludos,
Roberto
(Veritas Filia Temporis)
Roberto
(Veritas Filia Temporis)
- Roberto Lopez
- HMG Founder
- Posts: 4004
- Joined: Wed Jul 30, 2008 6:43 pm
Re: PDF Viewer DLL?
Well... this is my first try...
'-lang es' sets the Sumatra UI to Spanish, so, You could change as required.
Code: Select all
*----------------------------------------------------------------------*
PROCEDURE VIEW_PDF(cFile)
*----------------------------------------------------------------------*
LOCAL cHwnd
IF .NOT. FILE('SumatraPDF.exe')
MSGSTOP('PDF Viewer Not Found!')
RETURN
ELSE
DEFINE WINDOW PdfView ;
AT 0,0 ;
WIDTH 900 ;
HEIGHT 700 ;
TITLE cFile ;
MODAL
END WINDOW
Center Window PdfView
cHwnd := ALLTRIM( STR( GETFORMHANDLE( 'PdfView' ) ) )
EXECUTE FILE 'SumatraPDF.exe' PARAMETERS ' -lang es -plugin ' + cHwnd + ' ' + cFile
Activate Window PdfView
ENDIF
RETURN
Regards/Saludos,
Roberto
(Veritas Filia Temporis)
Roberto
(Veritas Filia Temporis)
- Roberto Lopez
- HMG Founder
- Posts: 4004
- Joined: Wed Jul 30, 2008 6:43 pm
Re: PDF Viewer DLL?
This is the final code.
I'm using the Pete suggested method to embbed Sumatra, since I prefer to have as much as I can in source (prg) code, instead resources.
As I've said, from some time ago, I'm creating all my reports straight to PDF and from now, for the preview at generating and revieweing stored versions, I'll use Sumatra this way.
Times are changing and PDF is becoming more important than paper... so... we must adapt
Thanks to all for the help me on this!
I'm using the Pete suggested method to embbed Sumatra, since I prefer to have as much as I can in source (prg) code, instead resources.
Code: Select all
#include "fileio.ch"
STATIC FUNCTION SumatraExe()
#pragma __binarystreaminclude "SumatraPDF.exe" | RETURN %s
*----------------------------------------------------------------------*
PROCEDURE VIEW_PDF(cFile)
*----------------------------------------------------------------------*
LOCAL cHwnd
IF ! hb_vfExists( "SumatraPDF.exe" )
hb_MemoWrit( "SumatraPDF.exe", SumatraExe() )
// 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( "SumatraPDF.exe", HB_FA_HIDDEN + HB_FA_READONLY + HB_FA_SYSTEM )
ENDIF
DEFINE WINDOW PdfView ;
AT 0,0 ;
WIDTH 900 ;
HEIGHT 700 ;
TITLE cFile ;
MODAL
END WINDOW
Center Window PdfView
cHwnd := ALLTRIM( STR( GETFORMHANDLE( 'PdfView' ) ) )
EXECUTE FILE 'SumatraPDF.exe' PARAMETERS ' -plugin ' + cHwnd + ' ' + cFile
Activate Window PdfView
RETURN
Times are changing and PDF is becoming more important than paper... so... we must adapt
Thanks to all for the help me on this!
Regards/Saludos,
Roberto
(Veritas Filia Temporis)
Roberto
(Veritas Filia Temporis)
Re: PDF Viewer DLL?
Thanks Roberto Lopez,
This is very useful for report in pdf and view solution.
Regards,
Anand
This is very useful for report in pdf and view solution.
Regards,
Anand
Re: PDF Viewer DLL?
Nice and clean implementation!
+1Times are changing and PDF is becoming more important than paper... so... we must adapt
regards,
---
Pete
- Rathinagiri
- Posts: 5471
- Joined: Tue Jul 29, 2008 6:30 pm
- DBs Used: MariaDB, SQLite, SQLCipher and MySQL
- Location: Sivakasi, India
- Contact:
Re: PDF Viewer DLL?
Actually I can not adapt to PDF because it doesn't support our Unicode.
I use HTML instead and it works nice.
We can also consider using ePub, djvu formats along with Sumatra. Are there any libraries to export to these formats from Harbour?
I use HTML instead and it works nice.
We can also consider using ePub, djvu formats along with Sumatra. Are there any libraries to export to these formats from Harbour?
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
South or North HMG is worth.
...the possibilities are endless.
Re: PDF Viewer DLL?
Hola
Hice algunas pruebas con el UPX y esto resulto...
---------------------------------------------------------------------------------------------------------------------------
El primer ejecutable, es una compilación normal y el sumatrapdf2.exe (6,339 kb) y pesa 10,251 kb.
(con mis bibliotecas predefinidas)
El segundo, es utilizando el UPX con el sumatrapdf2.exe con '--ultra-brute' switch. y pesa 7,048 kb.
El tercero, es utilizando el UPX '--ultra-brute' switch con el resultado de la compilación normal y pesa 5,084 kb
O sea, que utilizando directamente el UPX en la compilación normal, lo reduce más !.
--------------------------------------------------------------------------------------------------------------------------
The first executable, is a normal compilation and sumatrapdf2.exe (6,339 kb) and weighs 10.251 kb.
(With my predefined libraries)
The second is using UPX with sumatrapdf2.exe with '--ultra-brute' switch. And weighs 7.048 kb.
The third, is using the UPX '--ultra-brute' switch with the result of normal compilation and weighs 5.084 kb
That is, using the UPX directly in the normal compilation, reduce it more!
P.D. Gracias PeteWG y Roberto por el ejemplo !
Hice algunas pruebas con el UPX y esto resulto...
---------------------------------------------------------------------------------------------------------------------------
El primer ejecutable, es una compilación normal y el sumatrapdf2.exe (6,339 kb) y pesa 10,251 kb.
(con mis bibliotecas predefinidas)
El segundo, es utilizando el UPX con el sumatrapdf2.exe con '--ultra-brute' switch. y pesa 7,048 kb.
El tercero, es utilizando el UPX '--ultra-brute' switch con el resultado de la compilación normal y pesa 5,084 kb
O sea, que utilizando directamente el UPX en la compilación normal, lo reduce más !.
--------------------------------------------------------------------------------------------------------------------------
The first executable, is a normal compilation and sumatrapdf2.exe (6,339 kb) and weighs 10.251 kb.
(With my predefined libraries)
The second is using UPX with sumatrapdf2.exe with '--ultra-brute' switch. And weighs 7.048 kb.
The third, is using the UPX '--ultra-brute' switch with the result of normal compilation and weighs 5.084 kb
That is, using the UPX directly in the normal compilation, reduce it more!
P.D. Gracias PeteWG y Roberto por el ejemplo !
Andrés González López
Desde Guadalajara, Jalisco. México.
Desde Guadalajara, Jalisco. México.
- Roberto Lopez
- HMG Founder
- Posts: 4004
- Joined: Wed Jul 30, 2008 6:43 pm
Re: PDF Viewer DLL?
Very interesting info.
My first thinking was that the result could be nearly the same (compressing Sumatra before embedding or later along the final exe).
Thanks!
Regards/Saludos,
Roberto
(Veritas Filia Temporis)
Roberto
(Veritas Filia Temporis)
- Roberto Lopez
- HMG Founder
- Posts: 4004
- Joined: Wed Jul 30, 2008 6:43 pm
Re: PDF Viewer DLL?
My knowledge about unicode is very poor, but I'm sure that some kind of conversion could be possible...Rathinagiri wrote: ↑Fri Feb 17, 2017 6:05 pm Actually I can not adapt to PDF because it doesn't support our Unicode.
There is lots of small commandline utilities for each need, maybe that one of them, could convert HTML to PDF.
ie: In the case of scanner control I've ended using three different things (my requirement was to scan to PDF 1.4).
To achieve that I've used:
- EZTW32.DLL: For scanner acces. The result is one (or more) bmp file(s).
- JPG.dll: Converts bmp to jpg (I could use HMG, I know).
- jpeg2pdf.exe: Converts jpgs to PDF. It is able to join multiple jpg files in a single PDF document (one page per jpg file).
The point is that if you research deep enough, almost always a solution arises, even you need multiple utilities to achieve that
Regards/Saludos,
Roberto
(Veritas Filia Temporis)
Roberto
(Veritas Filia Temporis)