本文整理汇总了Java中com.lowagie.text.pdf.PdfReader类的典型用法代码示例。如果您正苦于以下问题:Java PdfReader类的具体用法?Java PdfReader怎么用?Java PdfReader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PdfReader类属于com.lowagie.text.pdf包,在下文中一共展示了PdfReader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: encrypt
import com.lowagie.text.pdf.PdfReader; //导入依赖的package包/类
public static void encrypt(PDFDocument doc, OutputStream os, String newUserPassword, String newOwnerPassword, int permissions, int encryption) throws ApplicationException, DocumentException, IOException {
byte[] user = newUserPassword==null?null:newUserPassword.getBytes();
byte[] owner = newOwnerPassword==null?null:newOwnerPassword.getBytes();
PdfReader pr = doc.getPdfReader();
List bookmarks = SimpleBookmark.getBookmark(pr);
int n = pr.getNumberOfPages();
Document document = new Document(pr.getPageSizeWithRotation(1));
PdfCopy writer = new PdfCopy(document, os);
if(encryption!=ENCRYPT_NONE)writer.setEncryption(user, owner, permissions, encryption);
document.open();
PdfImportedPage page;
for (int i = 1; i <= n; i++) {
page = writer.getImportedPage(pr, i);
writer.addPage(page);
}
PRAcroForm form = pr.getAcroForm();
if (form != null)writer.copyAcroForm(pr);
if (bookmarks!=null)writer.setOutlines(bookmarks);
document.close();
}
开发者ID:lucee,项目名称:Lucee4,代码行数:25,代码来源:PDFUtil.java示例2: getContentBytesFromPdfObject
import com.lowagie.text.pdf.PdfReader; //导入依赖的package包/类
public static byte[] getContentBytesFromPdfObject(PdfObject object) throws IOException {
switch (object.type()) {
case PdfObject.INDIRECT:
return getContentBytesFromPdfObject(PdfReader.getPdfObject(object));
case PdfObject.STREAM:
return PdfReader.getStreamBytes((PRStream) PdfReader.getPdfObject(object));
case PdfObject.ARRAY:
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ListIterator<PdfObject> iter = ((PdfArray) object).listIterator();
while (iter.hasNext()) {
PdfObject element = iter.next();
baos.write(getContentBytesFromPdfObject(element));
}
return baos.toByteArray();
default:
throw new IllegalStateException("Unsupported type: " + object.getClass().getCanonicalName());
}
}
开发者ID:albfernandez,项目名称:itext2,代码行数:19,代码来源:PdfContentStreamProcessor.java示例3: main
import com.lowagie.text.pdf.PdfReader; //导入依赖的package包/类
/**
* Merges an XFDF file with a PDF form.
*/
@Test
public void main() throws Exception {
// merging the FDF file
PdfReader pdfreader = new PdfReader(PdfTestBase.RESOURCES_DIR + "SimpleRegistrationForm.pdf");
PdfStamper stamp = new PdfStamper(pdfreader, PdfTestBase.getOutputStream("registered_xfdf.pdf"));
XfdfReader fdfreader = new XfdfReader(PdfTestBase.RESOURCES_DIR + "register.xfdf");
AcroFields form = stamp.getAcroFields();
form.setFields(fdfreader);
stamp.close();
}
开发者ID:albfernandez,项目名称:itext2,代码行数:16,代码来源:XfdfExampleTest.java示例4: main
import com.lowagie.text.pdf.PdfReader; //导入依赖的package包/类
/**
* Writes an FDF file and merges it with a PDF form.
*/
@Test
public void main() throws Exception {
// writing the FDF file
FdfWriter fdf = new FdfWriter();
fdf.setFieldAsString("name", "Bruno Lowagie");
fdf.setFieldAsString("address", "Baeyensstraat 121, Sint-Amandsberg");
fdf.setFieldAsString("postal_code", "BE-9040");
fdf.setFieldAsString("email", "[email protected]");
fdf.setFile(PdfTestBase.RESOURCES_DIR + "SimpleRegistrationForm.pdf");
fdf.writeTo(PdfTestBase.getOutputStream("SimpleRegistrationForm.fdf"));
// merging the FDF file
PdfReader pdfreader = new PdfReader(PdfTestBase.RESOURCES_DIR + "SimpleRegistrationForm.pdf");
PdfStamper stamp = new PdfStamper(pdfreader, PdfTestBase.getOutputStream("registered_fdf.pdf"));
FdfReader fdfreader = new FdfReader(PdfTestBase.OUTPUT_DIR + "SimpleRegistrationForm.fdf");
AcroFields form = stamp.getAcroFields();
form.setFields(fdfreader);
stamp.close();
}
开发者ID:albfernandez,项目名称:itext2,代码行数:25,代码来源:FdfExampleTest.java示例5: obtenirDadesCertificatPdf
import com.lowagie.text.pdf.PdfReader; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private List<DadesCertificat> obtenirDadesCertificatPdf(
byte[] signatura) throws Exception {
PdfReader reader = new PdfReader(new ByteArrayInputStream(signatura));
AcroFields af = reader.getAcroFields();
ArrayList<String> names = af.getSignatureNames();
for (String name: names) {
PdfPKCS7 pk = af.verifySignature(name);
Certificate pkc[] = pk.getCertificates();
List<DadesCertificat> dadesCertificats = new ArrayList<DadesCertificat>();
for (Certificate cert: pkc) {
if (cert instanceof X509Certificate) {
int basicConstraints = ((X509Certificate)cert).getBasicConstraints();
// Només afegeix els certificats que no son de CA
if (basicConstraints == -1)
dadesCertificats.add(getDadesCertificat((X509Certificate)cert));
}
}
return dadesCertificats;
}
return null;
}
开发者ID:GovernIB,项目名称:helium,代码行数:23,代码来源:SignaturaPluginTest.java示例6: extractPages
import com.lowagie.text.pdf.PdfReader; //导入依赖的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示例7: countNumOfPages
import com.lowagie.text.pdf.PdfReader; //导入依赖的package包/类
public static int countNumOfPages(String fileName) {// count number of pages in a local pdf file
int numOfPage = 0;
String docdownload = oscar.OscarProperties.getInstance().getProperty("DOCUMENT_DIR");
if (!docdownload.endsWith(File.separator))
{
docdownload += File.separator;
}
String filePath = docdownload + fileName;
try {
PdfReader reader = new PdfReader(filePath);
numOfPage = reader.getNumberOfPages();
reader.close();
} catch (IOException e) {
MiscUtils.getLogger().error("Error", e);
}
return numOfPage;
}
开发者ID:williamgrosset,项目名称:OSCAR-ConCert,代码行数:21,代码来源:AddEditDocumentAction.java示例8: countNumOfPages
import com.lowagie.text.pdf.PdfReader; //导入依赖的package包/类
/**
* Counts the number of pages in a local pdf file.
* @param fileName the name of the file
* @return the number of pages in the file
*/
public int countNumOfPages(String fileName) {// count number of pages in a
// local pdf file
int numOfPage = 0;
String docdownload = oscar.OscarProperties.getInstance().getProperty("DOCUMENT_DIR");
String filePath = docdownload + fileName;
try {
PdfReader reader = new PdfReader(filePath);
numOfPage = reader.getNumberOfPages();
reader.close();
} catch (IOException e) {
logger.debug(e.toString());
}
return numOfPage;
}
开发者ID:williamgrosset,项目名称:OSCAR-ConCert,代码行数:21,代码来源:DocumentUploadAction.java示例9: toPdfReader
import com.lowagie.text.pdf.PdfReader; //导入依赖的package包/类
public static PdfReader toPdfReader(PageContext pc,Object value, String password) throws IOException, PageException {
if(value instanceof PdfReader) return (PdfReader) value;
if(value instanceof PDFDocument) return ((PDFDocument) value).getPdfReader();
if(Decision.isBinary(value)){
if(password!=null)return new PdfReader(Caster.toBinary(value),password.getBytes());
return new PdfReader(Caster.toBinary(value));
}
if(value instanceof Resource) {
if(password!=null)return new PdfReader(IOUtil.toBytes((Resource)value),password.getBytes());
return new PdfReader(IOUtil.toBytes((Resource)value));
}
if(value instanceof String) {
if(password!=null)return new PdfReader(IOUtil.toBytes(Caster.toResource(pc,value,true)),password.getBytes());
return new PdfReader(IOUtil.toBytes((Resource)value));
}
throw new CasterException(value,PdfReader.class);
}
开发者ID:lucee,项目名称:Lucee4,代码行数:18,代码来源:PDFUtil.java示例10: modifyPdf
import com.lowagie.text.pdf.PdfReader; //导入依赖的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示例11: testAutoRegisterJasperReportsExecuteReport
import com.lowagie.text.pdf.PdfReader; //导入依赖的package包/类
@Test
public void testAutoRegisterJasperReportsExecuteReport() throws Exception {
JasperReport report1 = (JasperReport) JRLoader.loadObject(getClass().getClassLoader().getResource(TEST_REPORT_1));
Hashtable<String, Object> properties = new Hashtable<String, Object>();
properties.put(Constants.SERVICE_RANKING, 0);
properties.put(org.openeos.reporting.jasperreports.Constants.SERVICE_REPORT_ID, TEST_REPORT_1);
ServiceRegistration<JasperReport> register1 = bc.registerService(JasperReport.class, report1, properties);
HashMap<String, Object> parameters = new HashMap<String, Object>();
parameters.put(JRParameter.REPORT_DATA_SOURCE, new JRBeanCollectionDataSource(createSampleBeans()));
InputStream result = reportingService.generateReport(TEST_REPORT_1, "application/pdf", parameters);
PdfReader reader = new PdfReader(result);
assertEquals(1, reader.getNumberOfPages());
reader.close();
register1.unregister();
}
开发者ID:frincon,项目名称:openeos,代码行数:18,代码来源:OsgiTestCase.java示例12: testEntityReportingService
import com.lowagie.text.pdf.PdfReader; //导入依赖的package包/类
@Test
public void testEntityReportingService() throws Exception {
JasperReport report = (JasperReport) JRLoader.loadObject(getClass().getClassLoader().getResource(TEST_REPORT_BEAN));
Hashtable<String, Object> properties = new Hashtable<String, Object>();
properties.put(Constants.SERVICE_RANKING, 0);
properties.put(org.openeos.reporting.jasperreports.Constants.SERVICE_REPORT_ID, TEST_REPORT_ID);
ServiceRegistration<JasperReport> register1 = bc.registerService(JasperReport.class, report, properties);
InputStream result = entityReportingService.generateReport(TEST_REPORT_ID, BusinessPartner.class, bpDAO.findAll());
PdfReader reader = new PdfReader(result);
assertEquals(1, reader.getNumberOfPages());
assertTrue(findPdfString(reader, "testField"));
reader.close();
register1.unregister();
}
开发者ID:frincon,项目名称:openeos,代码行数:21,代码来源:OsgiTestCase.java示例13: testReport
import com.lowagie.text.pdf.PdfReader; //导入依赖的package包/类
private void testReport(String reportName) throws Exception {
JasperReport report = (JasperReport) JRLoader.loadObject(getClass().getClassLoader().getResource(reportName));
Hashtable<String, Object> properties = new Hashtable<String, Object>();
properties.put(Constants.SERVICE_RANKING, 0);
properties.put(org.openeos.reporting.jasperreports.Constants.SERVICE_REPORT_ID, TEST_REPORT_ID);
ServiceRegistration<JasperReport> register1 = bc.registerService(JasperReport.class, report, properties);
HashMap<String, Object> parameters = new HashMap<String, Object>();
parameters.put(org.openeos.reporting.jasperreports.entity.Constants.PARAMETER_IS_ENTITY_REPORT, true);
parameters.put(org.openeos.reporting.jasperreports.entity.Constants.PARAMETER_ENTITY_COLLECTION, bpDAO.findAll());
parameters.put(org.openeos.reporting.jasperreports.entity.Constants.PARAMETER_ENTITY_CLASS, BusinessPartner.class);
InputStream result = reportingService.generateReport(TEST_REPORT_ID, "application/pdf", parameters);
PdfReader reader = new PdfReader(result);
assertEquals(1, reader.getNumberOfPages());
assertTrue(findPdfString(reader, "testField"));
reader.close();
register1.unregister();
}
开发者ID:frincon,项目名称:openeos,代码行数:24,代码来源:OsgiTestCase.java示例14: generateCoverSheet
import com.lowagie.text.pdf.PdfReader; //导入依赖的package包/类
/**
* Generate a cover sheet for the <code>{@link CashReceiptDocument}</code>. An <code>{@link OutputStream}</code> is written
* to for the cover sheet.
*
* @param document The cash receipt document the cover sheet is for.
* @param searchPath The directory path to the template to be used to generate the cover sheet.
* @param returnStream The output stream the cover sheet will be written to.
* @exception DocumentException Thrown if the document provided is invalid, including null.
* @exception IOException Thrown if there is a problem writing to the output stream.
* @see org.kuali.rice.kns.module.financial.service.CashReceiptCoverSheetServiceImpl#generateCoverSheet(
* org.kuali.module.financial.documentCashReceiptDocument )
*/
public void generateCoverSheet(CashReceiptDocument document, String searchPath, OutputStream returnStream) throws Exception {
if (isCoverSheetPrintingAllowed(document)) {
ByteArrayOutputStream stamperStream = new ByteArrayOutputStream();
stampPdfFormValues(document, searchPath, stamperStream);
PdfReader reader = new PdfReader(stamperStream.toByteArray());
Document pdfDoc = new Document(reader.getPageSize(FRONT_PAGE));
PdfWriter writer = PdfWriter.getInstance(pdfDoc, returnStream);
pdfDoc.open();
populateCheckDetail(document, writer, reader);
pdfDoc.close();
writer.close();
}
}
开发者ID:VU-libtech,项目名称:OLE-INST,代码行数:30,代码来源:CashReceiptCoverSheetServiceImpl.java示例15: populateCheckDetail
import com.lowagie.text.pdf.PdfReader; //导入依赖的package包/类
/**
* Method responsible for producing Check Detail section of the cover sheet. Not all Cash Receipt documents have checks.
*
* @param crDoc The CashReceipt document the cover sheet is being created for.
* @param writer The output writer used to write the check data to the PDF file.
* @param reader The input reader used to read data from the PDF file.
*/
protected void populateCheckDetail(CashReceiptDocument crDoc, PdfWriter writer, PdfReader reader) throws Exception {
PdfContentByte content;
ModifiableInteger pageNumber;
int checkCount = 0;
int maxCheckCount = MAX_CHECKS_FIRST_PAGE;
pageNumber = new ModifiableInteger(0);
content = startNewPage(writer, reader, pageNumber);
for (Check current : crDoc.getChecks()) {
writeCheckNumber(content, current);
writeCheckDate(content, current);
writeCheckDescription(content, current);
writeCheckAmount(content, current);
setCurrentRenderingYPosition(getCurrentRenderingYPosition() - CHECK_FIELD_HEIGHT);
checkCount++;
if (checkCount > maxCheckCount) {
checkCount = 0;
maxCheckCount = MAX_CHECKS_NORMAL;
content = startNewPage(writer, reader, pageNumber);
}
}
}
开发者ID:VU-libtech,项目名称:OLE-INST,代码行数:33,代码来源:CashReceiptCoverSheetServiceImpl.java本文标签属性:
示例:示例志愿表
代码:代码大全可复制
java:javascript18岁