#pdf #api-bindings #generate #encoding

sys itext

Safe rust bindings to the iText 7 PDF generation library written in Java

4 releases

0.2.3 Oct 11, 2024
0.2.2 Feb 20, 2024
0.2.0 Jun 19, 2023
0.1.0 Jun 15, 2023

#86 in Multimedia

46 downloads per month

MIT/Apache

70KB
1.5K SLoC

Contains (JAR file, 61KB) bundle/gradle/wrapper/gradle-wrapper.jar

itext-rs

Rust bindings to the Java library iText-PDF.

Purpose

Generating PDFs in Rust is at the early stages. Java's PDF world is pretty far along. This library allows a Rust program to create PDFs using iText PDF.

Compiling

If the bundled feature is enabled:

  • The JVM should be installed.
  • The environmental variable JAVA_HOME should be set.

Usage

If the bundled feature is enabled:
When using JNI's invocation API, the JAR file embedded in this crate should be added to the classpath:

  1. Save the jarfile (const bundle::DEPENDENCIES) to disk
  2. Add the option -Djava.class.path=<PATH TO JARFILE> to the JVM's start parameters.

If the bundled feature is not enabled, you are responsible for providing the itext-pdf libraries to the JVM.


lib.rs:

iText-rs

Rust bindings to the iText 7.1.18 library.

Bindings

This library provides (partial) bindings for the following iText classes:

  • com.itextpdf.io
    • ImageData
  • com.itextpdf.kernel
    • PdfDocument
    • PdfWriter
    • SolidLine
    • PageSize
    • ColorConstant
  • com.itextpdf.layout
    • Document
    • Table
    • Cell
    • Paragraph
    • LineSeparator
    • Image

To support the iText-PDF types, there are also some other bindings included:

  • java.io.ByteArrayOutputStream
  • java.io.ByteArrayInputStream
  • java.awt.image.BufferedImage
  • javax.imageio.ImageIO
  • javax.imageio.stream.ImageInputStream

PR's to add missing bindings or to add to incomplete bindings are more than welcome.

The library

To function, this crate needs a JVM, obviously. Furthermore it needs the iText kernel, layout and io libraries. These are included in this crate via the bundled feature. A JAR file containing all dependencies is then included at itext::bundle::DEPENDENCIES;

If you're using the invocation API of the JVM to start it from code, add the option -Djava.class.path=<PATH TO JARFILE> to the JVM's start options. Of course, the dependencies jarfile must be saved to disk for this to work.

License

This library is provided under the MIT or Apache 2.0 license, at your option.

Dependencies

~3–13MB
~111K SLoC