Page 1 of 2

Create and Email PDF's from FWH

Posted: Tue Oct 31, 2006 1:32 am
by TimStone
The question has been raised several times about being able to email a report / document, from rpreview, as a PDF. There have been some elaborate solutions proposed, but I have finished incorporating a product that works very well for this task.

Essentially, I pass the aFiles array of EMF names to this product ( it is a .DLL ), and it creates the PDF and I then simply attach it to an email. It all happens with the click of an email icon in a Preview using the .dll and pure FWH / xHarbour code.

I had an initial problem with graphic backgrounds ( grey ) but those were fixed within a couple of hours, and now the output is excellent. A special utility capability in the latest version creates PDF from EMF/WMF files that are much smaller, and it works very quickly.

If you are looking for this solution, go to www.utilitywarrior.com and check out Image2PDF, the .DLL version. The price is very reasonable ... $60 / US for a royalty free license for a single application, or $260 / US for a royalty free for an unlimited number of licenses ( one developer of course ). The support is fast, pleasant, and this is a product well worth supporting.

If you need any help implementing it, I'd be happy to provide a copy of my changes to the rpreview.prg as I've modified it. Just send me an email to timstone@masterlinksoftware.com and I'll send it by reply. I will send only the added function(s) and notes on how to implement them into your version of rpreview !

Do check this out. This is a nice person doing a good job ! :D

Posted: Tue Oct 31, 2006 2:17 am
by ShumingWang
Support VRD /Visual report ?

Thanks !

Shuming Wang

Posted: Tue Oct 31, 2006 5:06 pm
by George
Tim,

I agreed 100% with you.

This product is Excellent!!! and Adrian is nice and him answer quickly any question that someone could have about his product.

Regards



George

Posted: Tue Oct 31, 2006 5:22 pm
by Roberto Parisi
Bought!

Excellent.

Regards.

Posted: Sat Nov 04, 2006 4:53 pm
by reinaldocrespo
Hi.

I also purchased the .dll version. It is excellent. My users love it.

Tim, thank you very much for the info.


Reinaldo Crespo-Bazán

Posted: Tue Nov 07, 2006 9:59 am
by Silvio
TImm,
can you pubblish the function to use th eimage2pdf on this forum ?

Posted: Tue Nov 07, 2006 4:17 pm
by George
Silvio,

These are the wrappers that I am using with image2pdf.dll

Code: Select all

DLL32 Function I2PDF_AddImage(image as LPSTR);
AS LONG PASCAL FROM "I2PDF_AddImage" LIB "IMAGE2PDF.DLL"

DLL32 Function I2PDF_SetProducer(producer as LPSTR);
AS LONG PASCAL FROM "I2PDF_SetProducer" LIB "IMAGE2PDF.DLL"


DLL32 Function I2PDF_GetDLLVersion();
AS LONG PASCAL FROM "I2PDF_GetDLLVersion" LIB "IMAGE2PDF.DLL"


DLL32 Function I2PDF_License(code As LPSTR);
AS LPSTR PASCAL FROM "I2PDF_License" LIB "IMAGE2PDF.DLL"


DLL32 Function I2PDF_MetaImageMaxMP(maxmp as LONG);
AS LONG PASCAL FROM "I2PDF_MetaImageMaxMP" LIB "IMAGE2PDF.DLL"

DLL32 Function I2PDF_DeleteImagesOnConvert();
AS VOID PASCAL FROM "I2PDF_DeleteImagesOnConvert" LIB "IMAGE2PDF.DLL"

DLL32 Function I2PDF_SetDPI(dpi as LONG);
AS LONG PASCAL FROM "I2PDF_SetDPI" LIB "IMAGE2PDF.DLL"

DLL32 Function I2PDF_MakePDF(output As LPSTR, options as LONG, @cBuffer As LPSTR, ;
	maxErrorTextSize As LONG);
AS LONG PASCAL FROM "I2PDF_MakePDF" LIB "IMAGE2PDF.DLL"

DLL32 Function I2PDF_SetPermissionPrint();
AS VOID PASCAL FROM "I2PDF_SetPermissionPrint" LIB "IMAGE2PDF.DLL"

DLL32 Function I2PDF_MetaImageMaxMP_Int(maxmp as LONG);
AS LONG PASCAL FROM "I2PDF_MetaImageMaxMP_Int" LIB "IMAGE2PDF.DLL"

DLL32 Function I2PDF_UseEMFDeviceSize();
AS VOID PASCAL FROM "I2PDF_UseEMFDeviceSize" LIB "IMAGE2PDF.DLL"

