Example usage for com.lowagie.text.pdf.codec Base64 decodeToFile

List of usage examples for com.lowagie.text.pdf.codec Base64 decodeToFile

Introduction

In this page you can find the example usage for com.lowagie.text.pdf.codec Base64 decodeToFile.

Prototype

public static boolean decodeToFile(String dataToDecode, String filename) 

Source Link

Document

Convenience method for decoding data to a file.

Usage

From source file:org.oscarehr.fax.core.FaxImporter.java

License:Open Source License

private boolean saveAndInsertIntoQueue(FaxConfig faxConfig, FaxJob receivedFax, FaxJob faxFile) {

    boolean retval = false;

    String filename = receivedFax.getFile_name().replace("tif", "pdf");
    String user = "-1";

    EDoc newDoc = new EDoc("", "", filename, "", user, user, "", 'A',
            DateFormatUtils.format(receivedFax.getStamp(), "yyyy-MM-dd"), "", "", "demographic", "-1", 0);
    newDoc.setDocPublic("0");

    filename = newDoc.getFileName();/*from ww  w. j ava2s  .co m*/
    if (Base64.decodeToFile(faxFile.getDocument(), DOCUMENT_DIR + "/" + filename)) {

        newDoc.setContentType("application/pdf");
        newDoc.setNumberOfPages(receivedFax.getNumPages());
        String doc_no = EDocUtil.addDocumentSQL(newDoc);

        Integer queueId = faxConfig.getQueue();
        Integer docNum = Integer.parseInt(doc_no);

        queueDocumentLinkDao.addActiveQueueDocumentLink(queueId, docNum);
        FaxJob saveFax = new FaxJob(receivedFax);
        saveFax.setFile_name(filename);
        faxJobDao.persist(saveFax);
        retval = true;
    }

    return retval;

}