Generate PDF via Open Source C++ API

Open Source C++ Library for Creating, Editing, Manipulating & Parsing PDF Files.

What is PDF-Writer?

PDF-Writer is an Open Source C++ library that fully supports creating, editing, manipulating & parsing PDF Files as well as streams. The library was developed with the principal “one-off” method of generating PDF files.  That’s why it is working fast and uses low memory regardless of how large the file grows. Therefore it is best to create small PDF files or generate larger PDF documents.

Adding content to a PDF is always very important and helps developers in generating custom PDFs. The library has included support for several important features for processing PDF files such as Creation of PDF pages, PDF operators for drawing content, JPG or PNG and TIFF images embedding,  modifying PDF, merge or split PDFs, rendering PDF files, data extraction from PDF, Unicode text support, TrueType and OpenType fonts support and many more..

Previous Next

Getting Started with PDF-Writer

The recommended method for building the library, and sample application, is to use CMake.  you can get it from CMake web site.  The library is dependent on Zlib, LibTiff, LibJpeg, FreeType, and LibPng.  This means that you should compile them too, before using the PDF library in a linked context.

You can also install it manually; download the latest release files directly from GitHub repository.

PDF Generation & Modification via C++

Software developers can use PDF-Writer API to generate a new PDF file inside their own C++ applications. Once the document is the library also facilitates developers to modify it according to their own needs. You can easily embed JPG, PNG, and TIFF images, Defining reusable objects, embed existing PDFs pages as well as text with ease. You can use existing PDFs pages by either append them as pages to the PDF or use them as parts to include in the graphics of a newly created page. By using the following steps, you can generate PDF easily.

Generate PDF in C++

  1. Import jsPDF
  2. Initialize a new PDF document using jsPDF() method
  3. Add text using the text(text, x, y, options, transform) method. The method accepts string or array of strings as first arguments, x & y coordinates, optional settings, and transform number to rotate the text
  4. Save PDF document

PDF Generation in C++

import { jsPDF } from "jspdf";
// initialize jsPDF()
const doc = new jsPDF();
// add text
doc.text("File Format Developer Guide!", 10, 10);
// save"fileformat.pdf");

Adding New Pages to PDF Document

With PDF-Writer library it is possible to add new pages and set their dimensions inside a PDF document. It is very easy and requires just a few lines of PHP code to add new pages to a PDF file. The library also gives developers the power to modify an existing page or delete a page.  It is also possible to add content to an already created PDF page.

Embedding Images in PDF Documents

The PDF-Writer library provides support for embedding TIFF, PNG, and JPG Images as well as PDF pages. There are high-level methods that are general for any image type.  Apart from that there some lower-level methods for advanced usages of the images. It has provided support for JPG Images through the native DCT decoder, PNG is through decoding with LibPng and TIFF Images is through encoding/decoding with the help of LibTiff.