diff --git a/src/main/java/com/researchspace/export/pdf/ExportToFileConfig.java b/src/main/java/com/researchspace/export/pdf/ExportToFileConfig.java
index dc625352f..ab6bfa973 100644
--- a/src/main/java/com/researchspace/export/pdf/ExportToFileConfig.java
+++ b/src/main/java/com/researchspace/export/pdf/ExportToFileConfig.java
@@ -47,7 +47,7 @@ public enum DATE_FOOTER_PREF {
private boolean provenance = true;
private boolean comments = true;
private boolean annotations = true;
- private boolean pageName = true;
+ private boolean restartPageNumberPerDoc = true;
private boolean includeFieldLastModifiedDate = true;
@NotNull private ExportPageSize pageSize = ExportPageSize.A4;
@@ -67,11 +67,7 @@ public ExportScope getExportScope() {
return exportScope;
}
- /**
- * A name() String of an {@link ExportFormat} enum
- *
- * @param exportFormat
- */
+ /** A name() String of an {@link ExportFormat} enum */
public void setExportFormat(String exportFormat) {
this.exportFormat = ExportFormat.valueOf(exportFormat);
}
@@ -110,8 +106,8 @@ public String toString() {
+ comments
+ ", annotations="
+ annotations
- + ", pageName="
- + pageName
+ + ", restartPageNumberPerDoc="
+ + restartPageNumberPerDoc
+ ", pageSize="
+ pageSize
+ ", dateType="
diff --git a/src/main/java/com/researchspace/export/pdf/PdfProcessor.java b/src/main/java/com/researchspace/export/pdf/PdfProcessor.java
index 6e9c84f38..34bb2f90f 100644
--- a/src/main/java/com/researchspace/export/pdf/PdfProcessor.java
+++ b/src/main/java/com/researchspace/export/pdf/PdfProcessor.java
@@ -64,18 +64,32 @@ public void makeExport(
ExportToFileConfig config)
throws IOException {
- int startPage;
+ // 1 pdf export can contain multiple docs
+ int pdfPageLength;
try {
- startPage = doExportPdf(tempExportFile, documentData, strucDoc, config);
+ pdfPageLength = doExportPdf(tempExportFile, documentData, strucDoc, config);
} catch (DocumentException e) {
throw new IOException("Could not generate PDFWriter", e);
}
+ int startPage = calculatePageNumber(config, pdfPageLength);
+ config.setStartPage(startPage);
+ }
- if (!config.isPageName()) {
- config.setStartPage(startPage);
- } else {
- config.setStartPage(0);
+ /***
+ * The pdf writer expects the start page to be either:
+ * - 0 for a new doc, or when restarting the page numbering for each doc on a
+ * multi-doc/notebook export
+ * - the length of the existing pdf on multi-doc/notebook export when the user has selected
+ * not to restart the page numbering for each individual doc
+ * */
+ private int calculatePageNumber(ExportToFileConfig config, int pdfPageLength) {
+ if (!config.isRestartPageNumberPerDoc()) {
+ int currentStartPage = config.getStartPage();
+ return currentStartPage == 0
+ ? currentStartPage + pdfPageLength
+ : currentStartPage + pdfPageLength - 1;
}
+ return 0;
}
private int doExportPdf(
@@ -85,7 +99,7 @@ private int doExportPdf(
ExportToFileConfig config)
throws DocumentException, IOException {
- log.info("Before: {}", documentData.getDocumentAsHtml());
+ log.debug("Before: {}", documentData.getDocumentAsHtml());
documentData = preProcessHTML(documentData);
String html = pdfHtmlGenerator.prepareHtml(documentData, strucDoc, config);
@@ -103,7 +117,7 @@ private int doExportPdf(
renderer.setDocumentFromString(html);
renderer.layout();
try (FileOutputStream out = new FileOutputStream(tempExportFile)) {
- renderer.createPDF(out);
+ renderer.createPDF(out, true, config.getStartPage());
}
return renderer.getWriter().getPageNumber();
}
diff --git a/src/main/webapp/WEB-INF/pages/export/export_otherDialogs.jsp b/src/main/webapp/WEB-INF/pages/export/export_otherDialogs.jsp
index 2dfa68786..7f35c92b8 100644
--- a/src/main/webapp/WEB-INF/pages/export/export_otherDialogs.jsp
+++ b/src/main/webapp/WEB-INF/pages/export/export_otherDialogs.jsp
@@ -21,7 +21,7 @@
|
|
- |
+ |
|
|