当前位置: 首页>>代码示例>>Java>>正文


Java PdfStamper.setFormFlattening方法代码示例

本文整理汇总了Java中com.lowagie.text.pdf.PdfStamper.setFormFlattening方法的典型用法代码示例。如果您正苦于以下问题:Java PdfStamper.setFormFlattening方法的具体用法?Java PdfStamper.setFormFlattening怎么用?Java PdfStamper.setFormFlattening使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.lowagie.text.pdf.PdfStamper的用法示例。


在下文中一共展示了PdfStamper.setFormFlattening方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: modifyPdf

import com.lowagie.text.pdf.PdfStamper; //导入方法依赖的package包/类
public static void modifyPdf(InputStream pdfTemplate, OutputStream modifiedPdf, String name, LocalDate startDate) throws IOException, DocumentException {
        // NOTE: Can we use this?
//        PdfReader.unethicalreading = true;

        PdfReader reader = new PdfReader(pdfTemplate);
        PdfStamper stamper = new PdfStamper(reader, modifiedPdf);

        fill(stamper.getAcroFields(), name, startDate);

        stamper.setFormFlattening(true);
        stamper.partialFormFlattening(INITIATIVE_NAME);
        stamper.partialFormFlattening(INITIATIVE_DAY);
        stamper.partialFormFlattening(INITIATIVE_MONTH);
        stamper.partialFormFlattening(INITIATIVE_YEAR);

        stamper.close();
        reader.close();
    }
 
开发者ID:solita,项目名称:kansalaisaloite,代码行数:19,代码来源:SupportStatementPdf.java

示例2: generatePdfTesi

import com.lowagie.text.pdf.PdfStamper; //导入方法依赖的package包/类
/**
 * Genera il pdf per la richiesta della tesi
 *
 * @param tesiView Vista con il form per raccogliere i dati
 * @param path     Path del file di destinazione
 * @throws IOException
 * @throws DocumentException
 */
public void generatePdfTesi(FormTesi tesiView, String path) throws IOException, DocumentException {

    // Lettura del template
    PdfReader pdfTemplate = new PdfReader(template);
    // Apertura del file di destinazione
    FileOutputStream fileOutputStream = createOutputStream(path);
    // Popolazione del template con i dati
    PdfStamper stamper = new PdfStamper(pdfTemplate, fileOutputStream);

    stamper.setFormFlattening(true);

    stamper.getAcroFields().setField("nome", tesiView.getNome().getText());
    stamper.getAcroFields().setField("cognome", tesiView.getCognome().getText());
    stamper.getAcroFields().setField("matricola", tesiView.getMatricola().getText());
    stamper.getAcroFields().setField("dataNascita", tesiView.getDataNascita().getText());
    stamper.getAcroFields().setField("luogoNascita", tesiView.getLuogoNascita().getText());
    stamper.getAcroFields().setField("eMail", tesiView.getEmail().getText());
    stamper.getAcroFields().setField("annoCorso", tesiView.getAnnoCorso().getText());
    stamper.getAcroFields().setField("professoreRelatore", tesiView.getProfRelatore().getText());
    stamper.getAcroFields().setField("titoloTesi", tesiView.getTitoloTesi().getText());

    pdfTemplate.close();
    stamper.close();
    fileOutputStream.close();
}
 
开发者ID:ilario-pierbattista,项目名称:studeasy,代码行数:34,代码来源:PdfGenerator.java

示例3: generatePdfTirocinio

import com.lowagie.text.pdf.PdfStamper; //导入方法依赖的package包/类
/**
 * Genera il pdf per la richiesta di tirocinio
 *
 * @param tirocinioView Vista con il form per raccogliere i dati
 * @param path          Path del file di destinazione
 * @throws IOException
 * @throws DocumentException
 */
