From 4e55620db122b2b256b438548639499e4e8efa17 Mon Sep 17 00:00:00 2001 From: Alexander Dyuzhev Date: Sun, 5 May 2024 20:50:23 +0300 Subject: [PATCH 1/3] output_path xslt parameter added, metanorma/mn-native-pdf#449 --- Makefile | 2 +- README.adoc | 10 +++++----- pom.xml | 2 +- src/main/java/org/metanorma/fop/PDFGenerator.java | 2 ++ 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 8902093..93acdcf 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ SHELL ?= /bin/bash endif #JAR_VERSION := $(shell mvn -q -Dexec.executable="echo" -Dexec.args='$${project.version}' --non-recursive exec:exec -DforceStdout) -JAR_VERSION := 1.87 +JAR_VERSION := 1.88 JAR_FILE := mn2pdf-$(JAR_VERSION).jar all: target/$(JAR_FILE) diff --git a/README.adoc b/README.adoc index 3233998..5cad1d1 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.87.jar --xml-file --xsl-file --pdf-file [--syntax-highlight] +java -Xss5m -Xmx2048m -jar target/mn2pdf-1.88.jar --xml-file --xsl-file --pdf-file [--syntax-highlight] ---- e.g. [source,sh] ---- -java -Xss5m -Xmx2048m -jar target/mn2pdf-1.87.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.88.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.87 +1.88 Metanorma XML to PDF converter ---- @@ -111,8 +111,8 @@ Tag the same version in Git: [source,xml] ---- -git tag v1.87 -git push origin v1.87 +git tag v1.88 +git push origin v1.88 ---- Then the corresponding GitHub release will be automatically created at: diff --git a/pom.xml b/pom.xml index 2c84f13..e73e861 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 org.metanorma.fop mn2pdf - 1.87 + 1.88 Metanorma XML to PDF converter jar https://www.metanorma.org diff --git a/src/main/java/org/metanorma/fop/PDFGenerator.java b/src/main/java/org/metanorma/fop/PDFGenerator.java index ba9e7ed..4bc02b6 100644 --- a/src/main/java/org/metanorma/fop/PDFGenerator.java +++ b/src/main/java/org/metanorma/fop/PDFGenerator.java @@ -418,6 +418,8 @@ private void convertmn2pdf(fontConfig fontcfg, XSLTconverter xsltConverter, File additionalXSLTparams.setProperty("inputxml_basepath", fInputXMLParent); additionalXSLTparams.setProperty("inputxml_filename", fInputXML.getName()); + additionalXSLTparams.setProperty("output_path", pdf.getAbsolutePath()); + xsltConverter.setParams(additionalXSLTparams); setTablesWidths(fontcfg, xsltConverter, pdf); From 332aad71bf255263c46969c7defe853320ab94fd Mon Sep 17 00:00:00 2001 From: Alexander Dyuzhev Date: Tue, 21 May 2024 20:01:59 +0300 Subject: [PATCH 2/3] tables_only.xsl updated for #245 --- src/main/resources/tables_only.xsl | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/main/resources/tables_only.xsl b/src/main/resources/tables_only.xsl index 0310c23..70eec00 100644 --- a/src/main/resources/tables_only.xsl +++ b/src/main/resources/tables_only.xsl @@ -14,6 +14,13 @@ + + + + + + + @@ -28,7 +35,8 @@ local-name() = 'sections' or local-name() = 'annex' or local-name() = 'indexsect' - ]//*[local-name() = 'p' or + ]//*[local-name() = 'clause' or + local-name() = 'p' or local-name() = 'ul' or local-name() = 'ol' or local-name() = 'note' or @@ -131,4 +139,21 @@ + + + + + + + + + + + + Clause + + + + + From b8120f9aed8f9a4cafefce5d96550b6f8800d321 Mon Sep 17 00:00:00 2001 From: Alexander Dyuzhev Date: Wed, 22 May 2024 11:08:55 +0300 Subject: [PATCH 3/3] skip table auto layout for plateau added, metanorma/mn2pdf#245, metanorma/metanorma-plateau#2 --- src/main/java/org/metanorma/fop/PDFGenerator.java | 6 +++++- src/main/java/org/metanorma/fop/SourceXMLDocument.java | 3 ++- src/main/java/org/metanorma/fop/XSLTconverter.java | 5 +++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/metanorma/fop/PDFGenerator.java b/src/main/java/org/metanorma/fop/PDFGenerator.java index 4bc02b6..7981c59 100644 --- a/src/main/java/org/metanorma/fop/PDFGenerator.java +++ b/src/main/java/org/metanorma/fop/PDFGenerator.java @@ -88,6 +88,8 @@ public class PDFGenerator { private boolean isAddCommentaryPageNumbers = false; private boolean isAddMathAsAttachment = false; + + private boolean isApplyAutolayoutAlgorithm = true; private boolean isAddAnnotations = false; @@ -275,6 +277,8 @@ public boolean process() { isAddMathAsText = xsltConverter.hasParamAddMathAsText() && isMathExists; isAddMathAsAttachment = xsltConverter.hasParamAddMathAsAttachment(); + isApplyAutolayoutAlgorithm = xsltConverter.isApplyAutolayoutAlgorithm(); + if (isSyntaxHighlight) { xsltParams.put("syntax-highlight", "true"); } @@ -1174,7 +1178,7 @@ private void setTablesWidths(fontConfig fontcfg, XSLTconverter xsltConverter, Fi long startMethodTime = System.currentTimeMillis(); try { - if (isTableExists && xmlTableIF.isEmpty()) { + if (isTableExists && xmlTableIF.isEmpty() && isApplyAutolayoutAlgorithm) { // generate IF with table width data xsltConverter.setParam("table_if", "true"); logger.info("[INFO] Generation of XSL-FO with information about the table's widths ..."); diff --git a/src/main/java/org/metanorma/fop/SourceXMLDocument.java b/src/main/java/org/metanorma/fop/SourceXMLDocument.java index dbcb96d..9d31d78 100644 --- a/src/main/java/org/metanorma/fop/SourceXMLDocument.java +++ b/src/main/java/org/metanorma/fop/SourceXMLDocument.java @@ -98,7 +98,8 @@ public SourceXMLDocument(String strXML) { private void readMetaInformation() { String element_review = readValue("//*[local-name() = 'review'][1]"); this.hasAnnotations = element_review.length() != 0; - String element_table = readValue("//*[local-name() = 'table' or local-name() = 'dl'][1]"); + // check table without colgroup/col (width) or dl + String element_table = readValue("//*[(local-name() = 'table' and not(*[local-name() = 'colgroup']/*[local-name() = 'col'])) or local-name() = 'dl'][1]"); this.hasTables = element_table.length() != 0; String element_math = readValue("//*[local-name() = 'math'][1]"); this.hasMath = element_math.length() != 0; diff --git a/src/main/java/org/metanorma/fop/XSLTconverter.java b/src/main/java/org/metanorma/fop/XSLTconverter.java index fa5fad9..346c5cb 100644 --- a/src/main/java/org/metanorma/fop/XSLTconverter.java +++ b/src/main/java/org/metanorma/fop/XSLTconverter.java @@ -187,6 +187,11 @@ public boolean hasParamAddMathAsAttachment() { return param_add_math_as_attachment.equalsIgnoreCase("true"); } + public boolean isApplyAutolayoutAlgorithm() { + String variable_isApplyAutolayoutAlgorithm = readValue("/*[local-name() = 'stylesheet']/*[local-name() = 'variable'][@name = 'isApplyAutolayoutAlgorithm_']"); + return variable_isApplyAutolayoutAlgorithm.trim().equalsIgnoreCase("true"); + } + public void deleteTmpXSL() { if (tmpfileXSL != null) { try {