B4A Class [B4X] PDF Generator - B4X Cross Platform - Class 100% B4X Code

james_sgp

Active Member
Licensed User
Longtime User
Hi,

This library doesn't support all colorspace in PNG image. (see post #10)

spsp
I understand that, so there is no solution to be able to download an image and add into the PDF?

James
 

Setlodi

Member
I've found a workaround for adding images to a PDF document. My app captures signatures and then adds them on a PDF that I'm generating using the cPDF class. My signatures are captures with colorspace = 6 value and I couldn't see them in my PDF. When I use IrFax to change colorspace value to 2, as recommended in one of the posts it worked. However, to programmatically change was a challenge. So what I did is I converted my signature PNG image to JPEG and back to PNG, using the ConvertImage library.


Convert PNG image to JPEG and back to PNG:
'convert to JPEG
    Dim Bitmap1 As Bitmap = LoadBitmap(File.DirInternal, "signtest.png")
    Dim SavePathAndFileName As String = File.Combine(File.DirInternal, "signtest_JPG_conv.jpg")
    ConvertImage1.ConvertBitmapToFile(Bitmap1, SavePathAndFileName, ConvertImage1.TO_JPEG, 100)
    Log("signature.png converted to signature_JPG_conv.jpg")

    'convert to PNG
    Dim Bitmap1 As Bitmap = LoadBitmap(File.DirInternal, "signtest_JPG_conv.jpg")
    Dim SavePathAndFileName As String = File.Combine(File.DirInternal, "signtest_PNG_conv.png")
    ConvertImage1.ConvertBitmapToFile(Bitmap1, SavePathAndFileName, ConvertImage1.TO_PNG, 100)
    Log("signature.png converted back to signature_PNG_conv.png")
 

spsp

Active Member
Licensed User
Longtime User
Hi,

The class is updated in post #1 (version 0.5). it's support all image format loadable with xui.loadbitmap.


spsp
 

aeric

Expert
Licensed User
Longtime User
PDF standards font (Courier, Helvetica, Times, Symbol and Zapfdingbats), style (Normal, Bold, Italic, Underline and StrikeThrough), encoding cp1252
I hope this class can support unicode or utf8 encoding with Chinese standard fonts such as STHeitiSC-Light and AdobeMingStd-Light in the future.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…