public void generatePdfTirocinio(FormTirocinio tirocinioView, String path) throws IOException, DocumentException {

    // Lettura del template
    PdfReader pdfTemplate = new PdfReader(template);
    // Apertura del file di destinazione
    FileOutputStream fileOutputStream = createOutputStream(path);
    // Popolazione del template con i dati
    PdfStamper stamper = new PdfStamper(pdfTemplate, fileOutputStream);

    stamper.setFormFlattening(true);

    stamper.getAcroFields().setField("nome", tirocinioView.getNome().getText());
    stamper.getAcroFields().setField("cognome", tirocinioView.getCognome().getText());
    stamper.getAcroFields().setField("matricola", tirocinioView.getMatricola().getText());
    stamper.getAcroFields().setField("luogoNascita", tirocinioView.getLuogonascita().getText());
    stamper.getAcroFields().setField("dataNascita", tirocinioView.getDatanascita().getText());
    stamper.getAcroFields().setField("residenza", tirocinioView.getResidenza().getText());
    stamper.getAcroFields().setField("provincia", tirocinioView.getProvincia().getText());
    stamper.getAcroFields().setField("cap", tirocinioView.getCap().getText());
    stamper.getAcroFields().setField("via", tirocinioView.getVia().getText());
    stamper.getAcroFields().setField("codiceFiscale", tirocinioView.getCodicefiscale().getText());

    pdfTemplate.close();
    stamper.close();
    fileOutputStream.close();
}
 
开发者ID:ilario-pierbattista,项目名称:studeasy,代码行数:35,代码来源:PdfGenerator.java

示例4: generatePdfImmatricolazione

import com.lowagie.text.pdf.PdfStamper; //导入方法依赖的package包/类
/**
 * Genera il pdf per l'immatricolazione
 *
 * @param immatricolazioneView Vista che contiene il form per raccogliere i dati
 * @param path                 Path del file di destinazione
 * @throws IOException
 * @throws DocumentException
 */
public void generatePdfImmatricolazione(FormImmatricolazione immatricolazioneView, String path) throws IOException, DocumentException {

    // Lettura del template
    PdfReader pdfTemplate = new PdfReader(template);
    // Apertura del file di destinazione
    FileOutputStream fileOutputStream = createOutputStream(path);
    // Popolazione del template con i dati
    PdfStamper stamper = new PdfStamper(pdfTemplate, fileOutputStream);

    stamper.setFormFlattening(true);

    stamper.getAcroFields().setField("nome", immatricolazioneView.getNome().getText());
    stamper.getAcroFields().setField("cognome", immatricolazioneView.getCognome().getText());
    stamper.getAcroFields().setField("matricola", immatricolazioneView.getMatricola().getText());
    stamper.getAcroFields().setField("luogoNascita", immatricolazioneView.getLuogonascita().getText());
    stamper.getAcroFields().setField("dataNascita", immatricolazioneView.getDatanascita().getText());
    stamper.getAcroFields().setField("provinciaNascita", immatricolazioneView.getProvincia().getText());
    stamper.getAcroFields().setField("codiceFiscale", immatricolazioneView.getCodicefiscale().getText());
    stamper.getAcroFields().setField("tipologiaScuolaSuperiore", immatricolazioneView.getDiploma().getText());
    stamper.getAcroFields().setField("voto", immatricolazioneView.getVoto().getText());
    String primaParteAnnoScolastico = immatricolazioneView.getAnnoConseguimento1().getText();
    stamper.getAcroFields().setField("anno1", primaParteAnnoScolastico);
    stamper.getAcroFields().setField("anno2", Integer.toString(Integer.parseInt(primaParteAnnoScolastico) + 1));

    pdfTemplate.close();
    stamper.close();
    fileOutputStream.close();
}
 
开发者ID:ilario-pierbattista,项目名称:studeasy,代码行数:37,代码来源:PdfGenerator.java

示例5: stampPdfFormValues

import com.lowagie.text.pdf.PdfStamper; //导入方法依赖的package包/类
/**
 * Use iText <code>{@link PdfStamper}</code> to stamp information from <code>{@link CashReceiptDocument}</code> into field
 * values on a PDF Form Template.
 * 
 * @param document The cash receipt document the values will be pulled from.
 * @param searchPath The directory path of the template to be used to generate the cover sheet.
 * @param returnStream The output stream the cover sheet will be written to.
 */
