Hi,
how can I generate PDF without saving to a file? I need the content of PDF's as variable, while it must be base64 encoded.
Regards
Piotr
How generate PDF as variable?
Re: How generate PDF as variable?
There are lots of ways to create a PDF, but they all create a file.
You can first create the PDF file then make it into a Base64 string like this:
You can first create the PDF file then make it into a Base64 string like this:
Code: Select all
DCPRINT ON NAME "Microsoft PDF Printer" TOFILE OUTFILE 'MyPrintJob.Pdf'
.. DCPRINT commands
DCPRINT OFF
cBase64 := DC_File2Base64('MyPrintJob.Pdf')
* ------------------------------
FUNCTION DC_File2Base64( cInputFile )
LOCAL nHandle, nSize, cBuffer, cBase64
nHandle := FOpen(cInputFile)
nSize := FSeek(nHandle,0,FS_END)
cBuffer := Space(nSize)
FSeek(nHandle,0,FS_SET)
nSize := Fread(nHandle,@cBuffer,nSize)
FClose(nHandle)
IF nHandle <= 0
cBase64 := ''
ELSE
cBase64 := Bin2Base64(cBuffer)
ENDIF
RETURN cBase64
The eXpress train is coming - and it has more cars.
Re: How generate PDF as variable?
Hi Roger,
thanks for you tip - this way I know. But I search any way without creating a file. I find a DynamicPDF library, who can do it, but it's too expensive only for this purpose.
Regards
Piotr
thanks for you tip - this way I know. But I search any way without creating a file. I find a DynamicPDF library, who can do it, but it's too expensive only for this purpose.
Regards
Piotr