diff --git a/README.adoc b/README.adoc index c3a644f3..6306b80a 100644 --- a/README.adoc +++ b/README.adoc @@ -17,14 +17,14 @@ You will need the Java Development Kit (JDK) version 8, Update 241 (8u241) or hi [source,sh] ---- -java -Xss5m -Xmx2048m -jar target/mn2pdf-1.52.jar --xml-file --xsl-file --pdf-file [--syntax-highlight] +java -Xss5m -Xmx2048m -jar target/mn2pdf-1.53.jar --xml-file --xsl-file --pdf-file [--syntax-highlight] ---- e.g. [source,sh] ---- -java -Xss5m -Xmx2048m -jar target/mn2pdf-1.52.jar --xml-file tests/G.191.xml --xsl-file tests/itu.recommendation.xsl --pdf-file tests/G.191.pdf +java -Xss5m -Xmx2048m -jar target/mn2pdf-1.53.jar --xml-file tests/G.191.xml --xsl-file tests/itu.recommendation.xsl --pdf-file tests/G.191.pdf ---- === PDF encryption features @@ -100,7 +100,7 @@ Update version in `pom.xml`, e.g.: ---- org.metanorma.fop mn2pdf -1.52 +1.53 Metanorma XML to PDF converter ---- @@ -111,8 +111,8 @@ Tag the same version in Git: [source,xml] ---- -git tag v1.52 -git push origin v1.52 +git tag v1.53 +git push origin v1.53 ---- Then the corresponding GitHub release will be automatically created at: diff --git a/pom.xml b/pom.xml index ca1d5ac1..4a16d722 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 org.metanorma.fop mn2pdf - 1.52 + 1.53 Metanorma XML to PDF converter jar https://www.metanorma.org diff --git a/src/main/java/org/apache/fop/fonts/GlyphMapping.java b/src/main/java/org/apache/fop/fonts/GlyphMapping.java index f95d80f9..11c69222 100644 --- a/src/main/java/org/apache/fop/fonts/GlyphMapping.java +++ b/src/main/java/org/apache/fop/fonts/GlyphMapping.java @@ -75,7 +75,7 @@ public GlyphMapping(int startIndex, int endIndex, int wordSpaceCount, int letter MinOptMax areaIPD, boolean isHyphenated, boolean isSpace, boolean breakOppAfter, Font font, int level, int[][] gposAdjustments, String mapping, List associations) { this(startIndex, endIndex, wordSpaceCount, letterSpaceCount, areaIPD, isHyphenated, - isSpace, false, breakOppAfter, font, level, gposAdjustments, null, null); + isSpace, false, breakOppAfter, font, level, gposAdjustments, mapping, associations); } public GlyphMapping(int startIndex, int endIndex, int wordSpaceCount, int letterSpaceCount, diff --git a/src/test/java/org/metanorma/fop/mn2pdfTests.java b/src/test/java/org/metanorma/fop/mn2pdfTests.java index fdbb0740..2b2e0b5a 100644 --- a/src/test/java/org/metanorma/fop/mn2pdfTests.java +++ b/src/test/java/org/metanorma/fop/mn2pdfTests.java @@ -30,6 +30,7 @@ import org.apache.pdfbox.pdmodel.encryption.AccessPermission; import org.apache.pdfbox.pdmodel.encryption.PDEncryption; +import org.apache.pdfbox.text.PDFTextStripper; import org.junit.Rule; import org.junit.Test; import static org.junit.Assert.assertTrue; @@ -359,7 +360,46 @@ public void testSyntaxHighlight() throws TransformerException, TransformerConfig String exprectedValue = "<root><a></a><b>text</b><c key='value'/></root>"; assertTrue(value.equals(exprectedValue)); } - + + @Test + public void successSVGRendering() throws ParseException, IOException { + ClassLoader classLoader = getClass().getClassLoader(); + String fontpath = Paths.get(System.getProperty("buildDirectory"), ".." , "fonts").toString(); + String xml = classLoader.getResource("iso.svgtest.xml").getFile(); + String xsl = classLoader.getResource("iso.international-standard.xsl").getFile(); + Path pdf = Paths.get(System.getProperty("buildDirectory"), "iso.svgtest.pdf"); + + String[] args = new String[]{"--font-path", fontpath, "--xml-file", xml, "--xsl-file", xsl, "--pdf-file", pdf.toAbsolutePath().toString()}; + mn2pdf.main(args); + + String capturedLog = getTestCapturedLog(); + assertTrue(!capturedLog.contains("SVG graphic could not be rendered")); + assertTrue(Files.exists(pdf)); + } + + @Test + public void checkSpacesInPDF() throws ParseException { + ClassLoader classLoader = getClass().getClassLoader(); + String fontpath = Paths.get(System.getProperty("buildDirectory"), ".." , "fonts").toString(); + String xml = classLoader.getResource("iso.zerowidthspacetest.xml").getFile(); + String xsl = classLoader.getResource("iso.international-standard.xsl").getFile(); + Path pdf = Paths.get(System.getProperty("buildDirectory"), "iso.zerowidthspacetest.pdf"); + + String[] args = new String[]{"--font-path", fontpath, "--xml-file", xml, "--xsl-file", xsl, "--pdf-file", pdf.toAbsolutePath().toString()}; + mn2pdf.main(args); + + String pdftext = ""; + PDDocument doc; + try { + doc = PDDocument.load(pdf.toFile()); + pdftext = new PDFTextStripper().getText(doc); + } catch (IOException ex) { + System.out.println(ex.toString()); + } + assertTrue(pdftext.contains("the_integers") && pdftext.contains("elementary_space") && pdftext.contains("make_elementary_space")); + } + + @Test public void testDates() throws IOException { diff --git a/src/test/resources/iso.svgtest.xml b/src/test/resources/iso.svgtest.xml new file mode 100644 index 00000000..c6a2aec6 --- /dev/null +++ b/src/test/resources/iso.svgtest.xml @@ -0,0 +1,321 @@ + + + +Cereals and pulses — Specifications and test methods — Rice (Final) +Cereals and pulses +Specifications and test methods +Rice (Final) +Céréales et légumineuses — Spécification et méthodes d’essai — Riz (Final) +Céréales et légumineuses +Spécification et méthodes d’essai +Riz (Final) +ISO 17301-1:2016 +ISO 17301-1:2016(E) +ISO 17301-1:2016(E) +17301 +17301 + + + +International Organization for Standardization +ISO + + + + + +International Organization for Standardization +ISO + + +2 + +2016-05-01 + +en + + +60 +60 + + +2016 + + +International Organization for Standardization +ISO + + + + +international-standard + +Food products +Cereals and pulses +Amylose in rice +SAC + + +67.060 + + +ISO 17301 + +International standard + + + + +Scope