protected void stampPdfFormValues(CashReceiptDocument document, String searchPath, OutputStream returnStream) throws Exception {
    String templateName = CR_COVERSHEET_TEMPLATE_NM;

    try {
        // populate form with document values
        
        //KFSMI-7303
        //The PDF template is retrieve through web static URL rather than file path, so the File separator is unnecessary
        final boolean isWebResourcePath = StringUtils.containsIgnoreCase(searchPath, "HTTP");
        
        //skip the File.separator if reference by web resource
        PdfStamper stamper = new PdfStamper(new PdfReader(searchPath + (isWebResourcePath? "" : File.separator) + templateName), returnStream);
        AcroFields populatedCoverSheet = stamper.getAcroFields();
        
        populatedCoverSheet.setField(DOCUMENT_NUMBER_FIELD, document.getDocumentNumber());
        populatedCoverSheet.setField(INITIATOR_FIELD, document.getDocumentHeader().getWorkflowDocument().getInitiatorPrincipalId());
        populatedCoverSheet.setField(CREATED_DATE_FIELD, document.getDocumentHeader().getWorkflowDocument().getDateCreated().toString());
        populatedCoverSheet.setField(AMOUNT_FIELD, document.getTotalDollarAmount().toString());
        populatedCoverSheet.setField(ORG_DOC_NUMBER_FIELD, document.getDocumentHeader().getOrganizationDocumentNumber());
        populatedCoverSheet.setField(CAMPUS_FIELD, document.getCampusLocationCode());
        if (document.getDepositDate() != null) {
            // This value won't be set until the CR document is
            // deposited. A CR document is deposited only when it has
            // been associated with a Cash Management Document (CMD)
            // and with a Deposit within that CMD. And only when the
            // CMD is submitted and FINAL, will the CR documents
            // associated with it, be "deposited." So this value will
            // fill in at an arbitrarily later point in time. So your
            // code shouldn't expect it, but if it's there, then
            // display it.
            populatedCoverSheet.setField(DEPOSIT_DATE_FIELD, document.getDepositDate().toString());
        }
        populatedCoverSheet.setField(DESCRIPTION_FIELD, document.getDocumentHeader().getDocumentDescription());
        populatedCoverSheet.setField(EXPLANATION_FIELD, document.getDocumentHeader().getExplanation());
        populatedCoverSheet.setField(CHECKS_FIELD, document.getTotalCheckAmount().toString());
        populatedCoverSheet.setField(CURRENCY_FIELD, document.getTotalCashAmount().toString());
        populatedCoverSheet.setField(COIN_FIELD, document.getTotalCoinAmount().toString());
        populatedCoverSheet.setField(CHANGE_OUT_FIELD, document.getTotalChangeAmount().toString());
        
        populatedCoverSheet.setField(TOTAL_RECONCILIATION_FIELD, document.getTotalDollarAmount().toString());

        stamper.setFormFlattening(true);
        stamper.close();
    }
    catch (Exception e) {
        LOG.error("Error creating coversheet for: " + document.getDocumentNumber() + ". ::" + e);
        throw e;
    }
}
 
开发者ID:VU-libtech,项目名称:OLE-INST,代码行数:58,代码来源:CashReceiptCoverSheetServiceImpl.java

示例6: stampPdfFormValues

import com.lowagie.text.pdf.PdfStamper; //导入方法依赖的package包/类
/**
 * Use iText <code>{@link PdfStamper}</code> to stamp information from <code>{@link CashReceiptDocument}</code> into field
 * values on a PDF Form Template.
 *
 * @param document The cash receipt document the values will be pulled from.
 * @param searchPath The directory path of the template to be used to generate the cover sheet.
 * @param returnStream The output stream the cover sheet will be written to.
 */
