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

NA #1208

Closed
wants to merge 7 commits into from
Closed

NA #1208

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
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Some of the features of OpenPDF include:
* Table Support: The library facilitates the creation of tables in PDF documents.
* Encryption: You can encrypt PDF documents for security purposes.
* Page Layout: OpenPDF allows you to set the page size, orientation, and other layout properties.
* Convert PDF files to images using [openpdf-pdfrenderer](openpdf-pdfrenderer).

## Use OpenPDF as Maven dependency

Expand All @@ -69,6 +70,8 @@ Add this to your pom.xml file to use the latest version of OpenPDF:

You can find also a nice explanation of these licenses under https://itsfoss.com/open-source-licenses-explained/

openpdf-pdfrenderer is licensed with GNU Lesser General Public License (LGPL), Version 2.1 only.

We want OpenPDF to consist of source code which is consistently licensed with the LGPL and MPL
licences only. This also means that any new contributions to the project must have a dual LGPL and
MPL license only.
Expand Down
7 changes: 7 additions & 0 deletions changelogs/2.0.4.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# 2.0.4

## Changes

* Add openpdf-pdfrenderer for exporting PDF files as images. It is a fork of https://github.com/katjas/PDFrenderer
* Add RegionPdfTextExtractor for extracting text on a specific part of a page in a PDF document.
* Add test case for LibrePDF#1199 r = 5 encryption.
170 changes: 170 additions & 0 deletions openpdf-pdfrenderer/LICENSE.txt

Large diffs are not rendered by default.

99 changes: 99 additions & 0 deletions openpdf-pdfrenderer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
openpdf-pdfrenderer
===================

PDF to Image renderer for OpenPDF.

Because every fine PDF library should be able to create a PNG image from a PDF page.

License: GNU Lesser General Public License

---

This is a fork of https://github.com/katjas/PDFrenderer which is based on [pdf-renderer](http://java.net/projects/pdf-renderer) (covered by the LGPL-2.1 license) for improvement purposes.

The principal objective of the fork is to improve the original PDF renderer. The original version is able to handle most of the PDF 1.4 features, but has several bugs and missing functionality.



To do:
------
* some colours are displayed incorrect, there seem to be open issues regarding colour space handling
* some fonts can't be rendered and are replaced with built in fonts

Check notice on line 21 in openpdf-pdfrenderer/README.md

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

openpdf-pdfrenderer/README.md#L21

Expected: 0 or 2; Actual: 1
* embedded Type0 font with a CIDType0 font is not supported correctly. Currently there is a hack in the code to fall back to the built in fonts in this case.
* try to improve support of auto adjust stroke and overprint mode - the data is read but not really handled correctly.

Done:
-----
* support for widget annotation containing digital signature
* support function type 4 rendering (subset of the PostScript language, specification taken from http://www.adobe.com/devnet/acrobat/pdfs/adobe_supplement_iso32000.pdf)
* support link annotations for being able to render links
* rough support of stamp and freetext annotations
* handle alternate colour spaces (colour space plus a function to be applied on the colour values)
* fixes transparency issues / transparent masked images (even though transparency is still not completely supported)
* corrected handling of overlapping shapes
* better support Type0 fonts that use embedded CID fonts
* jbig2 image format decoded with (improved) "jpedal" API
* DeviceCMY / DeviceRGB colour spaces are working now, but some PDFs are still displayed in wrong format.
* Improved reading of CMYK images. Some colours are still displayed wrong. (using the ch.randelshofer.media.jpeg.JPEGImageIO API)
* Improved run length decoding (corrected reading of buffer)
* fixed compression issues
* fixed size of outline fonts
* fixed several exceptions
* Fixed various font encoding problems (Flex in Type 1, wrong stemhints in Type 1C and inverted presentation of Type 3)
* fixed rotation of text (http://java.net/jira/browse/PDF_RENDERER-91)
* JPEG decoding with imageio
* Work-around lack of YCCK decoding support in standard JRE image readers and thus allow CMYK jpeg images without using 3rd party image readers (e.g., JAI)
* Employ local TTF files if available instead of using the built-ins as substitutes. Scanning of available TTFs will take some time on the first request for an unavailable TTF. This behaviour can be disabled by setting the system property PDFRenderer.avoidExternalTtf to true. The PDFRenderer.fontSearchPath system property can be used to alter the search path, though Windows and Mac OS X defaults should hopefully be sensible.
* Added TIFF Type 2 Predictor for decoding
* use built in font as workaround for MMType1 fonts instead of throwing an exception
* introduced configuration options for improving the memory usage when rendering PDFs with large (e.g. scanned) images
* improved parsing of SMask images
* modified parsing of paths, some closures were missing
* added some debugging
* Add option to inject exception handling - e.g. for redirecting the stack trace to a log file
* Add SymbolSetEncoding

Usage / Example
-------

// example class for displaying a PDF file
```java
public class PDFDisplay extends JComponent{

// byte array containing the PDF file content
private byte[] bytes = null;


// some more code

@Override
public void paintComponent(Graphics g) {
int pageindex = 1;
PDFFile pdfFile = new PDFFile(ByteBuffer.wrap(this.bytes));
PDFPage page = pdfFile.getPage(pageIndex);
Paper paper = new Paper();
int formatOrientation = page.getAspectRatio() > 1 ? PageFormat.LANDSCAPE
: PageFormat.PORTRAIT;
if(formatOrientation == PageFormat.LANDSCAPE) {
paper.setSize(page.getHeight(), page.getWidth());
}else {
paper.setSize(page.getWidth(), page.getHeight());
}
PageFormat pageFormat = new PageFormat();
pageFormat.setPaper(paper);
pageFormat.setOrientation(formatOrientation);

Graphics2D g2d = (Graphics2D)g.create();
Rectangle imgbounds = new Rectangle(0, 0, (int)pageFormat.getWidth(),
(int)pageFormat.getHeight());
PDFRenderer renderer = new PDFRenderer(page, g2d, imgbounds, null, Color.WHITE);
try {
this.page.waitForFinish();
}
catch (InterruptedException e) {
// some exception handling
}
renderer.run();
}
}
```
48 changes: 48 additions & 0 deletions openpdf-pdfrenderer/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<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/maven-v4_0_0.xsd">

<parent>
<groupId>com.github.librepdf</groupId>
<artifactId>openpdf-parent</artifactId>
<version>2.0.4-SNAPSHOT</version>
</parent>

<modelVersion>4.0.0</modelVersion>
<artifactId>openpdf-pdfrenderer</artifactId>
<name>openpdf-pdfrenderer</name>

<licenses>
<license>
<name>Lesser General Public License (LGPL)</name>
<url>http://www.gnu.org/copyleft/lesser.html</url>
</license>
</licenses>

Check notice on line 19 in openpdf-pdfrenderer/pom.xml

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

openpdf-pdfrenderer/pom.xml#L19

Line contains a tab character.
<description>PDF renderer implementation supporting the subset of PDF 1.4 specification.</description>


<dependencies>
<dependency>
<groupId>com.github.librepdf</groupId>
<artifactId>openpdf</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>

Check notice on line 29 in openpdf-pdfrenderer/pom.xml

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

openpdf-pdfrenderer/pom.xml#L29

Line contains a tab character.
<!-- Test Deps -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

</project>
Loading
Loading