Android Question non bitmap image in a pdf

MarcRB

Member
Licensed User
Hi,
I will create a pdf report that contains a background image like a business logo or a fullpage coporate identity. I used two kind of pdf libs and they both work great with small images, but one PDF page can grow up to 12 MB after inserting an 45kB png image file.

I discovered that a fullpage (A4) background logo file in png of 45kB file size grows to a bitmap of 12,8MB.
Also outside b4a. If I open that png an choose SaveAs *.bmp in any image application the file grows to 12,8Mb . (1785 x 2520 pixels). So bitmap seems to be so big that I want to insert my png without converting to bitmap. Test png image is attached.
Note smaller resolution has a big impact on quality.

In the pdf code I MUST use LoadBitmap, or maybe there is a way to load a png?
At that point my image file is converted to a huge bitmap and it makes the pdf huge also.

B4X:
Dim bmpLogo As Bitmap

If File.Exists(AppUtils.cstAppFolder, "logoA4.png") = True Then
       bmpLogo= LoadBitmap(AppUtils.cstAppFolder, "logoA4.png")
       PDFWriter1.addImage2(0,AppUtils.mm2pdf(0),(bmpLogo.width/dblFact),(bmpLogo.Height/dblFact),bmpLogo)
 End If
Is there any better way to insert a full page image of good quality in a pdf without making that pdf useless for email, because of its file size ?
 

Attachments

MarcRB

Member
Licensed User
Erel, thanks for your reply.

Before trying to draw in the canvas I tryed the example in your link.
Do I need some special libraries to get the PDFDocument Object. Do I have to download an additional jar file ?
I checked library core (V8.00), tried PDF(V0.25) and PDFWriter(v1.10), but still don't get it work.

How do I get that PDFdocument object?

B4A V8.00
SDK manager API 24
 

MarcRB

Member
Licensed User
Drawing in the canvas, works, but the pdf size is still huge. (Canvas is also a bitmap)

Are there other PDF solutions noncommerial or commercial thta can do the job?
DonManfred's version has the same problem with this type of image.

Or is it possible to change the compression settings of that pdf?

If not than I will test again with the library created/edited by DonManfred. In that case I will use 4 images, top header, bottom footer, left and right border.All the Whitepsaces can be excluded. In a setting file I can set the positions and its dimensions of each image.
 
Top