Create and Email PDF's from FWH
Create and Email PDF's from FWH
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 !
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 !
Tim Stone
http://www.MasterLinkSoftware.com
timstone@masterlinksoftware.com
Using: FWH 19.06 with Harbour 3.2.0 / Microsoft Visual Studio Community 2019
http://www.MasterLinkSoftware.com
timstone@masterlinksoftware.com
Using: FWH 19.06 with Harbour 3.2.0 / Microsoft Visual Studio Community 2019
-
- Posts: 454
- Joined: Sun Oct 30, 2005 6:37 am
- Location: Guangzhou(Canton),China
-
- Posts: 116
- Joined: Thu Oct 13, 2005 5:14 pm
- Location: Italy
- reinaldocrespo
- Posts: 918
- Joined: Thu Nov 17, 2005 5:49 pm
- Location: Fort Lauderdale, FL
Silvio,
These are the wrappers that I am using with image2pdf.dll
The help file that come with "image2pdf.dll" is complete and easy to understand.
Regards
George
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"
Regards
George
Timm or George:
Could you please upload a little sample using image2pdf.dll ?
Regards, Armando
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
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
-
- Posts: 454
- Joined: Sun Oct 30, 2005 6:37 am
- Location: Guangzhou(Canton),China
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
#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
-
- Posts: 454
- Joined: Sun Oct 30, 2005 6:37 am
- Location: Guangzhou(Canton),China
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
#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
-
- Posts: 454
- Joined: Sun Oct 30, 2005 6:37 am
- Location: Guangzhou(Canton),China
-
- Posts: 454
- Joined: Sun Oct 30, 2005 6:37 am
- Location: Guangzhou(Canton),China
Sorry my friends; I was a month without my computer
Regards
George
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.)
George
Georce,George wrote:Sorry my friends; I was a month without my computer
RegardsCode: 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.)
George
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
Saludos
méxico.sureste