本文整理汇总了Java中com.lowagie.text.ExceptionConverter类的典型用法代码示例。如果您正苦于以下问题:Java ExceptionConverter类的具体用法?Java ExceptionConverter怎么用?Java ExceptionConverter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ExceptionConverter类属于com.lowagie.text包,在下文中一共展示了ExceptionConverter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: XmpReader
import com.lowagie.text.ExceptionConverter; //导入依赖的package包/类
/**
* Constructs an XMP reader
* @param bytes the XMP content
* @throws ExceptionConverter
* @throws IOException
* @throws SAXException
*/
public XmpReader(byte[] bytes) throws SAXException, IOException {
try {
DocumentBuilderFactory fact = DocumentBuilderFactory.newInstance();
fact.setNamespaceAware(true);
DocumentBuilder db = fact.newDocumentBuilder();
db.setEntityResolver(new EntityResolver() {
@Override
public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
return new InputSource(new StringReader(""));
}
});
ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
domDocument = db.parse(bais);
} catch (ParserConfigurationException e) {
throw new ExceptionConverter(e);
}
}
示例2: go
import com.lowagie.text.ExceptionConverter; //导入依赖的package包/类
/**
* Parses a given file.
* @param document The document that will listen to the parser
* @param is The InputStream with the contents
*/
public void go(DocListener document, InputSource is) {
try {
parser.parse(is, new SAXiTextHandler(document));
}
catch(SAXException se) {
throw new ExceptionConverter(se);
}
catch(IOException ioe) {
throw new ExceptionConverter(ioe);
}
}
示例3: onEndPage
import com.lowagie.text.ExceptionConverter; //导入依赖的package包/类
/**
* @see com.lowagie.text.pdf.PdfPageEventHelper#onEndPage(com.lowagie.text.pdf.PdfWriter, com.lowagie.text.Document)
*/
public void onEndPage(PdfWriter writer, Document document) {
try {
Rectangle page = document.getPageSize();
if (headerFooterPolicy.getHeader(writer.getPageNumber())!=null) {
Hdr hdr = headerFooterPolicy.getHeader(writer.getPageNumber()).getJaxbElement();
PdfPTable head = new PdfPTable(1); // num cols
// TODO - no cell borders
traverseBlockLevelContent( hdr.getEGBlockLevelElts(), head);
head.setTotalWidth(page.getWidth() - document.leftMargin() - document.rightMargin());
head.writeSelectedRows(0, -1, document.leftMargin(), page.getHeight() - document.topMargin() + head.getTotalHeight(),
writer.getDirectContent());
}
if (headerFooterPolicy.getFooter(writer.getPageNumber())!=null) {
Ftr ftr = headerFooterPolicy.getFooter(writer.getPageNumber()).getJaxbElement();
PdfPTable foot = new PdfPTable(1);
traverseBlockLevelContent( ftr.getEGBlockLevelElts(), foot);
foot.setTotalWidth(page.getWidth() - document.leftMargin() - document.rightMargin());
foot.writeSelectedRows(0, -1, document.leftMargin(), document.bottomMargin(),
writer.getDirectContent());
}
}
catch (Exception e) {
throw new ExceptionConverter(e);
}
}
示例4: setSignInfo
import com.lowagie.text.ExceptionConverter; //导入依赖的package包/类
/**
* Sets the crypto information to sign.
* @param privKey the private key
* @param certChain the certificate chain
* @param crlList the certificate revocation list. It can be <CODE>null</CODE>
*/
public void setSignInfo(PrivateKey privKey, Certificate[] certChain, CRL[] crlList) {
try {
pkcs = new PdfPKCS7(privKey, certChain, crlList, hashAlgorithm, provider, PdfName.ADBE_PKCS7_SHA1.equals(get(PdfName.SUBFILTER)));
pkcs.setExternalDigest(externalDigest, externalRSAdata, digestEncryptionAlgorithm);
if (PdfName.ADBE_X509_RSA_SHA1.equals(get(PdfName.SUBFILTER))) {
ByteArrayOutputStream bout = new ByteArrayOutputStream();
for (int k = 0; k < certChain.length; ++k) {
bout.write(certChain[k].getEncoded());
}
bout.close();
setCert(bout.toByteArray());
setContents(pkcs.getEncodedPKCS1());
}
else
setContents(pkcs.getEncodedPKCS7());
name = PdfPKCS7.getSubjectFields(pkcs.getSigningCertificate()).getField("CN");
if (name != null)
put(PdfName.NAME, new PdfString(name, PdfObject.TEXT_UNICODE));
pkcs = new PdfPKCS7(privKey, certChain, crlList, hashAlgorithm, provider, PdfName.ADBE_PKCS7_SHA1.equals(get(PdfName.SUBFILTER)));
pkcs.setExternalDigest(externalDigest, externalRSAdata, digestEncryptionAlgorithm);
}
catch (Exception e) {
throw new ExceptionConverter(e);
}
}
示例5: getPdfObject
import com.lowagie.text.ExceptionConverter; //导入依赖的package包/类
/**
* @param idx
* @return aPdfObject
*/
public PdfObject getPdfObject(int idx) {
try {
lastXrefPartial = -1;
if (idx < 0 || idx >= xrefObj.size())
return null;
PdfObject obj = (PdfObject)xrefObj.get(idx);
if (!partial || obj != null)
return obj;
if (idx * 2 >= xref.length)
return null;
obj = readSingleObject(idx);
lastXrefPartial = -1;
if (obj != null)
lastXrefPartial = idx;
return obj;
}
catch (Exception e) {
throw new ExceptionConverter(e);
}
}
示例6: OutputStreamEncryption
import com.lowagie.text.ExceptionConverter; //导入依赖的package包/类
/** Creates a new instance of OutputStreamCounter */
public OutputStreamEncryption(OutputStream out, byte key[], int off, int len, int revision) {
try {
this.out = out;
aes = revision == AES_128;
if (aes) {
byte[] iv = IVGenerator.getIV();
byte[] nkey = new byte[len];
System.arraycopy(key, off, nkey, 0, len);
cipher = new AESCipher(true, nkey, iv);
write(iv);
}
else {
arcfour = new ARCFOUREncryption();
arcfour.prepareARCFOURKey(key, off, len);
}
} catch (Exception ex) {
throw new ExceptionConverter(ex);
}
}
示例7: PdfICCBased
import com.lowagie.text.ExceptionConverter; //导入依赖的package包/类
/**
* Creates an ICC stream.
*
* @param compressionLevel the compressionLevel
*
* @param profile an ICC profile
* @since 2.1.3 (replacing the constructor without param compressionLevel)
*/
public PdfICCBased(ICC_Profile profile, int compressionLevel) {
super();
try {
int numberOfComponents = profile.getNumComponents();
switch (numberOfComponents) {
case 1:
put(PdfName.ALTERNATE, PdfName.DEVICEGRAY);
break;
case 3:
put(PdfName.ALTERNATE, PdfName.DEVICERGB);
break;
case 4:
put(PdfName.ALTERNATE, PdfName.DEVICECMYK);
break;
default:
throw new PdfException(numberOfComponents + " component(s) is not supported in PDF1.4");
}
put(PdfName.N, new PdfNumber(numberOfComponents));
bytes = profile.getData();
flateCompress(compressionLevel);
} catch (Exception e) {
throw new ExceptionConverter(e);
}
}
示例8: Barcode39
import com.lowagie.text.ExceptionConverter; //导入依赖的package包/类
/** Creates a new Barcode39.
*/
public Barcode39() {
try {
x = 0.8f;
n = 2;
font = BaseFont.createFont("Helvetica", "winansi", false);
size = 8;
baseline = size;
barHeight = size * 3;
textAlignment = Element.ALIGN_CENTER;
generateChecksum = false;
checksumText = false;
startStopText = true;
extended = false;
}
catch (Exception e) {
throw new ExceptionConverter(e);
}
}
示例9: loadCmap
import com.lowagie.text.ExceptionConverter; //导入依赖的package包/类
/** Loads a CJK cmap to the cache with the option of associating
* sequences to the newline.
* @param name the CJK cmap name
* @param newline the sequences to be replaced by a newline in the resulting CID. See <CODE>CRLF_CID_NEWLINE</CODE>
*/
public static void loadCmap(String name, byte newline[][]) {
try {
char planes[][] = null;
synchronized (cmaps) {
planes = (char[][])cmaps.get(name);
}
if (planes == null) {
planes = readCmap(name, newline);
synchronized (cmaps) {
cmaps.put(name, planes);
}
}
}
catch (IOException e) {
throw new ExceptionConverter(e);
}
}
示例10: processType0
import com.lowagie.text.ExceptionConverter; //导入依赖的package包/类
private void processType0(PdfDictionary font) {
try {
PdfObject toUniObject = PdfReader.getPdfObjectRelease(font.get(PdfName.TOUNICODE));
PdfArray df = (PdfArray)PdfReader.getPdfObjectRelease(font.get(PdfName.DESCENDANTFONTS));
PdfDictionary cidft = (PdfDictionary)PdfReader.getPdfObjectRelease(df.getPdfObject(0));
PdfNumber dwo = (PdfNumber)PdfReader.getPdfObjectRelease(cidft.get(PdfName.DW));
int dw = 1000;
if (dwo != null)
dw = dwo.intValue();
IntHashtable widths = readWidths((PdfArray)PdfReader.getPdfObjectRelease(cidft.get(PdfName.W)));
PdfDictionary fontDesc = (PdfDictionary)PdfReader.getPdfObjectRelease(cidft.get(PdfName.FONTDESCRIPTOR));
fillFontDesc(fontDesc);
if (toUniObject != null){
fillMetrics(PdfReader.getStreamBytes((PRStream)toUniObject), widths, dw);
}
} catch (Exception e) {
throw new ExceptionConverter(e);
}
}
示例11: newPage
import com.lowagie.text.ExceptionConverter; //导入依赖的package包/类
/**
* Signals that an new page has to be started.
*
* @return <CODE>true</CODE> if this action succeeded, <CODE>false</CODE> if not.
*/
public boolean newPage() {
try {
writeStart(HtmlTags.DIV);
write(" ");
write(HtmlTags.STYLE);
write("=\"");
writeCssProperty(Markup.CSS_KEY_PAGE_BREAK_BEFORE, Markup.CSS_VALUE_ALWAYS);
write("\" /");
os.write(GT);
}
catch(IOException ioe) {
throw new ExceptionConverter(ioe);
}
return true;
}
示例12: close
import com.lowagie.text.ExceptionConverter; //导入依赖的package包/类
/**
* Closes the document.
* <B>
* Once all the content has been written in the body, you have to close
* the body. After that nothing can be written to the body anymore.
*/
public void close() {
if (close) {
return;
}
try {
boolean wasImage = (imageWait != null);
newPage();
if (imageWait != null || wasImage) newPage();
if (annotationsImp.hasUnusedAnnotations())
throw new RuntimeException("Not all annotations could be added to the document (the document doesn't have enough pages).");
PdfPageEvent pageEvent = writer.getPageEvent();
if (pageEvent != null)
pageEvent.onCloseDocument(writer, this);
super.close();
writer.addLocalDestinations(localDestinations);
calculateOutlineCount();
writeOutlines();
}
catch(Exception e) {
throw ExceptionConverter.convertException(e);
}
writer.close();
}
示例13: rotateAnnotations
import com.lowagie.text.ExceptionConverter; //导入依赖的package包/类
public PdfArray rotateAnnotations(PdfWriter writer, Rectangle pageSize) {
PdfArray array = new PdfArray();
int rotation = pageSize.getRotation() % 360;
int currentPage = writer.getCurrentPageNumber();
for (int k = 0; k < annotations.size(); ++k) {
PdfAnnotation dic = (PdfAnnotation)annotations.get(k);
int page = dic.getPlaceInPage();
if (page > currentPage) {
delayedAnnotations.add(dic);
continue;
}
if (dic.isForm()) {
if (!dic.isUsed()) {
HashMap templates = dic.getTemplates();
if (templates != null)
acroForm.addFieldTemplates(templates);
}
PdfFormField field = (PdfFormField)dic;
if (field.getParent() == null)
acroForm.addDocumentField(field.getIndirectReference());
}
if (dic.isAnnotation()) {
array.add(dic.getIndirectReference());
if (!dic.isUsed()) {
PdfRectangle rect = (PdfRectangle)dic.get(PdfName.RECT);
if (rect != null) {
switch (rotation) {
case 90:
dic.put(PdfName.RECT, new PdfRectangle(
pageSize.getTop() - rect.bottom(),
rect.left(),
pageSize.getTop() - rect.top(),
rect.right()));
break;
case 180:
dic.put(PdfName.RECT, new PdfRectangle(
pageSize.getRight() - rect.left(),
pageSize.getTop() - rect.bottom(),
pageSize.getRight() - rect.right(),
pageSize.getTop() - rect.top()));
break;
case 270:
dic.put(PdfName.RECT, new PdfRectangle(
rect.bottom(),
pageSize.getRight() - rect.left(),
rect.top(),
pageSize.getRight() - rect.right()));
break;
}
}
}
}
if (!dic.isUsed()) {
dic.setUsed();
try {
writer.addToBody(dic, dic.getIndirectReference());
}
catch (IOException e) {
throw new ExceptionConverter(e);
}
}
}
return array;
}
示例14: PdfPKCS7
import com.lowagie.text.ExceptionConverter; //导入依赖的package包/类
/**
* Verifies a signature using the sub-filter adbe.x509.rsa_sha1.
* @param contentsKey the /Contents key
* @param certsKey the /Cert key
* @param provider the provider or <code>null</code> for the default provider
*/
public PdfPKCS7(byte[] contentsKey, byte[] certsKey, String provider) {
try {
this.provider = provider;
X509CertParser cr = new X509CertParser();
cr.engineInit(new ByteArrayInputStream(certsKey));
certs = cr.engineReadAll();
signCerts = certs;
signCert = (X509Certificate)certs.iterator().next();
crls = new ArrayList();
ASN1InputStream in = new ASN1InputStream(new ByteArrayInputStream(contentsKey));
digest = ((DEROctetString)in.readObject()).getOctets();
if (provider == null)
sig = Signature.getInstance("SHA1withRSA");
else
sig = Signature.getInstance("SHA1withRSA", provider);
sig.initVerify(signCert.getPublicKey());
}
catch (Exception e) {
throw new ExceptionConverter(e);
}
}
示例15: loadCacertsKeyStore
import com.lowagie.text.ExceptionConverter; //导入依赖的package包/类
/**
* Loads the default root certificates at <java.home>/lib/security/cacerts.
* @param provider the provider or <code>null</code> for the default provider
* @return a <CODE>KeyStore</CODE>
*/
public static KeyStore loadCacertsKeyStore(String provider) {
File file = new File(System.getProperty("java.home"), "lib");
file = new File(file, "security");
file = new File(file, "cacerts");
FileInputStream fin = null;
try {
fin = new FileInputStream(file);
KeyStore k;
if (provider == null)
k = KeyStore.getInstance("JKS");
else
k = KeyStore.getInstance("JKS", provider);
k.load(fin, null);
return k;
}
catch (Exception e) {
throw new ExceptionConverter(e);
}
finally {
try{if (fin != null) {fin.close();}}catch(Exception ex){}
}
}