• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java PdfCopyFields类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.lowagie.text.pdf.PdfCopyFields的典型用法代码示例。如果您正苦于以下问题:Java PdfCopyFields类的具体用法?Java PdfCopyFields怎么用?Java PdfCopyFields使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



PdfCopyFields类属于com.lowagie.text.pdf包,在下文中一共展示了PdfCopyFields类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: extractPages

import com.lowagie.text.pdf.PdfCopyFields; //导入依赖的package包/类
/**
 * 
 * @param pdfOut
 * @param pdfIn
 * @param pagesToDelete
 * @throws Exception
 */
public static void extractPages(OutputStream pdfOut,InputStream pdfIn, int[] pages) throws Exception{
	
	if (pages.length <= 0) {
           throw new Exception("Debe eliminar al menos una p�gina");
       }
		
	List pagesToKeep = new ArrayList();
	for (int i=0;i<pages.length;i++){
		pagesToKeep.add(new Integer(pages[i]));
	}
	
	
       PdfCopyFields  writer = new PdfCopyFields(pdfOut);
       int permission=0;
     
       PdfReader reader = new PdfReader(pdfIn);
       permission = reader.getPermissions();
       if (permission != 0){
       	writer.setEncryption(null, null,permission, PdfWriter.STRENGTH40BITS);
       }
    writer.addDocument(reader,pagesToKeep);
       
       writer.close();
           
    }
 
开发者ID:GovernIB,项目名称:sistra,代码行数:33,代码来源:UtilPDF.java


示例2: main

