Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LDEV-2968 switch to openhtmlpdf from flying saucer (WIP) #59

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 32 additions & 15 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,20 @@ jobs:
with:
distribution: 'temurin'
java-version: '11'

- name: Cache Maven packages
if: always()
uses: actions/cache@v3
with:
path: ~/.m2
key: lucee-script-runner-maven-cache
- name: Cache Maven packages
uses: actions/cache@v4
with:
path: ~/.m2
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-

- name: Extract version number
id: extract-version
run: |
VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
echo "::set-output name=VERSION::$VERSION"

- name: Cache Lucee files
uses: actions/cache@v4
with:
path: ~/work/_actions/lucee/script-runner/main/lucee-download-cache
key: lucee-downloads

- name: Import GPG key
run: |
echo "$GPG_PRIVATE_KEY" | base64 --decode | gpg --batch --import
Expand All @@ -55,6 +44,8 @@ jobs:
testAdditional: ${{ github.workspace }}/tests
LUCEE_TEST_VERSIONS: ${{ vars.LUCEE_TEST_VERSIONS }}
strategy:
fail-fast: false
max-parallel: 1
matrix:
lucee: ${{ fromJSON(vars.LUCEE_TEST_VERSIONS) }}
services:
Expand All @@ -71,6 +62,18 @@ jobs:
java-version: '11'
distribution: 'adopt'

- name: Cache Lucee files
uses: actions/cache/restore@v4
with:
path: ~/work/_actions/lucee/script-runner/main/lucee-download-cache
key: lucee-downloads

- name: Cache Maven packages
uses: actions/cache/restore@v4
with:
path: ~/.m2/repository
key: lucee-script-runner-maven-cache

- name: Build and Install with Maven
run: |
echo "------- Maven Install -------";
Expand All @@ -79,7 +82,7 @@ jobs:
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: pdf-lex-${{ matrix.lucee.version }}
name: extension-pdf-lex-${{ matrix.lucee.version }}
path: target/*.lex

- name: Checkout Lucee
Expand All @@ -96,14 +99,28 @@ jobs:
luceeVersion: ${{ matrix.lucee.version }}
luceeVersionQuery: ${{ matrix.lucee.query }}
extensionDir: ${{ github.workspace }}/target
extensions: B737ABC4-D43F-4D91-8E8E973E37C40D1B #image
env:
testLabels: pdf
testAdditional: ${{ github.workspace }}/tests
- name: Cache Lucee files
if: always()
uses: actions/cache/save@v4
with:
path: ~/work/_actions/lucee/script-runner/main/lucee-download-cache
key: lucee-downloads

- name: Cache Maven packages
if: always()
uses: actions/cache/save@v4
with:
path: ~/.m2/repository
key: lucee-script-runner-maven-cache

deploy:
runs-on: ubuntu-latest
needs: [build-and-test]
if: always() && needs.build-and-test.result == 'success'
if: ${{ false }} && always() && needs.build-and-test.result == 'success'
steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ va specific
target
target/*
*.DS_Store
/cache
/cache
tests/LDEV4048/test.pdf
28 changes: 5 additions & 23 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
<property name="dist" location="target"/>
<property name="tld" location="source/tld"/>
<property name="fld" location="source/fld"/>
<property name="bundleversion" value="version"/>
<property name="bundlename" value="bundlename"/>
<property name="filename" value="filename"/>

<path id="classpath">
<fileset dir="${lib}">
Expand All @@ -23,17 +26,15 @@
<target name="init">
<!-- Create the time stamp -->
<tstamp/>

<delete dir="${temp}"/>
<delete dir="${dist}"/>

<!-- Create the build directory structure used by compile -->
<mkdir dir="${temp}"/>
<mkdir dir="${build}"/>
<mkdir dir="${dist}/"/>
</target>


<target name="copy" depends="init" description="copy source file to temp" >
<!-- copy the source -->
<copy todir="${temp}">
Expand All @@ -42,7 +43,6 @@
</fileset>
</copy>


<tstamp>
<format property="NOW" pattern="yyyy-MM-dd HH:mm:ss" />
</tstamp>
Expand All @@ -57,34 +57,25 @@ lucee-core-version: "${luceeCoreVersion}"
release-type: ${releaseType}
start-bundles: false
</echo>


</target>



<target name="compile" depends="copy"
description="compile the source " >
<!-- Compile ACF-Infinspan source -->
<javac srcdir="${temp}" target="1.7" destdir="${build}" debug="true" debuglevel="lines,vars,source">
<javac srcdir="${temp}" target="11" source="11" destdir="${build}" debug="true" debuglevel="lines,vars,source">
<classpath refid="classpath" />
</javac>
</target>

<target name="dist" depends="compile"
description="generate the distribution" >



<!-- copy the source -->
<echo>-------------------------</echo>
<copy todir="${build}">
<fileset dir="${src}">
<include name="**/*.jar"/>
</fileset>
</copy>