This document specifies minimum requirements and test methods for rice (Oryza sativa L.).

+

It is applicable to husked rice, husked parboiled rice, milled rice and milled parboiled rice, suitable for human consumption, directly or after reconditioning.

+

It is not applicable to cooked rice products.

+ +
+SVG for non PDF-UA test + +
+
+Figure 5 — Implementation pattern for optional properties with a data type class in a different package + + + + + + + + + + + + + + + + + + + + + + +«ApplicationSchema» +Metadata base + + + + + + + + + + + + + + + + + + + + +«ApplicationSchema» +Metadata Common Classes + + + + + + + + + + + + + + + + + + + + +«ApplicationSchema» +Metadata for Lineage + + + + + + + + + + + + + + + + + + + + +«XMLnamespace» +mcc.xsd + + + + + + + + + + + + + + + + + + + + +«XMLnamespace» +mdb.xsd + + + + + + + + + + +«_Metadata» +MD_Metadata + + + + + + + + + + +«abstract» +Abstract_LineageInformation + + + + + + + + + + + + + + + + + + + + +«XMLnamespace» +mrl.xsd + + + + + + + + + + +LineageInformation::LI_Lineage + + + + + + + + + + + + + + + + + + + + +Lineage content is implemented by +LI_Lineage class that substitutes for +the abstract +Abstract_LineageInformation class + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +«realize» ++resourceLineage +0..* + + + +NOTE

An abstract class is implemented in the metadata common classes namespace, +and used as the target of the optional property. Instantiation of the property +in an XML instance requires importing of the namespace that contains a concrete +class in the substitution group for the abstract class (mrl.xsd in this +diagram).

+
+
+
+
diff --git a/src/test/resources/iso.zerowidthspacetest.xml b/src/test/resources/iso.zerowidthspacetest.xml new file mode 100644 index 00000000..3f6f68c3 --- /dev/null +++ b/src/test/resources/iso.zerowidthspacetest.xml @@ -0,0 +1,90 @@ + + + +Cereals and pulses — Specifications and test methods — Rice (Final) +Cereals and pulses +Specifications and test methods +Rice (Final) +Céréales et légumineuses — Spécification et méthodes d’essai — Riz (Final) +Céréales et légumineuses +Spécification et méthodes d’essai +Riz (Final) +ISO 17301-1:2016 +ISO 17301-1:2016(E) +ISO 17301-1:2016(E) +17301 +17301 + + + +International Organization for Standardization +ISO + + + + + +International Organization for Standardization +ISO + + +2 + +2016-05-01 + +en + + +60 +60 + + +2016 + + +International Organization for Standardization +ISO + + + + +international-standard + +Food products +Cereals and pulses +Amylose in rice +SAC + + +67.060 + + +ISO 17301 + +International standard + + + + +Scope

This document specifies minimum requirements and test methods for rice (Oryza sativa L.).

+

It is applicable to husked rice, husked parboiled rice, milled rice and milled parboiled rice, suitable for human consumption, directly or after reconditioning.

+

It is not applicable to cooked rice products.

+ +

EXPRESS specification:

+ +*) + the_integers : elementary_space := make_elementary_space(es_integers); + the_reals : elementary_space := make_elementary_space(es_reals); + the_complex_numbers : elementary_space := make_elementary_space(es_complex_numbers); + the_numbers : elementary_space := make_elementary_space(es_numbers); + the_logicals : elementary_space := make_elementary_space(es_logicals); + the_booleans : elementary_space := make_elementary_space(es_booleans); + the_strings : elementary_space := make_elementary_space(es_strings); + the_binarys : elementary_space := make_elementary_space(es_binarys); + the_maths_spaces : elementary_space := make_elementary_space(es_maths_spaces); + the_generics : elementary_space := make_elementary_space(es_generics); +(* + +
+
+