Skip to content

Commit 05f303d

Browse files
Add openpdf-renderer (#1357)
1 parent 195e79e commit 05f303d

File tree

204 files changed

+41483
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

204 files changed

+41483
-0
lines changed

openpdf-renderer/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/bin/
2+
/build/

openpdf-renderer/LICENSE.txt

Lines changed: 170 additions & 0 deletions
Large diffs are not rendered by default.

openpdf-renderer/README.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
OpenPDF-renderer
2+
============
3+
4+
OpenPDF-renderer is a Java library for rendering PDF files.
5+
6+
7+
Usage
8+
=====
9+
10+
// example class for displaying a PDF file
11+
```java
12+
public class PDFDisplay extends JComponent{
13+
14+
// byte array containing the PDF file content
15+
private byte[] bytes = null;
16+
17+
18+
// some more code
19+
20+
@Override
21+
public void paintComponent(Graphics g) {
22+
int pageindex = 1;
23+
PDFFile pdfFile = new PDFFile(ByteBuffer.wrap(this.bytes));
24+
PDFPage page = pdfFile.getPage(pageIndex);
25+
Paper paper = new Paper();
26+
int formatOrientation = page.getAspectRatio() > 1 ? PageFormat.LANDSCAPE
27+
: PageFormat.PORTRAIT;
28+
if(formatOrientation == PageFormat.LANDSCAPE) {
29+
paper.setSize(page.getHeight(), page.getWidth());
30+
}else {
31+
paper.setSize(page.getWidth(), page.getHeight());
32+
}
33+
PageFormat pageFormat = new PageFormat();
34+
pageFormat.setPaper(paper);
35+
pageFormat.setOrientation(formatOrientation);
36+
37+
Graphics2D g2d = (Graphics2D)g.create();
38+
Rectangle imgbounds = new Rectangle(0, 0, (int)pageFormat.getWidth(),
39+
(int)pageFormat.getHeight());
40+
PDFRenderer renderer = new PDFRenderer(page, g2d, imgbounds, null, Color.WHITE);
41+
try {
42+
this.page.waitForFinish();
43+
}
44+
catch (InterruptedException e) {
45+
// some exception handling
46+
}
47+
renderer.run();
48+
}
49+
}
50+
```

openpdf-renderer/pom.xml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
5+
<parent>
6+
<groupId>com.github.librepdf</groupId>
7+
<artifactId>openpdf-parent</artifactId>
8+
<version>2.1.1-SNAPSHOT</version>
9+
</parent>
10+
11+
<artifactId>openpdf-renderer</artifactId>
12+
13+
<packaging>jar</packaging>
14+
<name>OpenPDF Renderer</name>
15+
16+
<licenses>
17+
<license>
18+
<name>Lesser General Public License (LGPL)</name>
19+
<url>http://www.gnu.org/copyleft/lesser.html</url>
20+
</license>
21+
</licenses>
22+
<description>PDF renderer implementation supporting the subset of PDF 1.4 specification.</description>
23+
24+
<build>
25+
<sourceDirectory>src</sourceDirectory>
26+
<plugins>
27+
<plugin>
28+
<groupId>org.codehaus.mojo</groupId>
29+
<artifactId>build-helper-maven-plugin</artifactId>
30+
<version>3.6.1</version>
31+
<executions>
32+
<execution>
33+
<phase>generate-resources</phase>
34+
<goals>
35+
<goal>add-resource</goal>
36+
</goals>
37+
<configuration>
38+
<resources>
39+
<resource>
40+
<directory>${project.basedir}/stdclasses</directory>
41+
</resource>
42+
<resource>
43+
<directory>${project.basedir}/src</directory>
44+
<excludes>
45+
<exclude>**/*.java</exclude>
46+
</excludes>
47+
</resource>
48+
</resources>
49+
</configuration>
50+
</execution>
51+
</executions>
52+
</plugin>
53+
54+
<plugin>
55+
<groupId>org.apache.maven.plugins</groupId>
56+
<artifactId>maven-compiler-plugin</artifactId>
57+
<version>3.14.0</version>
58+
<configuration>
59+
<source>${java.version}</source>
60+
<target>${java.version}</target>
61+
</configuration>
62+
</plugin>
63+
</plugins>
64+
</build>
65+
66+
</project>

0 commit comments

Comments
 (0)