<!-- Put everything in ${build} into .jar file -->
<jar
jarfile="${dist}/extension/jars/${bundlename}-${bundleversion}.jar" basedir="${build}" manifest="${src}/META-INF/MANIFEST.MF">
Expand All @@ -96,7 +87,6 @@ start-bundles: false
</manifest>
</jar>


<!-- copy the tlds necessary -->
<copy file="${tld}/tag.tldx" tofile="${dist}/extension/tlds/pdftag.tldx" />
<replaceregexp
Expand All @@ -110,7 +100,6 @@ start-bundles: false
replace="${bundleversion}"
byline="true"/>


<!-- copy the flds necessary -->
<copy file="${fld}/function.fld" tofile="${dist}/extension/flds/pdffunction.fld" />
<replaceregexp
Expand All @@ -124,10 +113,6 @@ start-bundles: false
replace="${bundleversion}"
byline="true"/>





<!-- copy the context necessary
<copy todir="${dist}/extension/webcontexts">
<fileset dir="${context}">
Expand All @@ -154,13 +139,10 @@ start-bundles: false
</fileset>
</copy>



<!-- Zip everything -->
<zip destfile="${dist}/${filename}-${bundleversion}.lex">
<zipfileset dir="${dist}/extension"/>
</zip>

</target>

<target name="clean" depends="dist" description="clean up" >
Expand Down
67 changes: 61 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.lucee</groupId>
<artifactId>pdf-extension</artifactId>
<version>1.2.0.11-SNAPSHOT</version>
<version>2.0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>PDF Extension</name>

Expand All @@ -21,9 +21,64 @@
<release.url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</release.url>
<snapshot.url>https://oss.sonatype.org/content/repositories/snapshots/</snapshot.url>
</properties>



