From 6ae29df8c456a66e04875127259741d79f3db076 Mon Sep 17 00:00:00 2001 From: Alexander Dyuzhev Date: Fri, 9 Jun 2023 10:41:55 +0300 Subject: [PATCH 1/3] Apache FOP config updated, linearization turned off, #204 --- Makefile | 2 +- README.adoc | 6 +++--- pom.xml | 2 +- src/main/resources/pdf_fonts_config.xml | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 4037e08..ba1fb42 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.72 +JAR_VERSION := 1.73 JAR_FILE := mn2pdf-$(JAR_VERSION).jar all: target/$(JAR_FILE) diff --git a/README.adoc b/README.adoc index 4749975..9894b36 100644 --- a/README.adoc +++ b/README.adoc @@ -100,7 +100,7 @@ Update version in `pom.xml`, e.g.: ---- org.metanorma.fop mn2pdf -1.72 +1.73 Metanorma XML to PDF converter ---- @@ -111,8 +111,8 @@ Tag the same version in Git: [source,xml] ---- -git tag v1.72 -git push origin v1.72 +git tag v1.73 +git push origin v1.73 ---- Then the corresponding GitHub release will be automatically created at: diff --git a/pom.xml b/pom.xml index 2529adc..42c7eba 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 org.metanorma.fop mn2pdf - 1.72 + 1.73 Metanorma XML to PDF converter jar https://www.metanorma.org diff --git a/src/main/resources/pdf_fonts_config.xml b/src/main/resources/pdf_fonts_config.xml index fca08b4..d8a3b51 100644 --- a/src/main/resources/pdf_fonts_config.xml +++ b/src/main/resources/pdf_fonts_config.xml @@ -27,7 +27,7 @@ Relative config URLs are resolved relative to location of this file. PDF/UA-1 - true + 1.7 From d1e09654ac0c023fa4943c66359600a851f99a5a Mon Sep 17 00:00:00 2001 From: Alexander Dyuzhev Date: Mon, 12 Jun 2023 20:34:09 +0300 Subject: [PATCH 2/3] add_commentary_page_numbers.xsl added for metanorma/metanorma-jis#30 --- .../resources/add_commentary_page_numbers.xsl | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/main/resources/add_commentary_page_numbers.xsl diff --git a/src/main/resources/add_commentary_page_numbers.xsl b/src/main/resources/add_commentary_page_numbers.xsl new file mode 100644 index 0000000..28cebb9 --- /dev/null +++ b/src/main/resources/add_commentary_page_numbers.xsl @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + From e608b79cb77eb478f5c10aa1a404436c8c31a2f4 Mon Sep 17 00:00:00 2001 From: Alexander Dyuzhev Date: Mon, 12 Jun 2023 20:38:10 +0300 Subject: [PATCH 3/3] commentary pages renumbering added, metanorma/metanorma-jis#30 --- .../java/org/metanorma/fop/PDFGenerator.java | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/metanorma/fop/PDFGenerator.java b/src/main/java/org/metanorma/fop/PDFGenerator.java index 1f9afbd..e496e73 100644 --- a/src/main/java/org/metanorma/fop/PDFGenerator.java +++ b/src/main/java/org/metanorma/fop/PDFGenerator.java @@ -96,6 +96,8 @@ public class PDFGenerator { private boolean isAddMathAsText = false; private boolean isAddLineNumbers = false; + + private boolean isAddCommentaryPageNumbers = false; private boolean isAddMathAsAttachment = false; @@ -406,7 +408,10 @@ private void convertmn2pdf(fontConfig fontcfg, XSLTconverter xsltConverter, File String add_line_numbers = Util.readValueFromXMLString(xmlFO, "/*[local-name() = 'root']/processing-instruction('add_line_numbers')"); isAddLineNumbers = add_line_numbers.equalsIgnoreCase("true"); - + + String add_commentary_page_numbers = Util.readValueFromXMLString(xmlFO, "//*[@id = '_independent_page_number_commentary']/@id"); + isAddCommentaryPageNumbers = !add_commentary_page_numbers.isEmpty(); + debugSaveXML(xmlFO, pdf.getAbsolutePath() + ".fo.xml"); fontcfg.setSourceDocumentFontList(sourceXMLDocument.getDocumentFonts()); @@ -453,8 +458,10 @@ private void runFOP (fontConfig fontcfg, Source src, File pdf) throws IOExceptio try { String mime = MimeConstants.MIME_PDF; - - if (isAddMathAsText || isAddAnnotations || isAddLineNumbers) { + + boolean isPostprocessing = isAddMathAsText || isAddAnnotations || isAddLineNumbers || isAddCommentaryPageNumbers; + + if (isPostprocessing) { if (isAddMathAsText) { logger.info("Adding Math as text..."); } @@ -480,6 +487,16 @@ private void runFOP (fontConfig fontcfg, Source src, File pdf) throws IOExceptio debugSaveXML(xmlIF, pdf.getAbsolutePath() + ".if.linenumbers.xml"); } + + if (isAddCommentaryPageNumbers) { + logger.info("Updating Intermediate Format (adding commentary pages)..."); + xmlIF = applyXSLT("add_commentary_page_numbers.xsl", xmlIF, true); + + debugXSLFO = xmlIF; + + debugSaveXML(xmlIF, pdf.getAbsolutePath() + ".if.commentarypagenumbers.xml"); + } + src = new StreamSource(new StringReader(xmlIF)); } @@ -516,7 +533,7 @@ private void runFOP (fontConfig fontcfg, Source src, File pdf) throws IOExceptio out = new FileOutputStream(pdf); out = new BufferedOutputStream(out); - if (isAddMathAsText || isAddAnnotations || isAddLineNumbers) { // process IF to PDF + if (isPostprocessing) { // process IF to PDF //Setup target handler IFDocumentHandler targetHandler = fopFactory.getRendererFactory().createDocumentHandler( foUserAgent, mime);