Overview
Features
Download
Documentation
Community
Add-Ons & Services
The POCO C++ Libraries Blog

PocoPDF

Filed under: News by alex at 18:15

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:

PocoPDF Hello World

Alex

4 Comments »
  1. PocoPDF sounds interesting. Though it’s not specifically stated in your post, I’m guessing (by seeing the code example) that it is basically a C++ wrapper over libharu which is written in C? Or are there any other additional features you’ve added or plan to add?

    POCO itself sounds interesting too. It’s a good idea – C++ has been somewhat lacking in standardized cross-platform libraries for networking (unlike Java). Good to know about it. I shall check it out at some point …

    - Vasudev
    ———
    Vasudev Ram
    Dancing Bison Enterprises
    Software consulting and training
    Biz site: http://www.dancingbison.com
    Blog (on software innovation): http://jugad.livejournal.com
    Quick and easy PDF creation toolkit: http://www.dancingbison.com/products.html

    Comment by Vasudev Ram on January 27, 2008, 22:39

  2. This looks interesting. Any volunteers for adapting PocoDoc to make it generate great looking PDF documentation?

    Comment by guenter on January 27, 2008, 23:06

  3. Vasudev,

    Yes, it is a thin C++ wrapper of a C library. As for more features, I have none planned at the time so it all depends on the amount of volunteers willing to contribute.

    Alex

    Comment by alex on January 28, 2008, 04:17

  4. Thanks for the clarification.

    - Vasudev

    Comment by Vasudev Ram on April 24, 2008, 14:16

RSS RSS feed for comments on this post. TrackBack URI

Leave a comment