protected void stampPdfFormValues(CashReceiptDocument document, String searchPath, OutputStream returnStream) throws Exception {
    String templateName = CR_COVERSHEET_TEMPLATE_NM;

    try {
        // populate form with document values

        //KFSMI-7303
        //The PDF template is retrieved through web static URL rather than file path, so the File separator is unnecessary
        final boolean isWebResourcePath = StringUtils.containsIgnoreCase(searchPath, "HTTP");

        //skip the File.separator if reference by web resource
        PdfStamper stamper = new PdfStamper(new PdfReader(searchPath + (isWebResourcePath? "" : File.separator) + templateName), returnStream);
        AcroFields populatedCoverSheet = stamper.getAcroFields();

        populatedCoverSheet.setField(DOCUMENT_NUMBER_FIELD, document.getDocumentNumber());
        populatedCoverSheet.setField(INITIATOR_FIELD, document.getDocumentHeader().getWorkflowDocument().getInitiatorPrincipalId());
        populatedCoverSheet.setField(CREATED_DATE_FIELD, document.getDocumentHeader().getWorkflowDocument().getDateCreated().toString());
        populatedCoverSheet.setField(AMOUNT_FIELD, document.getTotalDollarAmount().toString());
        populatedCoverSheet.setField(ORG_DOC_NUMBER_FIELD, document.getDocumentHeader().getOrganizationDocumentNumber());
        populatedCoverSheet.setField(CAMPUS_FIELD, document.getCampusLocationCode());

        if (document.getDepositDate() != null) {
            // This value won't be set until the CR document is
            // deposited. A CR document is deposited only when it has
            // been associated with a Cash Management Document (CMD)
            // and with a Deposit within that CMD. And only when the
            // CMD is submitted and FINAL, will the CR documents
            // associated with it, be "deposited." So this value will
            // fill in at an arbitrarily later point in time. So your
            // code shouldn't expect it, but if it's there, then
            // display it.
            populatedCoverSheet.setField(DEPOSIT_DATE_FIELD, document.getDepositDate().toString());
        }
        populatedCoverSheet.setField(DESCRIPTION_FIELD, document.getDocumentHeader().getDocumentDescription());
        populatedCoverSheet.setField(EXPLANATION_FIELD, document.getDocumentHeader().getExplanation());

        /*
         * We should print original amounts before cash manager approves the CR; after that, we should print confirmed amounts.
         * Note that, in CashReceiptAction.printCoverSheet, it always retrieves the CR from DB, rather than from the current form.
         * Since during CashManagement route node, the CR can't be saved until CM approves/disapproves the document; this means
         * that if CM prints during this route node, he will get the original amounts. This is consistent with our logic here.
         */
        boolean isConfirmed = document.isConfirmed();
        KualiDecimal totalCheckAmount = !isConfirmed ? document.getTotalCheckAmount() : document.getTotalConfirmedCheckAmount();
        KualiDecimal totalCurrencyAmount = !isConfirmed ? document.getTotalCurrencyAmount() : document.getTotalConfirmedCurrencyAmount();
        KualiDecimal totalCoinAmount = !isConfirmed ? document.getTotalCoinAmount() : document.getTotalConfirmedCoinAmount();
        KualiDecimal totalCashInAmount = !isConfirmed ? document.getTotalCashInAmount() : document.getTotalConfirmedCashInAmount();
        KualiDecimal totalMoneyInAmount = !isConfirmed ? document.getTotalMoneyInAmount() : document.getTotalConfirmedMoneyInAmount();
        KualiDecimal totalChangeCurrencyAmount = !isConfirmed ? document.getTotalChangeCurrencyAmount() : document.getTotalConfirmedChangeCurrencyAmount();
        KualiDecimal totalChangeCoinAmount = !isConfirmed ? document.getTotalChangeCoinAmount() : document.getTotalConfirmedChangeCoinAmount();
        KualiDecimal totalChangeAmount = !isConfirmed ? document.getTotalChangeAmount() : document.getTotalConfirmedChangeAmount();
        KualiDecimal totalNetAmount = !isConfirmed ? document.getTotalNetAmount() : document.getTotalConfirmedNetAmount();

        populatedCoverSheet.setField(CHECKS_FIELD, totalCheckAmount.toString());
        populatedCoverSheet.setField(CURRENCY_FIELD, totalCurrencyAmount.toString());
        populatedCoverSheet.setField(COIN_FIELD, totalCoinAmount.toString());
        populatedCoverSheet.setField(CASH_IN_FIELD, totalCashInAmount.toString());
        populatedCoverSheet.setField(MONEY_IN_FIELD, totalMoneyInAmount.toString());
        populatedCoverSheet.setField(CHANGE_CURRENCY_FIELD, totalChangeCurrencyAmount.toString());
        populatedCoverSheet.setField(CHANGE_COIN_FIELD, totalChangeCoinAmount.toString());
        populatedCoverSheet.setField(CHANGE_OUT_FIELD, totalChangeAmount.toString());
        populatedCoverSheet.setField(RECONCILIATION_TOTAL_FIELD, totalNetAmount.toString());

        stamper.setFormFlattening(true);
        stamper.close();
    }
    catch (Exception e) {
        LOG.error("Error creating coversheet for: " + document.getDocumentNumber() + ". ::" + e);
        throw e;
    }
}
 
开发者ID:kuali,项目名称:kfs,代码行数:80,代码来源:CashReceiptCoverSheetServiceImpl.java


注:本文中的com.lowagie.text.pdf.PdfStamper.setFormFlattening方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。