Search in sources :

Example 16 with EngineProcessingException

use of org.jaffa.modules.printing.services.exceptions.EngineProcessingException in project jaffa-framework by jaffa-projects.

the class DomainDataBeanFactory method getInstance.

public IDataBean getInstance() throws FrameworkException, ApplicationExceptions {
    // Construct the DataBean
    IDataBean dataBean = null;
    log.debug("Created a DomainDataBean to wrapper " + m_beanClass);
    dataBean = (IDataBean) new DomainDataBean(m_beanClass, m_keys);
    if (dataBean == null)
        throw new EngineProcessingException("No DomainDataBean created");
    // Now make sure the bean has data in it
    dataBean.populate();
    return dataBean;
}
Also used : EngineProcessingException(org.jaffa.modules.printing.services.exceptions.EngineProcessingException)

Example 17 with EngineProcessingException

use of org.jaffa.modules.printing.services.exceptions.EngineProcessingException in project jaffa-framework by jaffa-projects.

the class FormPrintEngineIText method startDocument.

/**
 * Any work to start off printing the document
 * @throws FormPrintException Thrown if there is any form processing problems
 */
protected void startDocument() throws FormPrintException {
    log.debug("startDocument:");
    Rectangle r = m_templateReader.getPageSize(getCurrentTemplatePage());
    log.debug("Page Size      : t=" + r.getTop() + ",l=" + r.getLeft() + ",b=" + r.getBottom() + ",r=" + r.getRight() + ", rot=" + r.getRotation());
    r = m_templateReader.getPageSizeWithRotation(getCurrentTemplatePage());
    log.debug("Page Size w/Rot: t=" + r.getTop() + ",l=" + r.getLeft() + ",b=" + r.getBottom() + ",r=" + r.getRight() + ", rot=" + r.getRotation());
    m_generatedDoc = new Document(m_templateReader.getPageSizeWithRotation(getCurrentTemplatePage()));
    // m_generatedDoc = new Document(m_templateReader.getPageSize(getCurrentTemplatePage()));
    m_output = new ByteArrayOutputStream();
    try {
        m_writer = PdfWriter.getInstance(m_generatedDoc, m_output);
    } catch (DocumentException e) {
        log.error("Error Creating Writer - " + e.getMessage(), e);
        throw new EngineProcessingException("Error Creating Writer - " + e.getMessage());
    }
    if (getDocumentProperties() != null) {
        Properties dp = (Properties) getDocumentProperties().clone();
        if (dp.getProperty(DOCUMENT_PROPERTY_TITLE) != null) {
            m_generatedDoc.addTitle(dp.getProperty(DOCUMENT_PROPERTY_TITLE));
            dp.remove(DOCUMENT_PROPERTY_TITLE);
        }
        if (dp.getProperty(DOCUMENT_PROPERTY_SUBJECT) != null) {
            m_generatedDoc.addSubject(dp.getProperty(DOCUMENT_PROPERTY_SUBJECT));
            dp.remove(DOCUMENT_PROPERTY_SUBJECT);
        }
        if (dp.getProperty(DOCUMENT_PROPERTY_KEYWORDS) != null) {
            m_generatedDoc.addKeywords(dp.getProperty(DOCUMENT_PROPERTY_KEYWORDS));
            dp.remove(DOCUMENT_PROPERTY_KEYWORDS);
        }
        if (dp.getProperty(DOCUMENT_PROPERTY_CREATOR) != null) {
            m_generatedDoc.addCreator(dp.getProperty(DOCUMENT_PROPERTY_CREATOR, "Jaffa Print Engine"));
            dp.remove(DOCUMENT_PROPERTY_CREATOR);
        }
        if (dp.getProperty(DOCUMENT_PROPERTY_AUTHOR) != null) {
            m_generatedDoc.addAuthor(dp.getProperty(DOCUMENT_PROPERTY_AUTHOR));
            dp.remove(DOCUMENT_PROPERTY_AUTHOR);
        }
        // loop through other properties and set them as header parameters
        for (Enumeration en = dp.elements(); en.hasMoreElements(); ) {
            Map.Entry e = (Map.Entry) en.nextElement();
            if (e.getKey() != null && e.getValue() != null)
                m_generatedDoc.addHeader(e.getKey().toString(), e.getValue().toString());
        }
    }
    m_generatedDoc.addCreationDate();
    m_generatedDoc.open();
}
Also used : Enumeration(java.util.Enumeration) DocumentException(com.lowagie.text.DocumentException) Rectangle(com.lowagie.text.Rectangle) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Document(com.lowagie.text.Document) Properties(java.util.Properties) HashMap(java.util.HashMap) Map(java.util.Map) EngineProcessingException(org.jaffa.modules.printing.services.exceptions.EngineProcessingException)

Example 18 with EngineProcessingException

use of org.jaffa.modules.printing.services.exceptions.EngineProcessingException in project jaffa-framework by jaffa-projects.

the class FormPrintEngineIText method initEngine.

/**
 * Perform any initialization activity for generating the document
 * @throws FormPrintException Thrown if there were initialization errors
 */
protected void initEngine() throws FormPrintException {
    log.debug("initEngine:");
    if (getTemplateName() != null) {
        if (!(new File(getTemplateName())).exists()) {
            FormPrintException e = new EngineProcessingException("Form Template Not Found", new FileNotFoundException(getTemplateName()));
            log.error("Form Template Not Found." + getTemplateName(), e);
            throw e;
        }
    } else {
        FormPrintException e = new EngineProcessingException("Form Template Name Missing.");
        log.error(" Form Template Name Missing. ");
        throw e;
    }
}
Also used : FormPrintException(org.jaffa.modules.printing.services.exceptions.FormPrintException) FileNotFoundException(java.io.FileNotFoundException) File(java.io.File) EngineProcessingException(org.jaffa.modules.printing.services.exceptions.EngineProcessingException)

Aggregations

EngineProcessingException (org.jaffa.modules.printing.services.exceptions.EngineProcessingException)18 PDFlibException (com.pdflib.PDFlibException)7 IOException (java.io.IOException)7 FormPrintException (org.jaffa.modules.printing.services.exceptions.FormPrintException)5 File (java.io.File)4 DocumentException (com.lowagie.text.DocumentException)3 FileNotFoundException (java.io.FileNotFoundException)2 FileOutputStream (java.io.FileOutputStream)2 StringWriter (java.io.StringWriter)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 ArrayList (java.util.ArrayList)2 Iterator (java.util.Iterator)2 VelocityContext (org.apache.velocity.VelocityContext)2 MethodInvocationException (org.apache.velocity.exception.MethodInvocationException)2 ParseErrorException (org.apache.velocity.exception.ParseErrorException)2 ResourceNotFoundException (org.apache.velocity.exception.ResourceNotFoundException)2 BadElementException (com.lowagie.text.BadElementException)1 Document (com.lowagie.text.Document)1 Image (com.lowagie.text.Image)1 Phrase (com.lowagie.text.Phrase)1