Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some improvements #66

Open
Polarisru opened this issue Nov 27, 2020 · 8 comments
Open

Some improvements #66

Polarisru opened this issue Nov 27, 2020 · 8 comments

Comments

@Polarisru
Copy link
Contributor

Polarisru commented Nov 27, 2020

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.

@AndreRenaud
Copy link
Owner

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

@Polarisru
Copy link
Contributor Author

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
Copy link
Contributor Author

Hello Andre,

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

@AndreRenaud
Copy link
Owner

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

@ronaaron
Copy link

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).

@AndreRenaud
Copy link
Owner

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).

@ronaaron
Copy link

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.

@AndreRenaud
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants