Convert .bmp to .pdf on Keil 4 platform

107 Views Asked by At

In my embedded project, I'm using emWin for capturing the screenshot. The image saved is in .bmp format. Now my requirement is to convert this image into a pdf file.

Since there is no option in emWin to save as pdf, I'm thinking of using libharu library.

Does this library have the option to convert bmp to pdf? If it is not useful, how can I achieve this? Please guide me.

1

There are 1 best solutions below

0
jbrouwer On BEST ANSWER

Normaly, emWin can save image into a png format. There is a function in libharu to insert a png file in your pdf.

Ex:

HPDF_Doc   Pdf     = HPDF_New                  ( error_handler , NULL   ) ;
HPDF_Page  Page    = HPDF_AddPage              ( Pdf                    ) ;

HPDF_Image MyImage = HPDF_LoadPngImageFromFile ( Pdf ,"tmp//image.png" ) ; 
HPDF_REAL  Width   = HPDF_Image_GetWidth       ( MyImage                ) ;
HPDF_REAL  Height  = HPDF_Image_GetHeight      ( MyImage                ) ;

HPDF_Page_DrawImage ( Page , MyImage , x , y , Width , Height ) ;