Add option to select citation page format (LETTER or A4)

This commit is contained in:
Ilja Sidoroff
2018-04-20 22:06:32 +03:00
committed by Kim Shepherd
parent 49185db7e9
commit 426d21a1c6
2 changed files with 21 additions and 1 deletions

View File

@@ -94,6 +94,11 @@ public class CitationDocumentServiceImpl implements CitationDocumentService, Ini
protected String[] fields;
protected String footer;
/**
* Citation page format
*/
protected PDRectangle citationPageFormat = PDRectangle.LETTER;
@Autowired(required = true)
protected AuthorizeService authorizeService;
@Autowired(required = true)
@@ -195,6 +200,16 @@ public class CitationDocumentServiceImpl implements CitationDocumentService, Ini
footer = "Downloaded from DSpace Repository, DSpace Institution's institutional repository";
}
String pageformatCfg = configurationService.getProperty("citation-page.page_format");
if (pageformatCfg != null) {
if (pageformatCfg.equalsIgnoreCase("A4")) {
citationPageFormat = PDRectangle.A4;
} else if (!pageformatCfg.equalsIgnoreCase("LETTER")) {
log.info("Citation-page: Unknown page format ' " + pageformatCfg + "', using LETTER.");
}
}
//Ensure a temp directory is available
String tempDirString = configurationService.getProperty("dspace.dir") + File.separator + "temp";
tempDir = new File(tempDirString);
@@ -288,7 +303,7 @@ public class CitationDocumentServiceImpl implements CitationDocumentService, Ini
try {
Item item = (Item) bitstreamService.getParentObject(context, bitstream);
sourceDocument = sourceDocument.load(bitstreamService.retrieve(context, bitstream));
PDPage coverPage = new PDPage(PDRectangle.LETTER); // TODO: needs to be configurable
PDPage coverPage = new PDPage(citationPageFormat);
generateCoverPage(context, document, coverPage, item);
addCoverPageToDocument(document, sourceDocument, coverPage);