Creating and writing PDF files using c++
The goal is to learn enough about the PDF specification and in the end be able to generate PDF files with 3D/Multimedia support.
You'll need a compiler that supports C++17 (C++1z)
Tested with Apple Clang 11, Clang 8.0.0 on Debian Linux and Visual Studio 2017
A cmake solution is on the way
- PDF Parsing/Reading
- Metadata support
- Wiki
- Documentation
-
Image support -
Annotations for Pages -
3D Support -
Stronger types (much is stringly typed a.t.m., seePDF_Plus::Object::Ref
for example) -
Better stream handling -
Implement stream compression
Example usage:
#include "PDF_Plus.h"
int main(int argc, const char * argv[])
{
using namespace PDF_Plus;
auto doc = std::make_unique<Document>("Example Document");
auto bigfont = std::make_shared<Font>(*doc, Font::Properties{
.fontSize = 25
});
auto font = std::make_shared<Font>(*doc, Font::Properties{
.fontSize = 14,
.fontName = "Courier"
});
auto page = std::make_shared<Page>(*doc);
page->resources()->addFont(bigfont);
page->resources()->addFont(font);
page->contents()->drawText("Page 1", font, Point{10, 10});
page->contents()->drawText("Timetable", bigfont, Point{100, 750});
doc->addPage(page);
std::ofstream ofs;
ofs.open("/tmp/pdfplus.pdf", std::ios::binary);
std::cout << *doc;
ofs << *doc;
return 0;
}