I need to make a PDF file that will have plenty of EAN and QR codes.
I can do this in a classic way by writing the generated code from HMG_Zebra to a .png file and inserting it into a HPDFDOC by loading this file.
But this causes a lot of writes, reads and deletes on the HDD.
I tried using HPDF_Page_DrawImage (), but this requires pointing out the "pointer" of allocating bitmap in memory.
I do not know if is possible to read/convert the pointer with a bitmap handler.
Code: Select all
#include "hmg.ch"
Procedure Main
Local cEan:='20763015'
Local cImgFile:=TEMPFILE(,'png')
Local hBitMap, nImgWidth, nImgHeight
Local lSuccess := .f.
SELECT HPDFDOC "test.pdf" TO lSuccess PAPERSIZE HPDF_PAPER_A4
IF lSuccess
SET HPDFDOC COMPRESS ALL
SET HPDFDOC PAGEMODE TO OUTLINE
START HPDFDOC
START HPDFPAGE
hBitMap := HMG_CreateBarCode(cEan,"EAN8", 1, 15, .F., '', {0, 0, 0}, {255,255,255}, .F., .F. , .F.)
IF hBitMap <> 0
nImgWidth:=(BT_BitmapWidth(hBitmap) / 96) * 25.4
nImgHeight:=(BT_BitmapHeight(hBitmap) / 96) * 25.4
BT_BitmapSaveFile (hBitmap, cImgFile, BT_FILEFORMAT_PNG)
BT_BitmapRelease ( hBitmap )
@ 10, 10 HPDFPRINT IMAGE cImgFile WIDTH nImgWidth HEIGHT nImgHeight TYPE PNG
ENDIF
FErase(cImgFile)
END HPDFPAGE
END HPDFDOC
ENDIF
Regards, Edward.