Skip to content

AndreRenaud/PDFGen

Folders and files

NameName
Last commit message
Last commit date

Latest commit

53ea781 · Apr 20, 2024
Jul 16, 2023
Aug 20, 2021
Mar 16, 2022
Sep 27, 2023
May 7, 2018
Mar 16, 2022
Mar 16, 2022
Jan 22, 2018
Sep 27, 2023
Apr 20, 2024
Jan 11, 2021
Mar 16, 2022
Jun 7, 2021
Sep 27, 2023
Aug 2, 2023

Repository files navigation

PDFGen

PDFGen Logo

Buy Me A Coffee

Simple C PDF Creation/Generation library. All contained a single C-file with header and no external library dependencies.

Useful for embedding into other programs that require rudimentary PDF output.

Supports the following PDF features

  • Text of various fonts/sizes/colours/rotation
  • Primitive drawing elements
    • Lines
    • Rectangles
    • Filled Rectangles
    • Polygons
    • Filled Polygons
    • Bezier curves
  • Bookmarks
  • Barcodes (Code-128 & Code-39)
  • Embedded images
    • PPM/PGM (binary format only)
    • JPEG
    • PNG (Alpha Channels are not supported)
    • BMP

Example usage

#include "pdfgen.h"

int main(void) {
    struct pdf_info info = {
        .creator = "My software",
        .producer = "My software",
        .title = "My document",
        .author = "My name",
        .subject = "My subject",
        .date = "Today"
    };
    struct pdf_doc *pdf = pdf_create(PDF_A4_WIDTH, PDF_A4_HEIGHT, &info);
    pdf_set_font(pdf, "Times-Roman");
    pdf_append_page(pdf);
    pdf_add_text(pdf, NULL, "This is text", 12, 50, 20, PDF_BLACK);
    pdf_add_line(pdf, NULL, 50, 24, 150, 24, 3, PDF_BLACK);
    pdf_save(pdf, "output.pdf");
    pdf_destroy(pdf);
    return 0;
}

License

License: Unlicense

The source here is public domain. If you find it useful, please drop me a line at [email protected].

Builds

Build status: GitHub Actions

Appveyor status: Build status

Code Coverage: Coverage Status

Coverity scan: Coverity scan

Static Analysis

This is a code base that I use to test static analysis tools. As such the build system is quite a bit more complex than should be necessary for a project of this size.

Language Bindings