Last night I chatted with Mr. Vilian and requested him to check both :Say() and :
SayText(). He confirmed both working correctly to me in person and also in his post above. He is using bcc and I know you are using MSVC.
I searched and located the old evaluation version of image2pdf dll I downloaded in 2009 and tested with bcc and msvc using the code posted by Mr. Vilian.
This is my test program. Depending on the choice of the user, it creates PDF either by using the default (Word) or using FWH function or Image2PDF. I compiled using MSVC (2017) and did not encounter any runtime errors or problems.
- Code: Select all Expand view RUN
#include "fivewin.ch"
static hLib
//----------------------------------------------------------------------------//
#include "fivewin.ch"
function Main()
local oPrn, oFont, nCh
local oBrushRed, oBrushGreen
nCh := Alert( "Create PDF using", { "FWH", "WORD", "IMG2PDF" } )
if nCh == 0
return nil
elseif nCh == 1
TPreview():bSaveAsPDF := { |o| FWSavePreviewToPDF( o:oDevice ) }
elseif nCh == 3
TPreview():bSaveAsPDF := { |o| Image2PDF( o:oDevice:aMeta ) }
endif
PRINT oPrn PREVIEW
DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-20 OF oPrn
DEFINE BRUSH oBrushRed COLOR CLR_HRED
DEFINE BRUSH oBrushGreen COLOR CLR_HGREEN
PAGE
@ 300,100 PRINT TO oPrn TEXT "YELLOW ON RED" SIZE 2000,200 PIXEL FONT oFont COLOR CLR_YELLOW,oBrushRed
@ 620,100 PRINT TO oPrn TEXT "DEFAULT COLORS" SIZE 2000,200 PIXEL FONT oFont
@ 940,100 PRINT TO oPrn TEXT "BLUE ON GREEN" SIZE 2000,200 PIXEL FONT oFont COLOR CLR_BLUE, oBrushGreen
@ 1260,100 PRINT TO oPrn TEXT "DEFAULT COLORS" SIZE 2000,200 PIXEL FONT oFont
@ 1580,100 PRINT TO oPrn TEXT "YELLOW ON RED" SIZE 2000,200 PIXEL FONT oFont COLOR CLR_YELLOW,oBrushRed
SetBkColor( oPrn:hDCOut, CLR_HRED )
oPrn:Say( 300, 2600, "YELLOW ON RED", oFont, 2000, CLR_YELLOW, 2 )
SetBkColor( oPrn:hDCOut, CLR_HGREEN )
oPrn:Say( 940, 2600, "BLUE ON GREEN", oFont, 2000, CLR_BLUE, 2 )
ENDPAGE
ENDPRINT
RELEASE FONT oFont
RELEASE BRUSH oBrushRed, oBrushGreen
return nil
//----------------------------------------------------------------------------//
function Image2PDF( aMeta, cPdf, lView )
local i, err
DEFAULT cPDF := cGetFile( "(*.pdf)|*.pdf|", "Select PDF File to Save",, ;
CurDir(), .T. )
if Empty( cPdf )
return nil
endif
hLib := LoadLib32( "Image2PDF StdCall.dll" )
// err := I2PDF_License( "xxx-xxxx-xxxxx-xxxxxx-xxxxxxx" )
err := I2PDF_MetaToNativePDF( )
err := I2PDF_MetaTextFitBoundingRect()
err := I2PDF_UseEMFDeviceSize( )
for i := 1 TO Len( aMeta )
if ( err := I2PDF_AddImage( aMeta[ i ] ) ) != 0
exit
endif
next
err := I2PDF_SetDPI( 0 )
err := I2PDF_MakePDF( cPdf, 0, "", 40 )
FreeLib32( hLib )
DEFAULT lView := MsgYesNo( "View " + cPdf + "?" )
if lView
ShellExecute( 0, "open", cPDF )
endif
return ( cPdf )
//----------------------------------------------------------------------------//
DLL32 STATIC FUNCTION I2PDF_License( cLicCode AS LPSTR) AS LONG;
PASCAL FROM "I2PDF_License" LIB hLib
DLL32 STATIC FUNCTION I2PDF_MetaToNativePDF( ) AS LONG;
PASCAL FROM "I2PDF_MetaToNativePDF" LIB hLib
DLL32 STATIC FUNCTION I2PDF_UseEMFDeviceSize( ) AS LONG;
PASCAL FROM "I2PDF_UseEMFDeviceSize" LIB hLib
DLL32 STATIC FUNCTION I2PDF_MetaTextFitBoundingRect( ) AS LONG;
PASCAL FROM "I2PDF_MetaTextFitBoundingRect" LIB hLib
// static unsigned int I2PDF_AddImage(char *image);
DLL32 STATIC FUNCTION I2PDF_AddImage( cImage AS LPSTR ) AS LONG;
PASCAL FROM "I2PDF_AddImage" LIB hLib
// static unsigned int I2PDF_SetDPI(unsigned int dpi);
DLL32 STATIC FUNCTION I2PDF_SetDPI( nDpi AS LONG ) AS LONG;
PASCAL FROM "I2PDF_SetDPI" LIB hLib
// static unsigned int I2PDF_MakePDF(char *output, int options, char *errorText, unsigned int maxErrorTextSize);
DLL32 STATIC FUNCTION I2PDF_MakePDF( cOutFile AS LPSTR, nOptions AS LONG, cErrTxt AS LPSTR, nMaxESize AS LONG ) AS LONG;
PASCAL FROM "I2PDF_MakePDF" LIB hLib
Note: @ r,c PRINT commands are translated to :
SayText() calls.
You use LoadLib32( ) and I'm using LoadLibrary( )
When I used LoadLib32(), it is working correctly. When I changed to LoadLibrary() no pdf is generated but an hb_out.log file is generated with errors of crash.
Built using buildh32.bat:
This is the print preview screen:
By default, the preview generates PDF using MSWord if installed. This is the PDF generated using MSWord by default.
This is the PDF generated using FWH own function:
This is the PDF generated using Image2PDF (evaluation) DLL.
Observations:
Quality:
Can be seen in the above images.
PDF File sizes:
Image2PDF generates very small PDF files.
Handling of colors:
In the left column, text is printed using :
SayText() over color background painted using color brush.
All three pdfs rendered these background colors.
In the right column, text is printed by the method Say() with the background color set by calling SetBkColor(). In this case, the background color is rendered by both FWH own function and MSWord. Image2PDF failed to display the background color totally.