DLL32 Function I2PDF_MetaToNativePDF();
AS VOID PASCAL FROM "I2PDF_MetaToNativePDF" LIB "IMAGE2PDF.DLL"

DLL32 Function I2PDF_Log(logFilename As LPSTR, logLevel as LONG);
AS LONG PASCAL FROM "I2PDF_Log" LIB "IMAGE2PDF.DLL"

The help file that come with "image2pdf.dll" is complete and easy to understand.

Regards



George

Posted: Sun Nov 12, 2006 9:15 am
by wmormar
George,

Podrias colgar un ejemplo de uso?

Gracias de antemano

Posted: Sun Nov 12, 2006 2:17 pm
by Armando
Timm or George:

Could you please upload a little sample using image2pdf.dll ?

Regards, Armando

Posted: Sat Nov 25, 2006 4:15 am
by ShumingWang
This the test.c and include file come from iamge2pdf.dll download package

#include <Windows.h>
#include "Image2PDF.h"


UINT ShowError(char *which, UINT iErr)
{
char message[200];

wsprintf(message, "%s returned error %d", which, iErr);

MessageBox(NULL, message, "Error Returned From Image2PDF DLL", MB_OK | MB_ICONERROR);

return iErr;
}


int PASCAL WinMain(HINSTANCE hCurrentInstance, HINSTANCE hPreviousInstance,
LPSTR lpszCommandLine, int iCommandShow)
{
UINT iErr;
char appDir[MAX_PATH + 1];
char imageFilename[MAX_PATH + 1];
char pdfFilename[MAX_PATH + 1];
char *p;
char errorText[1024];

// determine where app is running
lstrcpy(appDir, GetCommandLine());
if (*appDir == '"')
lstrcpy(appDir, GetCommandLine() + 1);
p = strrchr(appDir, '\\');
if (p) p[1] = 0;

wsprintf(imageFilename, "%stest.jpg", appDir);
wsprintf(pdfFilename, "%stest.pdf", appDir);

iErr = I2PDF_AddImage(imageFilename); if (iErr) return ShowError("I2PDF_AddImage", iErr);
iErr = I2PDF_SetDPI(96); if (iErr) return ShowError("I2PDF_SetDPI", iErr);
iErr = I2PDF_MakePDF(pdfFilename, OPTION_OPEN_PDF, errorText, sizeof(errorText));
if (iErr)
{
if (iErr == 3)
ShowError(errorText, iErr);
else
ShowError("I2PDF_MakePDF", iErr);
}
return 0;
}



2. I write a test.prg

ACTIVATE REPORT oRpt ;
WHILE ( oRpt:Cargo == 1 );
on end save2pdf(orpt)

FUNCTION save2pdf(orpt)
private ctext:=SPACE(4096)
aFiles := orpt:oDevice:aMeta
for i:=1 TO LEN(afiles)
I2PDF_AddImage(afiles)
end
I2PDF_MakePDF("d:\aaa.pdf", 1, @cTEXT, 4096)

return .t.

This do not create pdf file at all.

Best Regard!

Shuming Wang

Posted: Sat Nov 25, 2006 4:17 am
by ShumingWang
This the test.c and include file come from iamge2pdf.dll download package

#include <Windows.h>
#include "Image2PDF.h"


UINT ShowError(char *which, UINT iErr)
{
char message[200];

wsprintf(message, "%s returned error %d", which, iErr);

MessageBox(NULL, message, "Error Returned From Image2PDF DLL", MB_OK | MB_ICONERROR);

return iErr;
}


int PASCAL WinMain(HINSTANCE hCurrentInstance, HINSTANCE hPreviousInstance,
LPSTR lpszCommandLine, int iCommandShow)
{
UINT iErr;
char appDir[MAX_PATH + 1];
char imageFilename[MAX_PATH + 1];
char pdfFilename[MAX_PATH + 1];
char *p;
char errorText[1024];

// determine where app is running
lstrcpy(appDir, GetCommandLine());
if (*appDir == '"')
lstrcpy(appDir, GetCommandLine() + 1);
p = strrchr(appDir, '\\');
if (p) p[1] = 0;

wsprintf(imageFilename, "%stest.jpg", appDir);
wsprintf(pdfFilename, "%stest.pdf", appDir);

iErr = I2PDF_AddImage(imageFilename); if (iErr) return ShowError("I2PDF_AddImage", iErr);
iErr = I2PDF_SetDPI(96); if (iErr) return ShowError("I2PDF_SetDPI", iErr);
iErr = I2PDF_MakePDF(pdfFilename, OPTION_OPEN_PDF, errorText, sizeof(errorText));
if (iErr)
{
if (iErr == 3)
ShowError(errorText, iErr);
else
ShowError("I2PDF_MakePDF", iErr);
}
return 0;
}



2. I write a test.prg

ACTIVATE REPORT oRpt ;
WHILE ( oRpt:Cargo == 1 );
on end save2pdf(orpt)

FUNCTION save2pdf(orpt)
private ctext:=SPACE(4096)
aFiles := orpt:oDevice:aMeta
for i:=1 TO LEN(afiles)
I2PDF_AddImage(afiles)
next
I2PDF_MakePDF("d:\aaa.pdf", 1, @cTEXT, 4096)

return .t.


DLL32 Function I2PDF_AddImage(image as LPSTR);
AS LONG PASCAL FROM "I2PDF_AddImage" LIB "IMAGE2PDF.DLL"


DLL32 Function I2PDF_MakePDF(output As LPSTR, options as LONG, @cBuffer As LPSTR, ;
maxErrorTextSize As LONG);
AS LONG PASCAL FROM "I2PDF_MakePDF" LIB "IMAGE2PDF.DLL"

This do not create pdf file at all.

Best Regard!

Shuming Wang

Posted: Tue Nov 28, 2006 1:59 am
by ShumingWang
George,

Your wraps require Adobe Acrobat software for creation?
why mines not create a pdf file?

Best regard!

Shuming Wang

Posted: Tue Nov 28, 2006 2:04 am
by ShumingWang
George,

> These are the wrappers that I am using with image2pdf.dll
Why my prg not create pdf ?

ctext:=space(1024)

I2PDF_AddImage("logo.jpg")
I2PDF_SetDPI(96)
I2PDF_MakePDF("d:\abc.pdf", 1, @ctext,1024)
Best regard!
Shuming Wang

Posted: Fri Dec 01, 2006 11:02 pm
by George
Sorry my friends; I was a month without my computer :(

Code: Select all

FUNCTION SaveAsPDF(cRepName)
LOCAL result
LOCAL cBuffer:=space(300)
    hLib = LOADLIBRARY( "image2pdf.dll" )
	 
	 nRc :=  I2PDF_Log(".\log.txt", 3) // To save a LOG 
	
	 I2PDF_MetaTextFitBoundingRect()

	  nRc := I2PDF_UseEMFDeviceSize()
    
	  nRc := I2PDF_MetaToNativePDF()
	
	   nRc := I2PDF_SetDPI(300)   //- or to whatever value you require
	 

                DECLARE aEmf := {}
	aEmf := directory("*.emf") // Multiples pages

	FOR nX := 1 TO  len(aEmf)
	            nRc := I2PDF_AddImage(alltrim(aEmf[nX, F_NAME]))
	NEXT

	nResult := I2PDF_MakePDF(cRepName, 0, @cBuffer ,300)
	 	
	 FreeLibrary(hLib)

RETURN (.T.)
Regards


George

Posted: Sat Dec 02, 2006 6:43 am
by wmormar
George wrote:Sorry my friends; I was a month without my computer :(

Code: Select all

FUNCTION SaveAsPDF(cRepName)
LOCAL result
LOCAL cBuffer:=space(300)
    hLib = LOADLIBRARY( "image2pdf.dll" )
	 
	 nRc :=  I2PDF_Log(".\log.txt", 3) // To save a LOG 
	
	 I2PDF_MetaTextFitBoundingRect()

	  nRc := I2PDF_UseEMFDeviceSize()
    
	  nRc := I2PDF_MetaToNativePDF()
	
	   nRc := I2PDF_SetDPI(300)   //- or to whatever value you require
	 

                DECLARE aEmf := {}
	aEmf := directory("*.emf") // Multiples pages

	FOR nX := 1 TO  len(aEmf)
	            nRc := I2PDF_AddImage(alltrim(aEmf[nX, F_NAME]))
	NEXT

	nResult := I2PDF_MakePDF(cRepName, 0, @cBuffer ,300)
	 	
	 FreeLibrary(hLib)

RETURN (.T.)
Regards


George
Georce,

The next function not exist

I2PDF_Log()
I2PDF_MetaTextFitBoundingRect()
I2PDF_UseEMFDeviceSize()
I2PDF_MetaToNativePDF()
I2PDF_SetDPI()
I2PDF_AddImage()
I2PDF_MakePDF()

something any idea?

William

PD. sorry by bad english