<!-- not used, but good for version reporting! -->
<dependencies>
<dependency>
<groupId>io.github.openhtmltopdf</groupId>
<artifactId>openhtmltopdf-core</artifactId>
<version>1.1.24</version>
</dependency>
<dependency>
<groupId>io.github.openhtmltopdf</groupId>
<artifactId>openhtmltopdf-pdfbox</artifactId>
<version>1.1.24</version>
</dependency>
<dependency>
<groupId>io.github.openhtmltopdf</groupId>
<artifactId>openhtmltopdf-java2d</artifactId>
<version>1.1.24</version>
</dependency>
<dependency>
<groupId>org.apache.pdfbox</groupId>
<artifactId>pdfbox</artifactId>
<version>3.0.3</version>
</dependency>
<dependency>
<groupId>org.apache.pdfbox</groupId>
<artifactId>pdfbox-io</artifactId>
<version>3.0.3</version>
</dependency>
<dependency>
<groupId>org.apache.pdfbox</groupId>
<artifactId>xmpbox</artifactId>
<version>3.0.3</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.3.2</version>
</dependency>
<dependency>
<groupId>de.rototor.pdfbox</groupId>
<artifactId>graphics2d</artifactId>
<version>3.0.1</version><!-- waiting on OSGI PR https://github.com/rototor/pdfbox-graphics2d/pull/61 -->
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcutil-jdk18on</artifactId>
<version>1.80</version>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcpkix-jdk18on</artifactId>
<version>1.80</version>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk18on</artifactId>
<version>1.80</version>
</dependency>
</dependencies>
<scm>
<url>https://github.com/lucee/extension-pdf</url>
<connection>scm:git:git://github.com/lucee/extension-pdf.git</connection>
Expand Down Expand Up @@ -121,7 +176,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<version>3.1.0</version>
<executions>
<execution>
<phase>package</phase>
Expand All @@ -130,7 +185,7 @@
</goals>
<configuration>
<target>
<ant antfile="build.xml" target="clean">
<ant antfile="build.xml" target="clean" inheritAll="true">
<property name="bundleversion" value="${project.version}"/>
<property name="bundlename" value="${bundlename}"/>
<property name="filename" value="${project.artifactId}"/>
Expand Down
Binary file added source/java/libs/bcmail-jdk18on-1.80.jar
Binary file not shown.
Binary file added source/java/libs/bcpkix-jdk18on-1.80.jar
Binary file not shown.
Binary file added source/java/libs/bcprov-jdk18on-1.80.jar
Binary file not shown.
Binary file added source/java/libs/bcutil-jdk18on-1.80.jar
Binary file not shown.
Binary file added source/java/libs/commons-logging-1.3.2.jar
Binary file not shown.
Binary file not shown.
Binary file added source/java/libs/graphics2d-3.0.3-SNAPSHOT.jar
Binary file not shown.
Binary file added source/java/libs/openhtmltopdf-core-1.1.24.jar
Binary file not shown.
Binary file added source/java/libs/openhtmltopdf-java2d-1.1.24.jar
Binary file not shown.
Binary file added source/java/libs/openhtmltopdf-pdfbox-1.1.24.jar
Binary file not shown.
Binary file not shown.
Binary file modified source/java/libs/org.lucee.itext-2.1.7.jar
Binary file not shown.
Binary file removed source/java/libs/org.lucee.pdfbox-3.0.0.RC101.jar
Binary file not shown.
Binary file not shown.
Binary file added source/java/libs/pdfbox-3.0.3.jar
Binary file not shown.
Binary file added source/java/libs/pdfbox-io-3.0.3.jar
Binary file not shown.
Binary file added source/java/libs/xmpbox-3.0.3.jar
Binary file not shown.
19 changes: 14 additions & 5 deletions source/java/src/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,17 @@ Require-Bundle: bouncycastle.mail;bundle-version=1.38.0,
bouncycastle.prov;bundle-version=1.38.0,
bouncycastle.tsp;bundle-version=1.38.0,
org.lucee.itext;bundle-version=2.1.7,
org.xhtmlrenderer.flying.saucer.core;bundle-version=9.1.20,
org.lucee.flyingSaucerPDF;bundle-version=9.1.20,
org.lucee.pdfbox;bundle-version=3.0.0.RC101,
org.lucee.pdfbox-fontbox;bundle-version=3.0.0.RC1,
tagsoup;bundle-version=1.2.1.0002L
tagsoup;bundle-version=1.2.1.0002L,
io.github.openhtmltopdf.core;bundle-version=1.1.24,
io.github.openhtmltopdf.java2d;bundle-version=1.1.24,
io.github.openhtmltopdf.pdfbox;bundle-version=1.1.24,
org.apache.pdfbox;bundle-version=3.0.3,
org.apache.pdfbox.fontbox;bundle-version=3.0.3,
org.apache.pdfbox.io;bundle-version=3.0.3,
bcmail;bundle-version=1.80.0,
bcprov;bundle-version=1.80.0,
bcutil;bundle-version=1.80.0,
bcpkix;bundle-version=1.80.0,
org.apache.commons.commons-logging;bundle-version=1.3.2,
de.rototor.pdfbox.graphics2d;bundle-version=3.0.3.SNAPSHOT,
org.apache.pdfbox.xmpbox;bundle-version=3.0.3
16 changes: 9 additions & 7 deletions source/java/src/org/lucee/extension/fs/Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,25 @@
import java.io.ByteArrayOutputStream;
import java.io.FileOutputStream;

import org.xhtmlrenderer.pdf.ITextRenderer;
import com.openhtmltopdf.pdfboxout.PdfRendererBuilder;

public class Test {

public static void main(String[] args) throws Exception {

ITextRenderer renderer = new ITextRenderer();
PdfRendererBuilder builder = new PdfRendererBuilder();

// if you have html source in hand, use it to generate document object
renderer.setDocumentFromString("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ "<html xmlns=\"http://www.w3.org/1999/xhtml\" xmlns:html=\"http://www.w3.org/1999/xhtml\"><body><h1>Title</h1>\n" + "This is the text\n" + "</body></html>");
renderer.layout();
String html = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ "<html xmlns=\"http://www.w3.org/1999/xhtml\" xmlns:html=\"http://www.w3.org/1999/xhtml\"><body><h1>Title</h1>\n" + "This is the text\n" + "</body></html>";

String fileNameWithPath = "/Users/mic/Tmp3/PDF-FromHtmlString.pdf";
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
FileOutputStream fos = new FileOutputStream(fileNameWithPath);
renderer.createPDF(baos);

builder.withHtmlContent(html, null);
builder.toStream(outputStream);
builder.run();
fos.close();

System.out.println("File 2: '" + fileNameWithPath + "' created.");
Expand Down
Loading
Loading