PocoPDF
I have just submitted a first attempt of PocoPDF into the SVN sandbox. It is a wrapper for the Haru PDF library. Haru depends on zlib and libpng, so full source for all three is embedded in PocoPDF.
Submitted code works and it comes with two samples – one showing how to create a text document and one with embedded image.
Here’s a list of outstanding items for this effort to be released:
- VS 71 and VS 90 solution and project files (only VS 80 and Makefiles are current now)
- attempt to establish some cooperation with Haru maintainers to:
- get rid of MSVC warnings (mainly narrowing and signedness implicit conversions)
- use freetype for fonts (there are some reports that loading TTF fonts on Mac does not work well and Haru’s font handling is rudimentary)
- write tests
- write more samples
- ? export zlib functions from Foundation so we do not have to duplicate code in PDF ?
As usual, it would be really nice if someone would step up and volunteer to complete this. I will also post a message on Haru forum.
Here’s a snippet of code:
Document document(pdfFile.path());
Page page = document[0];
Font helv = document.font("Helvetica");
page.setFont(helv, 24);
std::string hello = "Hello PDF World from ";
float textWidth = page.textWidth(hello);
float textBegin = (page.getWidth() - textWidth) / 2;
page.writeOnce(textBegin, page.getHeight() - 50, hello);
Image image = document.loadPNGImage(pngFile.path());
page.drawImage(image, textBegin + textWidth / 2 - image.width() / 2,
page.getHeight() - 100 - image.height(),
image.width(),
image.height());
document.save();
And voila! – here’s the resulting document:
Alex