import com.lowagie.text.pdf.PdfCopyFields; //导入依赖的package包/类
/**
	 * Concatenates 2 PDF files with forms. The resulting PDF has 1 merged
	 * AcroForm.
	 * 
	 * @param args
	 *            no arguments needed
	 */
	public static void main(String[] args) {
		try {
			//Can't use filename directly
//			PdfReader reader1 = new PdfReader("SimpleRegistrationForm.pdf");
//			PdfReader reader2 = new PdfReader("TextFields.pdf");
			PdfReader reader1 = new PdfReader(PdfTestRunner.getActivity().getResources().openRawResource(R.raw.simpleregistrationform));
			PdfReader reader2 = new PdfReader(PdfTestRunner.getActivity().getResources().openRawResource(R.raw.textfields));
			PdfCopyFields copy = new PdfCopyFields(new FileOutputStream(android.os.Environment.getExternalStorageDirectory() + java.io.File.separator + "droidtext" + java.io.File.separator + "concatenatedforms.pdf"));
			copy.addDocument(reader1);
			copy.addDocument(reader2);
			copy.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
 
开发者ID:fc-dream,项目名称:PDFTestForAndroid,代码行数:23,代码来源:ConcatenateForms.java


示例3: main

import com.lowagie.text.pdf.PdfCopyFields; //导入依赖的package包/类
/**
 * Concatenates 2 PDF files with forms. The resulting PDF has 1 merged AcroForm.
 */
@Test
public void main() throws Exception{
		PdfReader reader1 = new PdfReader(PdfTestBase.RESOURCES_DIR + "SimpleRegistrationForm.pdf");
		PdfReader reader2 = new PdfReader(PdfTestBase.RESOURCES_DIR + "TextFields.pdf");
		PdfCopyFields copy = new PdfCopyFields(PdfTestBase.getOutputStream("concatenatedforms.pdf"));
		copy.addDocument(reader1);
		copy.addDocument(reader2);
		copy.close();
}
 
开发者ID:albfernandez,项目名称:itext2,代码行数:13,代码来源:ConcatenateFormsTest.java


示例4: concatenarPdf

import com.lowagie.text.pdf.PdfCopyFields; //导入依赖的package包/类
/**
 * Concatena varios pdfs
 * @param pdfOut Outputstream al pdf de salida
 * @param pdfIn InputStreams de los pdfs a concatenar
 */
public static void concatenarPdf(OutputStream pdfOut,InputStream [] pdfIn) throws Exception{
	if (pdfIn.length < 2) {
           throw new Exception("Debe concatenar al menos 2 PDFs");
       }
	
	// Realizamos copia PDFs        
       int f = 0;
       
       PdfCopyFields  writer = new PdfCopyFields(pdfOut);
       int permission=0;
       while (f < pdfIn.length) {
           // we create a reader for a certain document
           PdfReader reader = new PdfReader(pdfIn[f]);            
           // Establecemos permisos del primer documento
           if (f==0){
           	permission = reader.getPermissions();
           	if (permission != 0){
           		writer.setEncryption(null, null,permission, PdfWriter.STRENGTH40BITS);
           	}
           }
                       
           writer.addDocument(reader);
                       
           f++;
       }
       
       writer.close();
           
    }
 
开发者ID:GovernIB,项目名称:sistra,代码行数:35,代码来源:UtilPDF.java


示例5: generateCombinedPdfForInvoices

import com.lowagie.text.pdf.PdfCopyFields; //导入依赖的package包/类
/**
 * Generates the pdf file for printing the invoices.
 *
 * @param list
 * @param outputStream
 * @throws DocumentException
 * @throws IOException
 */
protected void generateCombinedPdfForInvoices(Collection<ContractsGrantsInvoiceDocument> list, OutputStream outputStream) throws DocumentException, IOException {
    PdfCopyFields copy = new PdfCopyFields(outputStream);
    boolean pageAdded = false;
    for (ContractsGrantsInvoiceDocument invoice : list) {
        // add a document
        List<InvoiceAddressDetail> invoiceAddressDetails = invoice.getInvoiceAddressDetails();

        for (InvoiceAddressDetail invoiceAddressDetail : invoiceAddressDetails) {
            if (ArConstants.InvoiceTransmissionMethod.MAIL.equals(invoiceAddressDetail.getInvoiceTransmissionMethodCode())) {
                Note note = noteService.getNoteByNoteId(invoiceAddressDetail.getNoteId());
                Integer numberOfCopiesToPrint = invoiceAddressDetail.getCustomerAddress().getCustomerCopiesToPrint();
                if (ObjectUtils.isNull(numberOfCopiesToPrint)) {
                    numberOfCopiesToPrint = 1;
                }

                if (!ObjectUtils.isNull(note)) {
                    for (int i = 0; i < numberOfCopiesToPrint; i++) {
                        if (!pageAdded) {
                            copy.open();
                        }
                        pageAdded = true;
                        copy.addDocument(new PdfReader(note.getAttachment().getAttachmentContents()));
                    }
                }
                invoiceAddressDetail.setInitialTransmissionDate(new Date(new java.util.Date().getTime()));
            }
        }
        documentService.updateDocument(invoice);
    }
    if (pageAdded) {
        copy.close();
    }
}
 
开发者ID:kuali,项目名称:kfs,代码行数:42,代码来源:ContractsGrantsInvoiceReportServiceImpl.java


示例6: generateCombinedPdfForInvoices

import com.lowagie.text.pdf.PdfCopyFields; //导入依赖的package包/类
/**
 * Generates the pdf file for printing the invoices.
 *
 * @param list
 * @param outputStream
 * @throws DocumentException
 * @throws IOException
 */
protected void generateCombinedPdfForInvoices(Collection<ContractsGrantsInvoiceDocument> list, byte[] report, OutputStream outputStream) throws DocumentException, IOException {
    PdfCopyFields copy = new PdfCopyFields(outputStream);
    copy.open();
    copy.addDocument(new PdfReader(report));
    for (ContractsGrantsInvoiceDocument invoice : list) {
        for (InvoiceAddressDetail invoiceAddressDetail : invoice.getInvoiceAddressDetails()) {
            Note note = noteService.getNoteByNoteId(invoiceAddressDetail.getNoteId());
            if (ObjectUtils.isNotNull(note) && note.getAttachment().getAttachmentFileSize() > 0) {
                copy.addDocument(new PdfReader(note.getAttachment().getAttachmentContents()));
            }
        }
    }
    copy.close();
}
 
开发者ID:kuali,项目名称:kfs,代码行数:23,代码来源:DunningLetterServiceImpl.java


示例7: stampPdfFormValues425A

import com.lowagie.text.pdf.PdfCopyFields; //导入依赖的package包/类
/**
 * Use iText <code>{@link PdfStamper}</code> to stamp information into field values on a PDF Form Template.
 *
 * @param agency The award the values will be pulled from.
 * @param reportingPeriod
 * @param year
 * @param returnStream The output stream the federal form will be written to.
 */
protected void stampPdfFormValues425A(ContractsAndGrantsBillingAgency agency, String reportingPeriod, String year, OutputStream returnStream, Map<String, String> replacementList) {
    String federalReportTemplatePath = configService.getPropertyValueAsString(KFSConstants.EXTERNALIZABLE_HELP_URL_KEY);
    try {
        final String federal425ATemplateUrl = federalReportTemplatePath + ArConstants.FF_425A_TEMPLATE_NM + KFSConstants.ReportGeneration.PDF_FILE_EXTENSION;
        final String federal425TemplateUrl = federalReportTemplatePath + ArConstants.FF_425_TEMPLATE_NM + KFSConstants.ReportGeneration.PDF_FILE_EXTENSION;

        Map<String, Object> fieldValues = new HashMap<>();
        fieldValues.put(KFSPropertyConstants.AGENCY_NUMBER, agency.getAgencyNumber());
        fieldValues.put(KFSPropertyConstants.ACTIVE, Boolean.TRUE);
        List<ContractsAndGrantsBillingAward> awards = kualiModuleService.getResponsibleModuleService(ContractsAndGrantsBillingAward.class).getExternalizableBusinessObjectsList(ContractsAndGrantsBillingAward.class, fieldValues);
        Integer pageNumber = 1, totalPages;
        totalPages = (awards.size() / ArConstants.Federal425APdf.NUMBER_OF_SUMMARIES_PER_PAGE) + 1;
        PdfCopyFields copy = new PdfCopyFields(returnStream);

        // generate replacement list for FF425
        populateListByAgency(awards, reportingPeriod, year, agency);
        contractsGrantsBillingUtilityService.putValueOrEmptyString(replacementList, ArPropertyConstants.FederalFormReportFields.TOTAL_PAGES, org.apache.commons.lang.ObjectUtils.toString(totalPages + 1));
        KualiDecimal sumCashControl = KualiDecimal.ZERO;
        KualiDecimal sumCumExp = KualiDecimal.ZERO;
        while (pageNumber <= totalPages) {
            List<ContractsAndGrantsBillingAward> awardsList = new ArrayList<ContractsAndGrantsBillingAward>();
            for (int i = ((pageNumber - 1) * ArConstants.Federal425APdf.NUMBER_OF_SUMMARIES_PER_PAGE); i < (pageNumber * ArConstants.Federal425APdf.NUMBER_OF_SUMMARIES_PER_PAGE); i++) {
                if (i < awards.size()) {
                    awardsList.add(awards.get(i));
                }
            }
            // generate replacement list for FF425
            List<KualiDecimal> list = populateListByAgency(awardsList, reportingPeriod, year, agency);
            if (CollectionUtils.isNotEmpty(list)){
                sumCashControl = sumCashControl.add(list.get(0));
                if (list.size() > 1){
                    sumCumExp = sumCumExp.add(list.get(1));
                }
            }

            // populate form with document values
            contractsGrantsBillingUtilityService.putValueOrEmptyString(replacementList, ArPropertyConstants.FederalFormReportFields.PAGE_NUMBER, org.apache.commons.lang.ObjectUtils.toString(pageNumber + 1));
            if (pageNumber == totalPages){
                contractsGrantsBillingUtilityService.putValueOrEmptyString(replacementList, ArPropertyConstants.FederalFormReportFields.TOTAL, contractsGrantsBillingUtilityService.formatForCurrency(sumCashControl));
                contractsGrantsBillingUtilityService.putValueOrEmptyString(replacementList, ArPropertyConstants.FederalFormReportFields.CASH_RECEIPTS, contractsGrantsBillingUtilityService.formatForCurrency(sumCashControl));
                contractsGrantsBillingUtilityService.putValueOrEmptyString(replacementList, ArPropertyConstants.FederalFormReportFields.CASH_DISBURSEMENTS, contractsGrantsBillingUtilityService.formatForCurrency(sumCumExp));
                contractsGrantsBillingUtilityService.putValueOrEmptyString(replacementList, ArPropertyConstants.FederalFormReportFields.CASH_ON_HAND, contractsGrantsBillingUtilityService.formatForCurrency(sumCashControl.subtract(sumCumExp)));
            }
            // add a document
            copy.addDocument(new PdfReader(renameFieldsIn(federal425ATemplateUrl, replacementList)));
            pageNumber++;
        }
        contractsGrantsBillingUtilityService.putValueOrEmptyString(replacementList, ArPropertyConstants.FederalFormReportFields.PAGE_NUMBER, "1");

        // add the FF425 form.
        copy.addDocument(new PdfReader(renameFieldsIn(federal425TemplateUrl, replacementList)));
        // Close the PdfCopyFields object
        copy.close();
    }
    catch (DocumentException | IOException ex) {
        throw new RuntimeException("Tried to stamp the 425A, but couldn't do it.  Just...just couldn't do it.", ex);
    }
}
 
开发者ID:kuali,项目名称:kfs,代码行数:67,代码来源:ContractsGrantsInvoiceReportServiceImpl.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java DocCommentScanner类代码示例发布时间:2022-05-23
下一篇:
Java RetireJobInfo类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap