Skip to content

Commit

Permalink
PD4ML
Browse files Browse the repository at this point in the history
  • Loading branch information
Federico committed Feb 4, 2018
1 parent 3cb228f commit 85485fc
Show file tree
Hide file tree
Showing 8 changed files with 306 additions and 172 deletions.
105 changes: 64 additions & 41 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,47 +1,70 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.javastaff</groupId>
<artifactId>html2pdf</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<groupId>com.javastaff</groupId>
<artifactId>html2pdf</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>

<name>html2pdf</name>
<name>html2pdf</name>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
<!-- FlyingSaucer -->
<dependency>
<groupId>org.xhtmlrenderer</groupId>
<artifactId>flying-saucer-pdf</artifactId>
<version>9.1.11</version>
</dependency>
<dependency>
<groupId>org.xhtmlrenderer</groupId>
<artifactId>flying-saucer-core</artifactId>
<version>9.1.11</version>
</dependency>
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.11.2</version>
</dependency>
<!-- iText -->
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>itextpdf</artifactId>
<version>5.5.12</version>
</dependency>
<dependency>
<groupId>com.itextpdf.tool</groupId>
<artifactId>xmlworker</artifactId>
<version>5.5.12</version>
</dependency>


</dependencies>
<dependencies>
<!-- FlyingSaucer -->
<dependency>
<groupId>org.xhtmlrenderer</groupId>
<artifactId>flying-saucer-pdf</artifactId>
<version>9.1.11</version>
</dependency>
<dependency>
<groupId>org.xhtmlrenderer</groupId>
<artifactId>flying-saucer-core</artifactId>
<version>9.1.11</version>
</dependency>
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.11.2</version>
</dependency>
<!-- iText -->
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>itextpdf</artifactId>
<version>5.5.12</version>
</dependency>
<dependency>
<groupId>com.itextpdf.tool</groupId>
<artifactId>xmlworker</artifactId>
<version>5.5.12</version>
</dependency>
<!-- PD4ML -->
<dependency>
<groupId>org.zefer.pd4ml</groupId>
<artifactId>pd4ml</artifactId>
<version>370fx2</version>
</dependency>
<dependency>
<groupId>org.zefer.pd4ml</groupId>
<artifactId>ss_css2</artifactId>
<version>370fx2</version>
</dependency>
<!-- JODConverter -->
<dependency>
<groupId>org.jodconverter</groupId>
<artifactId>jodconverter-online</artifactId>
<version>4.1.0</version>
</dependency>
</dependencies>

<repositories>
<repository>
<id>pd4ml-repo</id>
<name>your custom repo</name>
<url>http://maven.scandilabs.com/repository</url>
</repository>
</repositories>
</project>
73 changes: 0 additions & 73 deletions src/main/java/com/javastaff/html2pdf/FlyingSaucer.java

This file was deleted.

52 changes: 52 additions & 0 deletions src/main/java/com/javastaff/html2pdf/FlyingSaucerTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package com.javastaff.html2pdf;

import com.lowagie.text.DocumentException;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.xhtmlrenderer.pdf.ITextRenderer;

/**
* Test HTML 2 PDf using FlyingSaucer
*/
public class FlyingSaucerTest {
public static void main(String a[]) throws IOException, FileNotFoundException, DocumentException, Exception {
pdfTest("https://raw.githubusercontent.com/fpaparoni/html2pdf/master/html/simple.html","simple-flyingsaucer.pdf");
pdfTest("https://raw.githubusercontent.com/fpaparoni/html2pdf/master/html/standard.html","standard-flyingsaucer.pdf");
imageCSSPDFTest("https://raw.githubusercontent.com/fpaparoni/html2pdf/master/html/css.html",
"https://raw.githubusercontent.com/fpaparoni/html2pdf/master/html/",
"image-css-flyingsaucer.pdf");
}

private static void pdfTest(String url,String fileOut) throws FileNotFoundException, DocumentException, IOException {
ITextRenderer renderer = new ITextRenderer();

renderer.setDocument(url);
renderer.layout();

FileOutputStream fos = new FileOutputStream( fileOut );
renderer.createPDF( fos );
fos.close();

System.out.println( fileOut+" created." );
}

private static void imageCSSPDFTest(String url,String baseUrl,String fileOut) throws MalformedURLException, IOException, DocumentException, Exception {
ITextRenderer renderer = new ITextRenderer();
Document d = Jsoup.parse(new URL(url),5000);
d.outputSettings().syntax(Document.OutputSettings.Syntax.xml);

renderer.setDocumentFromString(d.outerHtml(),baseUrl);
renderer.layout();

FileOutputStream fos = new FileOutputStream( fileOut );
renderer.createPDF( fos );
fos.close();

System.out.println( fileOut+" created." );
}
}
58 changes: 0 additions & 58 deletions src/main/java/com/javastaff/html2pdf/IText.java

This file was deleted.

Loading

0 comments on commit 85485fc

Please sign in to comment.