# HG changeset patch # User robcast # Date 1294603863 -3600 # Node ID e8668edcb880eb12467b54df260230429ed70ecf # Parent 7768ea8f59cff326bbdc6c65d653aac5e51b9109# Parent 85e465e6a6425d91c0704f6584a461492d51de97 Merge from HEAD 85e465e6a6425d91c0704f6584a461492d51de97 diff -r 7768ea8f59cf -r e8668edcb880 servlet/src/digilib/pdf/PDFStreamWorker.java --- a/servlet/src/digilib/pdf/PDFStreamWorker.java Fri Jan 07 12:00:10 2011 +0100 +++ b/servlet/src/digilib/pdf/PDFStreamWorker.java Sun Jan 09 21:11:03 2011 +0100 @@ -78,25 +78,24 @@ addTitlePage(doc); - logger.debug("- " + outstream + " doc.open()ed (" + logger.debug("PDF: " + outstream + " doc.open()ed (" + (System.currentTimeMillis() - start_time) + "ms)"); - start_time = System.currentTimeMillis(); NumRange pgs = job_info.getPages(); for (int p : pgs) { - logger.debug(" - adding Image " + p + " to " + outstream); + logger.debug("PDF: adding Image " + p + " to " + outstream); // create ImageJobInformation ImageJobDescription iji = ImageJobDescription.getInstance(job_info, job_info.getDlConfig()); iji.setValue("pn", p); addImage(doc, iji); - logger.debug(" - done adding Image " + p + " to " + outstream); + logger.debug("PDF: done adding Image " + p + " to " + outstream); } - logger.debug(" - done adding all Images to " + outstream); + logger.debug("PDF: done adding all Images to " + outstream); doc.close(); - logger.debug("- " + outstream + " doc.close() (" + logger.debug("PDF: " + outstream + " doc.close() (" + (System.currentTimeMillis() - start_time) + "ms)"); docwriter.close(); return outstream; diff -r 7768ea8f59cf -r e8668edcb880 servlet/src/digilib/pdf/PDFTitlePage.java --- a/servlet/src/digilib/pdf/PDFTitlePage.java Fri Jan 07 12:00:10 2011 +0100 +++ b/servlet/src/digilib/pdf/PDFTitlePage.java Sun Jan 09 21:11:03 2011 +0100 @@ -1,5 +1,6 @@ package digilib.pdf; +import java.io.File; import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; @@ -14,8 +15,7 @@ import com.itextpdf.text.Image; import com.itextpdf.text.Paragraph; - -import digilib.io.DocuDirCache; +import digilib.io.FileOpException; import digilib.servlet.PDFCache; import digilib.servlet.PDFRequest; @@ -27,7 +27,6 @@ private PDFRequest job_info = null; private DigilibInfoReader info_reader= null; - private DocuDirCache dirCache = null; protected static Logger logger = Logger.getLogger("digilib.servlet"); @@ -37,12 +36,27 @@ */ public PDFTitlePage(PDFRequest pdfji){ job_info = pdfji; - dirCache = (DocuDirCache) job_info.getDlConfig().getValue("servlet.dir.cache"); + + // use MPIWG-style info.xml + info_reader = getInfoXmlReader(pdfji); + } - String fn = getBase(dirCache.getDirectory(pdfji.getImageJobInformation().getAsString("fn")).getDir().getPath()) + "presentation/info.xml"; - - info_reader = new DigilibInfoReader(fn); - } + /** + * @param pdfji + * @return + */ + protected DigilibInfoReader getInfoXmlReader(PDFRequest pdfji) { + try { + // try to load ../presentation/info.xml + File imgDir = pdfji.getImageJobInformation().getFileDirectory().getDir(); + File docDir = imgDir.getParentFile(); + File infoFn = new File(new File(docDir, "presentation"), "info.xml"); + return new DigilibInfoReader(infoFn.getAbsolutePath()); + } catch (FileOpException e) { + logger.warn("info.xml not found"); + } + return null; + } /** * generate iText-PDF-Contents for the title page @@ -58,7 +72,6 @@ content.add(Chunk.NEWLINE); } - // add logo content.add(getLogo()); content.add(Chunk.NEWLINE); @@ -88,9 +101,6 @@ content.add(Chunk.NEWLINE); content.add(Chunk.NEWLINE); - // add credits - content.add(new Paragraph("MPIWG Berlin 2009", FontFactory.getFont(FontFactory.HELVETICA,10))); - // add digilib version content.add(new Paragraph(getDigilibVersion(),FontFactory.getFont(FontFactory.HELVETICA,10))); @@ -108,32 +118,11 @@ return content; } - /** - * return base directory of an image directory - * - * @param path - * @return - */ - private String getBase(String path){ - if(path.contains("/")){ - String[] x = path.split("/"); - String newpath = ""; - for(int i=0; i