Search in sources :

Example 1 with NumRange

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;
}
Also used : NumRange(digilib.util.NumRange) PdfWriter(com.itextpdf.text.pdf.PdfWriter) ImageJobDescription(digilib.image.ImageJobDescription) Document(com.itextpdf.text.Document)

Example 2 with NumRange

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);
}
Also used : NumRange(digilib.util.NumRange) ImageJobDescription(digilib.image.ImageJobDescription) DocuDirectory(digilib.io.DocuDirectory)

Aggregations

ImageJobDescription (digilib.image.ImageJobDescription)2 NumRange (digilib.util.NumRange)2 Document (com.itextpdf.text.Document)1 PdfWriter (com.itextpdf.text.pdf.PdfWriter)1 DocuDirectory (digilib.io.DocuDirectory)1