GithubHelp home page GithubHelp logo

danfickle / openhtmltopdf-native Goto Github PK

View Code? Open in Web Editor NEW
1.0 4.0 0.0 52 KB

A proof-of-concept PDF generator with GraalVM native-image tool.

Shell 46.12% Java 53.88%
graalvm-native-image graalvm java pdf-generation

openhtmltopdf-native's Introduction

OpenHTMLtoPDF with native-image

Aim is to make a blazing fast PDF generator. This is a proof-of-concept. See also danfickle/openhtmltopdf

Instructions

I did this on an Oracle Cloud Ampere ARM compute instance (Oracle Linux 8) with 18GB of memory (always free eligible). I'd recommend an instance with at least 8GB of memory. It may also work on x86 (with a different yum repo below).

Create the instance and SSH into it:

  • sudo yum update
  • sudo reboot
  • sudo yum install git
  • sudo yum install graalvm21-ee-11
  • sudo yum-config-manager --add-repo=http://yum.oracle.com/repo/OracleLinux/OL8/codeready/builder/aarch64
  • sudo yum install graalvm21-ee-11-native-image
  • git clone https://github.com/danfickle/openhtmltopdf-native.git
  • cd openhtmltopdf-native
  • chmod u+x build.sh
  • chmod u+x mvnw
  • ./build.sh
  • cd target
  • ./com.example.app to run, will produce test.pdf.
  • At the moment testing consists of downloading test.pdf with scp and confirming it opens.

Feedback welcome

  • Have you got this working on x86?
  • Have you got it working with a web server?
  • Serverless?

openhtmltopdf-native's People

Contributors

danfickle avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar

openhtmltopdf-native's Issues

Unable to make custom fonts to work

I was able to run this as a servless lambda function on AWS using quarkus native build. It is working great but the only issue I was unable to work it out is the fact that even though the font file is loaded properly it is not rendering on the PDF. This issue only occurs with the native build.

I use the following code to load the files from the resource and it does not throw any message.

builder.useUriResolver((baseUri, uri) -> {
	if (baseUri != null) {
		URL resource = RelatorioHandler.class.getClassLoader().getResource(uri);
		if (resource == null)
			throw new RuntimeException("Resource não encontrado");

		return resource.toString();
	}

	return uri;
});

expected.pdf
actual.pdf

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.