use of digilib.util.NumRange in project digilib by robcast.
the class PDFStreamWorker method renderPDF.
/**
* @throws DocumentException
* @throws InterruptedException
* @throws ExecutionException
* @throws IOException
* @throws ImageOpException
*/
protected OutputStream renderPDF() throws DocumentException, InterruptedException, ExecutionException, IOException, ImageOpException {
// create document object
doc = new Document(PageSize.A4, 0, 0, 0, 0);
PdfWriter docwriter = null;
long start_time = System.currentTimeMillis();
docwriter = PdfWriter.getInstance(doc, outstream);
setPDFProperties(doc);
doc.open();
addTitlePage(doc);
logger.debug("PDF: " + outstream + " doc.open()ed (" + (System.currentTimeMillis() - start_time) + "ms)");
NumRange pgs = job_info.getPages();
for (int p : pgs) {
logger.debug("PDF: adding Image " + p + " to " + outstream);
// set page number
job_info.setValue("pn", p);
// create ImageJobInformation
ImageJobDescription iji = ImageJobDescription.getInstance(job_info, job_info.getDlConfig());
addImage(doc, iji);
logger.debug("PDF: done adding Image " + p + " to " + outstream);
}
logger.debug("PDF: done adding all Images to " + outstream);
doc.close();
logger.debug("PDF: " + outstream + " doc.close() (" + (System.currentTimeMillis() - start_time) + "ms)");
docwriter.flush();
docwriter.close();
return outstream;
}
use of digilib.util.NumRange in project digilib by robcast.
the class PDFRequest method setWithRequest.
/**
* Read the request object.
*
* @param request
* @throws ImageOpException
* @throws IOException
*/
public void setWithRequest(HttpServletRequest request) throws IOException, ImageOpException {
// read matching request parameters for the parameters in this map
for (String k : params.keySet()) {
if (request.getParameterMap().containsKey(k)) {
setValueFromString(k, request.getParameter(k));
}
}
// process parameters
pages = new NumRange(getAsString("pgs"));
ImageJobDescription ij = ImageJobDescription.getInstance(this, dlConfig);
DocuDirectory dir = ij.getFileDirectory();
int dirsize = dir.size();
pages.setMaxnum(dirsize);
}
Aggregations