diff --git a/gradle.properties b/gradle.properties index 08f30ec..bba1b0a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ group = org.xbib.graphics name = graphics -version = 5.2.1 +version = 5.3.0 org.gradle.warning.mode = ALL diff --git a/graphics-ghostscript/src/main/java/org/xbib/graphics/ghostscript/FontAnalysisItem.java b/graphics-ghostscript/src/main/java/org/xbib/graphics/ghostscript/FontAnalysisItem.java deleted file mode 100644 index 6adafdb..0000000 --- a/graphics-ghostscript/src/main/java/org/xbib/graphics/ghostscript/FontAnalysisItem.java +++ /dev/null @@ -1,50 +0,0 @@ -package org.xbib.graphics.ghostscript; - -public class FontAnalysisItem { - - private String name; - - private boolean embedded; - - private boolean subSet; - - public FontAnalysisItem() { - } - - @Override - public String toString() { - String embeddedString = "NOT_EMBEDDED"; - if (embedded) { - embeddedString = "EMBEDDED"; - } - String setString = "FULL_SET"; - if (subSet) { - setString = "SUB_SET"; - } - return name + ": " + embeddedString + " " + setString; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public boolean isEmbedded() { - return embedded; - } - - public void setEmbedded(boolean embedded) { - this.embedded = embedded; - } - - public boolean isSubSet() { - return subSet; - } - - public void setSubSet(boolean subSet) { - this.subSet = subSet; - } -} diff --git a/graphics-ghostscript/src/main/java/org/xbib/graphics/ghostscript/FontAnalyzer.java b/graphics-ghostscript/src/main/java/org/xbib/graphics/ghostscript/FontAnalyzer.java deleted file mode 100644 index d8b5952..0000000 --- a/graphics-ghostscript/src/main/java/org/xbib/graphics/ghostscript/FontAnalyzer.java +++ /dev/null @@ -1,61 +0,0 @@ -package org.xbib.graphics.ghostscript; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.nio.file.Path; -import java.util.ArrayList; -import java.util.List; - -/** - * Font analyzer. - * Analyze fonts used in a document using {@code -fonta}. - * We use Pdfbox for font analysis, so this is not tested and not used. - */ -public class FontAnalyzer { - - public FontAnalyzer() { - } - - public synchronized List analyze(Path path) throws IOException { - String[] gsArgs = new String[]{"-fonta", - "-dQUIET", "-dNOPAUSE", "-dBATCH", "-dNODISPLAY", - "-sFile=" + path.toAbsolutePath(), - "-sOutputFile=%stdout", - "-f", "-"}; - try (Ghostscript gs = new Ghostscript(); - InputStream is = this.getClass().getClassLoader().getResourceAsStream("script/AnalyzePDFFonts.ps"); - ByteArrayOutputStream baos = new ByteArrayOutputStream()) { - gs.setStdIn(is); - gs.setStdOut(baos); - gs.run(gsArgs); - List result = new ArrayList<>(); - String s = baos.toString(); - String[] lines = s.split("\n"); - boolean inResults = false; - for (String line : lines) { - if (line.equals("---")) { - inResults = true; - } else if (inResults) { - String[] columns = line.split(" "); - if (columns.length == 2) { - FontAnalysisItem font = new FontAnalysisItem(); - String name = columns[0]; - String[] nameParts = name.split("\\+"); - if (nameParts.length > 1) { - name = nameParts[1]; - font.setSubSet(true); - } - font.setName(name); - font.setEmbedded(false); - if (columns[1].equals("EM") || columns[1].equals("SU")) { - font.setEmbedded(true); - } - result.add(font); - } - } - } - return result; - } - } -} diff --git a/graphics-ghostscript/src/main/resources/darwin/libgs.9.25.dylib b/graphics-ghostscript/src/main/resources/darwin/libgs.9.25.dylib deleted file mode 100755 index cce8303..0000000 Binary files a/graphics-ghostscript/src/main/resources/darwin/libgs.9.25.dylib and /dev/null differ diff --git a/graphics-ghostscript/src/main/resources/fonts/DejaVuSans-Bold.ttf b/graphics-ghostscript/src/main/resources/fonts/DejaVuSans-Bold.ttf deleted file mode 100644 index f3ed1f1..0000000 Binary files a/graphics-ghostscript/src/main/resources/fonts/DejaVuSans-Bold.ttf and /dev/null differ diff --git a/graphics-ghostscript/src/main/resources/fonts/DejaVuSans-BoldOblique.ttf b/graphics-ghostscript/src/main/resources/fonts/DejaVuSans-BoldOblique.ttf deleted file mode 100644 index 2ae2ab8..0000000 Binary files a/graphics-ghostscript/src/main/resources/fonts/DejaVuSans-BoldOblique.ttf and /dev/null differ diff --git a/graphics-ghostscript/src/main/resources/fonts/DejaVuSans-ExtraLight.ttf b/graphics-ghostscript/src/main/resources/fonts/DejaVuSans-ExtraLight.ttf deleted file mode 100644 index 79f0ce0..0000000 Binary files a/graphics-ghostscript/src/main/resources/fonts/DejaVuSans-ExtraLight.ttf and /dev/null differ diff --git a/graphics-ghostscript/src/main/resources/fonts/DejaVuSans-Oblique.ttf b/graphics-ghostscript/src/main/resources/fonts/DejaVuSans-Oblique.ttf deleted file mode 100644 index 778b2c5..0000000 Binary files a/graphics-ghostscript/src/main/resources/fonts/DejaVuSans-Oblique.ttf and /dev/null differ diff --git a/graphics-ghostscript/src/main/resources/fonts/DejaVuSans.ttf b/graphics-ghostscript/src/main/resources/fonts/DejaVuSans.ttf deleted file mode 100644 index e0c72c9..0000000 Binary files a/graphics-ghostscript/src/main/resources/fonts/DejaVuSans.ttf and /dev/null differ diff --git a/graphics-ghostscript/src/main/resources/fonts/DejaVuSansCondensed-Bold.ttf b/graphics-ghostscript/src/main/resources/fonts/DejaVuSansCondensed-Bold.ttf deleted file mode 100644 index cb10039..0000000 Binary files a/graphics-ghostscript/src/main/resources/fonts/DejaVuSansCondensed-Bold.ttf and /dev/null differ diff --git a/graphics-ghostscript/src/main/resources/fonts/DejaVuSansCondensed-BoldOblique.ttf b/graphics-ghostscript/src/main/resources/fonts/DejaVuSansCondensed-BoldOblique.ttf deleted file mode 100644 index b2adca0..0000000 Binary files a/graphics-ghostscript/src/main/resources/fonts/DejaVuSansCondensed-BoldOblique.ttf and /dev/null differ diff --git a/graphics-ghostscript/src/main/resources/fonts/DejaVuSansCondensed-Oblique.ttf b/graphics-ghostscript/src/main/resources/fonts/DejaVuSansCondensed-Oblique.ttf deleted file mode 100644 index ef102eb..0000000 Binary files a/graphics-ghostscript/src/main/resources/fonts/DejaVuSansCondensed-Oblique.ttf and /dev/null differ diff --git a/graphics-ghostscript/src/main/resources/fonts/DejaVuSansCondensed.ttf b/graphics-ghostscript/src/main/resources/fonts/DejaVuSansCondensed.ttf deleted file mode 100644 index 01085ad..0000000 Binary files a/graphics-ghostscript/src/main/resources/fonts/DejaVuSansCondensed.ttf and /dev/null differ diff --git a/graphics-ghostscript/src/main/resources/fonts/DejaVuSansMono-Bold.ttf b/graphics-ghostscript/src/main/resources/fonts/DejaVuSansMono-Bold.ttf deleted file mode 100644 index fdee16f..0000000 Binary files a/graphics-ghostscript/src/main/resources/fonts/DejaVuSansMono-Bold.ttf and /dev/null differ diff --git a/graphics-ghostscript/src/main/resources/fonts/DejaVuSansMono-BoldOblique.ttf b/graphics-ghostscript/src/main/resources/fonts/DejaVuSansMono-BoldOblique.ttf deleted file mode 100644 index 139ba41..0000000 Binary files a/graphics-ghostscript/src/main/resources/fonts/DejaVuSansMono-BoldOblique.ttf and /dev/null differ diff --git a/graphics-ghostscript/src/main/resources/fonts/DejaVuSansMono-Oblique.ttf b/graphics-ghostscript/src/main/resources/fonts/DejaVuSansMono-Oblique.ttf deleted file mode 100644 index 8ae8b1c..0000000 Binary files a/graphics-ghostscript/src/main/resources/fonts/DejaVuSansMono-Oblique.ttf and /dev/null differ diff --git a/graphics-ghostscript/src/main/resources/fonts/DejaVuSansMono.ttf b/graphics-ghostscript/src/main/resources/fonts/DejaVuSansMono.ttf deleted file mode 100644 index 734a08c..0000000 Binary files a/graphics-ghostscript/src/main/resources/fonts/DejaVuSansMono.ttf and /dev/null differ diff --git a/graphics-ghostscript/src/main/resources/fonts/DejaVuSerif-Bold.ttf b/graphics-ghostscript/src/main/resources/fonts/DejaVuSerif-Bold.ttf deleted file mode 100644 index 3a604fb..0000000 Binary files a/graphics-ghostscript/src/main/resources/fonts/DejaVuSerif-Bold.ttf and /dev/null differ diff --git a/graphics-ghostscript/src/main/resources/fonts/DejaVuSerif-BoldOblique.ttf b/graphics-ghostscript/src/main/resources/fonts/DejaVuSerif-BoldOblique.ttf deleted file mode 100644 index 458a922..0000000 Binary files a/graphics-ghostscript/src/main/resources/fonts/DejaVuSerif-BoldOblique.ttf and /dev/null differ diff --git a/graphics-ghostscript/src/main/resources/fonts/DejaVuSerif-Oblique.ttf b/graphics-ghostscript/src/main/resources/fonts/DejaVuSerif-Oblique.ttf deleted file mode 100644 index 3d73245..0000000 Binary files a/graphics-ghostscript/src/main/resources/fonts/DejaVuSerif-Oblique.ttf and /dev/null differ diff --git a/graphics-ghostscript/src/main/resources/fonts/DejaVuSerif.ttf b/graphics-ghostscript/src/main/resources/fonts/DejaVuSerif.ttf deleted file mode 100644 index 5f476c4..0000000 Binary files a/graphics-ghostscript/src/main/resources/fonts/DejaVuSerif.ttf and /dev/null differ diff --git a/graphics-ghostscript/src/main/resources/fonts/DejaVuSerifCondensed-Bold.ttf b/graphics-ghostscript/src/main/resources/fonts/DejaVuSerifCondensed-Bold.ttf deleted file mode 100644 index 21baa55..0000000 Binary files a/graphics-ghostscript/src/main/resources/fonts/DejaVuSerifCondensed-Bold.ttf and /dev/null differ diff --git a/graphics-ghostscript/src/main/resources/fonts/DejaVuSerifCondensed-BoldOblique.ttf b/graphics-ghostscript/src/main/resources/fonts/DejaVuSerifCondensed-BoldOblique.ttf deleted file mode 100644 index 8562838..0000000 Binary files a/graphics-ghostscript/src/main/resources/fonts/DejaVuSerifCondensed-BoldOblique.ttf and /dev/null differ diff --git a/graphics-ghostscript/src/main/resources/fonts/DejaVuSerifCondensed-Oblique.ttf b/graphics-ghostscript/src/main/resources/fonts/DejaVuSerifCondensed-Oblique.ttf deleted file mode 100644 index ce634fa..0000000 Binary files a/graphics-ghostscript/src/main/resources/fonts/DejaVuSerifCondensed-Oblique.ttf and /dev/null differ diff --git a/graphics-ghostscript/src/main/resources/fonts/DejaVuSerifCondensed.ttf b/graphics-ghostscript/src/main/resources/fonts/DejaVuSerifCondensed.ttf deleted file mode 100644 index 05f5c54..0000000 Binary files a/graphics-ghostscript/src/main/resources/fonts/DejaVuSerifCondensed.ttf and /dev/null differ diff --git a/graphics-ghostscript/src/main/resources/fonts/NotoKufiArabic-Regular.ttf b/graphics-ghostscript/src/main/resources/fonts/NotoKufiArabic-Regular.ttf deleted file mode 100644 index 3c9947b..0000000 Binary files a/graphics-ghostscript/src/main/resources/fonts/NotoKufiArabic-Regular.ttf and /dev/null differ diff --git a/graphics-ghostscript/src/main/resources/fonts/NotoNaskhArabic-Regular.ttf b/graphics-ghostscript/src/main/resources/fonts/NotoNaskhArabic-Regular.ttf deleted file mode 100644 index 8658bce..0000000 Binary files a/graphics-ghostscript/src/main/resources/fonts/NotoNaskhArabic-Regular.ttf and /dev/null differ diff --git a/graphics-ghostscript/src/main/resources/fonts/NotoSans-Bold.ttf b/graphics-ghostscript/src/main/resources/fonts/NotoSans-Bold.ttf deleted file mode 100644 index ab4cdee..0000000 Binary files a/graphics-ghostscript/src/main/resources/fonts/NotoSans-Bold.ttf and /dev/null differ diff --git a/graphics-ghostscript/src/main/resources/fonts/NotoSans-Regular.ttf b/graphics-ghostscript/src/main/resources/fonts/NotoSans-Regular.ttf deleted file mode 100644 index ebd7703..0000000 Binary files a/graphics-ghostscript/src/main/resources/fonts/NotoSans-Regular.ttf and /dev/null differ diff --git a/graphics-ghostscript/src/main/resources/fonts/NotoSansCJKtc-Bold.ttf b/graphics-ghostscript/src/main/resources/fonts/NotoSansCJKtc-Bold.ttf deleted file mode 100644 index cc8729b..0000000 Binary files a/graphics-ghostscript/src/main/resources/fonts/NotoSansCJKtc-Bold.ttf and /dev/null differ diff --git a/graphics-ghostscript/src/main/resources/fonts/NotoSansCJKtc-Regular.ttf b/graphics-ghostscript/src/main/resources/fonts/NotoSansCJKtc-Regular.ttf deleted file mode 100644 index 0e76702..0000000 Binary files a/graphics-ghostscript/src/main/resources/fonts/NotoSansCJKtc-Regular.ttf and /dev/null differ diff --git a/graphics-ghostscript/src/main/resources/fonts/OpenSans-Bold.ttf b/graphics-ghostscript/src/main/resources/fonts/OpenSans-Bold.ttf deleted file mode 100644 index fd79d43..0000000 Binary files a/graphics-ghostscript/src/main/resources/fonts/OpenSans-Bold.ttf and /dev/null differ diff --git a/graphics-ghostscript/src/main/resources/fonts/OpenSans-BoldItalic.ttf b/graphics-ghostscript/src/main/resources/fonts/OpenSans-BoldItalic.ttf deleted file mode 100644 index 9bc8009..0000000 Binary files a/graphics-ghostscript/src/main/resources/fonts/OpenSans-BoldItalic.ttf and /dev/null differ diff --git a/graphics-ghostscript/src/main/resources/fonts/OpenSans-Italic.ttf b/graphics-ghostscript/src/main/resources/fonts/OpenSans-Italic.ttf deleted file mode 100644 index c90da48..0000000 Binary files a/graphics-ghostscript/src/main/resources/fonts/OpenSans-Italic.ttf and /dev/null differ diff --git a/graphics-ghostscript/src/main/resources/fonts/OpenSans-Regular.ttf b/graphics-ghostscript/src/main/resources/fonts/OpenSans-Regular.ttf deleted file mode 100644 index db43334..0000000 Binary files a/graphics-ghostscript/src/main/resources/fonts/OpenSans-Regular.ttf and /dev/null differ diff --git a/graphics-pdfbox/src/main/java/org/xbib/graphics/pdfbox/analyze/DocumentAnalyzer.java b/graphics-pdfbox/src/main/java/org/xbib/graphics/pdfbox/analyze/DocumentAnalyzer.java index d1fdcdd..a83187b 100644 --- a/graphics-pdfbox/src/main/java/org/xbib/graphics/pdfbox/analyze/DocumentAnalyzer.java +++ b/graphics-pdfbox/src/main/java/org/xbib/graphics/pdfbox/analyze/DocumentAnalyzer.java @@ -175,13 +175,21 @@ public class DocumentAnalyzer { } } + /* + * MediaBox: the largest box possible, for the carrier medium of the page, it contains all frames and all elements. + * CropBox: the size of the box for the printer and on-screen display. Includes printer marks. + * BleedBox: the "Anschnitt" which means the area of the page that is to be displayed, including cutmarks. + * BBox: PDFbox effective bounding box + * TrimBox: (optional) the "Endformat" of the page ready to be produced, without cutmarks. + * ArtBox: (optional) the smallest box possible, without header, footer, page numbering. + */ private Map analyzePage(int i, PDPage page, Set seen) throws IOException { Map m = new LinkedHashMap<>(); m.put("page", i); - m.put("bbox", Map.of("height", page.getBBox().getHeight(), "width", page.getBBox().getWidth())); - m.put("cropbox", Map.of("height", page.getCropBox().getHeight(), "width", page.getCropBox().getWidth())); m.put("mediabox", Map.of("height", page.getMediaBox().getHeight(), "width", page.getMediaBox().getWidth())); + m.put("cropbox", Map.of("height", page.getCropBox().getHeight(), "width", page.getCropBox().getWidth())); m.put("bleedbox", Map.of("height", page.getBleedBox().getHeight(), "width", page.getBleedBox().getWidth())); + m.put("bbox", Map.of("height", page.getBBox().getHeight(), "width", page.getBBox().getWidth())); if (page.getTrimBox() != null) { m.put("trimbox", Map.of("height", page.getTrimBox().getHeight(), "width", page.getTrimBox().getWidth())); } diff --git a/graphics-pdfbox/src/main/java/org/xbib/graphics/pdfbox/font/DefaultFontDrawer.java b/graphics-pdfbox/src/main/java/org/xbib/graphics/pdfbox/font/DefaultFontDrawer.java index f840204..5e9c92a 100644 --- a/graphics-pdfbox/src/main/java/org/xbib/graphics/pdfbox/font/DefaultFontDrawer.java +++ b/graphics-pdfbox/src/main/java/org/xbib/graphics/pdfbox/font/DefaultFontDrawer.java @@ -306,17 +306,22 @@ public class DefaultFontDrawer implements FontDrawer, Closeable { if (windir == null) { windir = javaFontDir; } - File[] paths = new File[]{new File(new File(windir), "fonts"), + File[] paths = new File[] { + new File(new File(windir), "fonts"), new File(System.getProperty("user.dir", ".")), // Mac Fonts - new File("/Library/Fonts"), new File("/System/Library/Fonts/Supplemental/"), + new File("/Library/Fonts"), + new File("/System/Library/Fonts/Supplemental/"), // Unix Fonts - new File("/usr/share/fonts/truetype"), new File("/usr/share/fonts/truetype/dejavu"), + new File("/usr/share/fonts/truetype"), + new File("/usr/share/fonts/truetype/dejavu"), new File("/usr/share/fonts/truetype/liberation"), - new File("/usr/share/fonts/truetype/noto"), new File(javaFontDir)}; - for (String fontFileName : new String[]{"LucidaSansRegular.ttf", "arial.ttf", "Arial.ttf", + new File("/usr/share/fonts/truetype/noto"), + new File(javaFontDir) + }; + for (String fontFileName : List.of("LucidaSansRegular.ttf", "arial.ttf", "Arial.ttf", "DejaVuSans.ttf", "LiberationMono-Regular.ttf", "NotoSerif-Regular.ttf", - "Arial Unicode.ttf", "Tahoma.ttf"}) { + "Arial Unicode.ttf", "Tahoma.ttf")) { for (File path : paths) { File arialFile = new File(path, fontFileName); if (arialFile.exists()) { diff --git a/graphics-pdfbox/src/test/java/org/xbib/graphics/pdfbox/test/BarcodeAnalyzerTest.java b/graphics-pdfbox/src/test/java/org/xbib/graphics/pdfbox/test/BarcodeAnalyzerTest.java index bae7813..e5bf673 100644 --- a/graphics-pdfbox/src/test/java/org/xbib/graphics/pdfbox/test/BarcodeAnalyzerTest.java +++ b/graphics-pdfbox/src/test/java/org/xbib/graphics/pdfbox/test/BarcodeAnalyzerTest.java @@ -19,7 +19,7 @@ public class BarcodeAnalyzerTest { @Test public void testBarcodeAnalysis() throws IOException { Path tmp = Files.createTempDirectory("barcode-analyzer"); - String sample = "test.pdf"; + String sample = "mail_with_barcode.pdf"; Path path = tmp.resolve(sample); try (InputStream inputStream = getClass().getResourceAsStream(sample); OutputStream outputStream = Files.newOutputStream(path)) { diff --git a/graphics-pdfbox/src/test/java/org/xbib/graphics/pdfbox/test/DocumentAnalyzerTest.java b/graphics-pdfbox/src/test/java/org/xbib/graphics/pdfbox/test/DocumentAnalyzerTest.java index c864e31..ec35761 100644 --- a/graphics-pdfbox/src/test/java/org/xbib/graphics/pdfbox/test/DocumentAnalyzerTest.java +++ b/graphics-pdfbox/src/test/java/org/xbib/graphics/pdfbox/test/DocumentAnalyzerTest.java @@ -18,7 +18,7 @@ public class DocumentAnalyzerTest { @Test public void testDocument() throws IOException { Path tmp = Files.createTempDirectory("document-analyzer"); - String sample = "394_394-F3GIS2JO.pdf"; + String sample = "antonio_sample.pdf"; Path path = tmp.resolve(sample); try (InputStream inputStream = getClass().getResourceAsStream(sample); OutputStream outputStream = Files.newOutputStream(path)) {