/cactoos-pdf

A true object-oriented implementation for PDF document generation

Primary LanguageJavaMIT LicenseMIT

EO principles respected here We recommend IntelliJ IDEA Java Profiler

Maven Central Javadoc License

Hits-of-Code

Introduction

Cactoos PDF is a collection of object-oriented Java classes to build a PDF document.

Motivation. We are not happy with current Java PDF solutions because:

  1. Their code aren't truly object-oriented, i.e. they aren't obey these design principles

  2. Their license code aren't really free to do anything, like MIT or BSD license

How to use

<dependency>
  <groupId>com.github.fabriciofx</groupId>
  <artifactId>cactoos-pdf</artifactId>
  <version>0.0.1</version>
</dependency>

Java version required: 1.8+.

Usage

WARNING: Cactoos PDF is in a VERY early development stage. So the API can change at any moment.

Here an example how to build a Hello World PDF file using our API:

final File file = new File("HelloWorld.pdf");
final Id id = new Serial();
Files.write(
    file.toPath(),
    new Document(
        id,
        new DefaultPages(
            id,
            new DefaultPage(
                id,
                new Contents(
                    new Text(
                        id,
                        new TimesRoman(id, 18),
                        0,
                        500,
                        new TextOf("Hello World")
                    )
                )
            )
        )
    ).asBytes()
);

More examples can be found here.

Contributions

Contributions are welcome! Please, open an issue before submit any kind (ideas, documentation, code, ...) of contribution.

How compile it?

$ mvn clean install -Pqulice

License

The MIT License (MIT)

Copyright (C) 2023-2024 FabrĂ­cio Barros Cabral

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Acknowledgements

David West (Blog) for:

@yegor256 as Yegor Bugayenko (Blog) for: