Create and Email PDF's from FWH

Create and Email PDF's from FWH

Postby TimStone » Tue Oct 31, 2006 1:32 am

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
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2945
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Postby ShumingWang » Tue Oct 31, 2006 2:17 am

Support VRD /Visual report ?

Thanks !

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

Postby George » Tue Oct 31, 2006 5:06 pm

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

Postby Roberto Parisi » Tue Oct 31, 2006 5:22 pm

Bought!

Excellent.

Regards.
Roberto Parisi
 
Posts: 116
Joined: Thu Oct 13, 2005 5:14 pm
Location: Italy

Postby reinaldocrespo » Sat Nov 04, 2006 4:53 pm

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
reinaldocrespo
 
Posts: 979
Joined: Thu Nov 17, 2005 5:49 pm
Location: Fort Lauderdale, FL

Postby Silvio » Tue Nov 07, 2006 9:59 am

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

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Postby George » Tue Nov 07, 2006 4:17 pm

Silvio,

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

Code: Select all  Expand view  RUN
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
George
 
Posts: 725
Joined: Tue Oct 18, 2005 6:49 pm

Postby wmormar » Sun Nov 12, 2006 9:15 am

George,

Podrias colgar un ejemplo de uso?

Gracias de antemano
William, Morales
Saludos

méxico.sureste
User avatar
wmormar
 
Posts: 1074
Joined: Fri Oct 07, 2005 10:41 pm
Location: México

Postby Armando » Sun Nov 12, 2006 2:17 pm

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
User avatar
Armando
 
Posts: 3229
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México

Postby ShumingWang » Sat Nov 25, 2006 4:15 am

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[i])
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: 465
Joined: Sun Oct 30, 2005 6:37 am
Location: Guangzhou(Canton),China

Postby ShumingWang » Sat Nov 25, 2006 4:17 am

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[i])
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: 465
Joined: Sun Oct 30, 2005 6:37 am
Location: Guangzhou(Canton),China

Postby ShumingWang » Tue Nov 28, 2006 1:59 am

George,

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

Best regard!

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

Postby ShumingWang » Tue Nov 28, 2006 2:04 am

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

Postby George » Fri Dec 01, 2006 11:02 pm

Sorry my friends; I was a month without my computer :(

Code: Select all  Expand view  RUN
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
George
 
Posts: 725
Joined: Tue Oct 18, 2005 6:49 pm

Postby wmormar » Sat Dec 02, 2006 6:43 am

George wrote:Sorry my friends; I was a month without my computer :(

Code: Select all  Expand view  RUN
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
User avatar
wmormar
 
Posts: 1074
Joined: Fri Oct 07, 2005 10:41 pm
Location: México

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Willi Quintana and 52 guests