Create and Email PDF's from FWH

User avatar
TimStone
Posts: 2536
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA
Contact:

Create and Email PDF's from FWH

Post 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
Tim Stone
http://www.MasterLinkSoftware.com
timstone@masterlinksoftware.com
Using: FWH 19.06 with Harbour 3.2.0 / Microsoft Visual Studio Community 2019
ShumingWang
Posts: 454
Joined: Sun Oct 30, 2005 6:37 am
Location: Guangzhou(Canton),China

Post by ShumingWang »

Support VRD /Visual report ?

Thanks !

Shuming Wang
George
Posts: 710
Joined: Tue Oct 18, 2005 6:49 pm

Post 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
Roberto Parisi
Posts: 116
Joined: Thu Oct 13, 2005 5:14 pm
Location: Italy

Post by Roberto Parisi »

Bought!

Excellent.

Regards.
User avatar
reinaldocrespo
Posts: 918
Joined: Thu Nov 17, 2005 5:49 pm
Location: Fort Lauderdale, FL

Post 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
User avatar
Silvio
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Post by Silvio »

TImm,
can you pubblish the function to use th eimage2pdf on this forum ?
Best Regards, Saludos

Falconi Silvio
George
Posts: 710
Joined: Tue Oct 18, 2005 6:49 pm

Post 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
User avatar
wmormar
Posts: 1050
Joined: Fri Oct 07, 2005 10:41 pm
Location: México
Contact:

Post by wmormar »

George,

Podrias colgar un ejemplo de uso?

Gracias de antemano
William, Morales
Saludos

méxico.sureste
User avatar
Armando
Posts: 2479
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México
Contact:

Post by Armando »

Timm or George:

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

Regards, Armando
SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
ShumingWang
Posts: 454
Joined: Sun Oct 30, 2005 6:37 am
Location: Guangzhou(Canton),China

Post 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
ShumingWang
Posts: 454
Joined: Sun Oct 30, 2005 6:37 am
Location: Guangzhou(Canton),China

Post 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
ShumingWang
Posts: 454
Joined: Sun Oct 30, 2005 6:37 am
Location: Guangzhou(Canton),China

Post by ShumingWang »

George,

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

Best regard!

Shuming Wang
ShumingWang
Posts: 454
Joined: Sun Oct 30, 2005 6:37 am
Location: Guangzhou(Canton),China

Post 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
George
Posts: 710
Joined: Tue Oct 18, 2005 6:49 pm

Post 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
User avatar
wmormar
Posts: 1050
Joined: Fri Oct 07, 2005 10:41 pm
Location: México
Contact:

Post 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
William, Morales
Saludos

méxico.sureste
Post Reply