PDFGen icon indicating copy to clipboard operation
PDFGen copied to clipboard

Some improvements

Open Polarisru opened this issue 5 years ago • 8 comments

I have found this project 2 years ago and have used it for my development for a while. That's why I have added some more features to the source code. This is a list of features:

  • adding PNG and BMP images
  • adding a same header block to every page of the project
  • adding QR-code based on Project Nayuki (MIT license)

I have also started to add embedded fonts support.

Please let me know if you need this features in your beauiful project. There are already some differences between the actual code and the code I have changed then, so I have to do some changes and need to know if you really want them.

Thank you in advance.

Polarisru avatar Nov 27 '20 22:11 Polarisru

Hi, Thanks for sending this through. Adding PNG & BMP support would be welcome, as would embedded fonts. I did start looking at embedding fonts, but didn't progress it very far.

Things like QR & repeated headers feel like they might be left out for now, depending on how much code it is. I'd like to keep PDFGen pretty small, so I'm not sure if these fit. But if you've already written them up, I'd be keen to have a look.

Thanks, Andre

AndreRenaud avatar Nov 28 '20 06:11 AndreRenaud

Hello Andre,

I have pulled the changes with PNG/BMP and headers (it is pretty light-weight). But I can't get CI to work. I don't see any errors there, but it can't process the request properly. May be it has something with missing Valgrind to do: Running test valgrind ...Failed to run 'valgrind' Could you please take a look at it?

With best regards, Alex

Polarisru avatar Nov 28 '20 14:11 Polarisru

Hello Andre,

I have some free time and could do something else. Would you like to add page headers/footers I have told about?

Polarisru avatar Jan 10 '21 20:01 Polarisru

Hi Alex, Yes, that would be nice. I think the idea of some kind of pseudo-page, which could either indicate all pages, or just a subset (like only even/odd pages, or something like that). ie: pdf_add_page_special(pdf, PDF_PAGE_even) ... Then any objects you add to that page will just be put on every even page (or odd, or all etc...)

Any thoughts on that?

Thanks

AndreRenaud avatar Jan 10 '21 20:01 AndreRenaud

Hi Andre - I just encountered your library a few days ago, and have started incorporating it into 8th for PDF output. The embedded fonts is of particular interest (as is support for arbitrary UTF-8 characters).

I'm already using stb_truetype, which makes parsing the TTF files easy. Have no idea, though, how to embed a font (or, in particular, subset one).

ronaaron avatar Apr 19 '22 05:04 ronaaron

Hi. I haven't looked at how involved embedding fonts is, but my gut feeling is that it's quite a bit of code. We'd need a good portion of something like stb_truetype (for getting all the metrics, but not the rendering), along with code to embed the actual font content itself. I'm concerned that the amount of code could be too much for something like PDFGen (which I really want to remain relatively small/self-contained).

I absolutely could be wrong about that size though, so if you want to have a look at this, I'd be happy to assist. But keep in mind that stb_truetype is around 5k lines, so it is larger than all of PDFGen by itself (although it has a much higher ratio of comments to code).

AndreRenaud avatar Apr 19 '22 09:04 AndreRenaud

So... I'm thinking having an #ifdef EMBED_FONTS or the like, which would be reliant on stb_truetype.h, might be an easy way to go. That way, someone wishing to have the ability to embed fonts could do that, while other could ignore it.

ronaaron avatar Apr 19 '22 09:04 ronaaron

I'm probably not too keen on bringing in an external dependency in that sense. If it were to be done that way, perhaps it would be better to change PDFGen to allow internal PDF objects to be created via the API, but then the contents actually constructed by the caller. So the font stuff could all live outside PDFGen if the user wanted it.

AndreRenaud avatar Apr 19 '22 09:04 AndreRenaud