You are on page 1of 13

// Decompiled by DJ v3.12.12.

98 Copyright 2014 Atanas Neshkov Date: 17/08/2014


21:39:43
// Home Page: http://www.neshkov.com/dj.html - Check often for new version!
// Decompiler options: packimports(3)
// Source File Name: SignaturePDF.java
package com.tradise.crypto.signature.pdf;
import
import
import
import
import
import
import
import
import
import
import
import
import
import
import
import

com.lowagie.text.*;
com.lowagie.text.pdf.*;
com.tradise.crypto.CryptoService;
com.tradise.crypto.certificate.CertificateStoreService;
com.tradise.crypto.certificate.data.PrivateKeyCertificateChain;
com.tradise.crypto.certificate.util.CertificateUtil;
com.tradise.crypto.utils.signatureUtils;
java.io.*;
java.security.MessageDigest;
java.util.*;
javax.xml.transform.*;
javax.xml.transform.sax.SAXResult;
javax.xml.transform.stream.StreamSource;
org.apache.commons.io.CopyUtils;
org.apache.commons.io.IOUtils;
org.apache.fop.apps.*;

public class SignaturePDF


{
public SignaturePDF()
{
try
{
_$615();
}
catch(Exception ex)
{
ex.printStackTrace();
}
}
public static String ConsoleQuery(String Text)
{
try
{
BufferedReader in = new BufferedReader(new InputStreamReader(System.
in));
System.out.print(Text);
String input = in.readLine();
return input;
}
catch(Exception ex)
{
System.out.print((new StringBuilder()).append("Ooopsie! We've had a
n Exception: ").append(ex.getMessage()).toString());
}
return "";
}
public static void main(String args[])
{

SignaturePDF testpdf = new SignaturePDF();


try
{
PrivateKeyCertificateChain privKey = CryptoService.getCertificateSto
reService("12341234", "H:/PlugAndSign/fdiaz.pfx", "PKCS12").getPrivateKeyCertifi
cateChains()[0];
testpdf.SignedPDF("C:\\AUT_BANCO_ANDREA_DANA.pdf", "C:\\AUT_BANCO_AN
DREA_DANA_Signed.pdf", privKey, "12341234");
}
catch(Exception ex1)
{
ex1.printStackTrace();
}
System.exit(0);
String documento1 = "K:\\amaia.pdf";
String documentoAFirmar = "C:\\PDF\\cide.pdf";
String documentoFirma = "K:\\tarifa_diaria.p7s";
String documentoAReFirmar = "C:\\prueba.pdf";
String documentoFirmado = "C:\\prueba2.pdf";
String documentoFirmadoDuplicate1a = "K:\\ChapterSection.pdf";
String documentoFirmadoDuplicate1 = "K:\\ChapterSection.pdf";
String documentoFirmadoDuplicate1b = "K:\\tarifa_diaria2_OK2_selloanfnor
econocidoporsha256.pdf";
String documentoFirmadoDuplicate2 = "K:\\tarifa_diaria1_duplicate4.pdf";
String pdfTestAttach = "K:\\tarifa_diaria1.pdf";
String pdfTestAttachResult = "K:\\tarifa_diaria1_1.pdf";
String documentToAttach = "C:\\DNI1.jpg";
String pathTransform = "C:\\proyects\\Java\\TradiseCrypto\\xsl";
String pathTransform2 = "C://proyects//Java//TradiseCrypto//xsl//";
String xmltotransform = (new StringBuilder()).append(pathTransform).appe
nd("\\signature1.xml").toString();
String xsltotransform = (new StringBuilder()).append(pathTransform).appe
nd("\\signaturePDF_ca.xsl").toString();
String pdftransform = (new StringBuilder()).append(pathTransform).append
("\\pdfsignature.pdf").toString();
int opcion = -1;
do
{
if(opcion == 0)
break;
System.out.println(" 0 - Salir");
System.out.println(" 1 - Firmar PDF");
System.out.println(" 2 - Firma PDF en el mismo documento");
System.out.println(" 3 - Firma PDF(TimeStamp)");
System.out.println(" 4 - Attach Filename");
System.out.println(" 5 - Copy Pages PDF");
System.out.println(" 6 - Add Pages PDF");
System.out.println(" 7 - Crear PDF");
System.out.println(" 8 - Add Pages PDFCopy (no lo copia todo)");
System.out.println(" 9 - Create Repport Signature");
System.out.println("10 - Transform FOP");
System.out.println("11 - Add Pages PDF Transform FOP");
System.out.println("12 - Transform FOP Ejemplos1");
String resp = ConsoleQuery("Seleccione una opcion:");
try
{
opcion = Integer.parseInt(resp);
}
catch(Exception ex)
{

opcion = -1;
}
String password = "";
PrivateKeyCertificateChain privkey = null;
if(opcion != 0 && opcion != -1 && opcion < 4)
{
CertificateStoreService certStSrv[] = CryptoService.detectCertif
icateStoreServices();
for(int cont = 0; cont < certStSrv.length; cont++)
System.out.println((new StringBuilder()).append(" ").append(
cont).append(" Store").toString());
resp = ConsoleQuery("Seleccione un Store:");
System.out.println((new StringBuilder()).append("resp sel store
:").append(resp).append("<-").toString());
resp = "0";
PrivateKeyCertificateChain privKeys[] = CryptoService.detectCert
ificateStoreServices()[Integer.parseInt(resp)].getPrivateKeyCertificateChains();
System.out.println(" 0 - Sin Certificado");
for(int cont = 0; cont < privKeys.length; cont++)
System.out.println((new StringBuilder()).append(" ").append(
cont + 1).append("-").append(privKeys[cont].getSubjectCommonName()).toString());
resp = ConsoleQuery("Seleccione un certificado:");
System.out.println((new StringBuilder()).append("resp sel certif
icado :").append(resp).append("<-").toString());
if(!"0".equals(resp))
{
privkey = privKeys[Integer.parseInt(resp) - 1];
resp = ConsoleQuery("Seleccione un password:");
password = resp;
}
}
try
{
switch(opcion)
{
case 6: // '\006'
case 7: // '\007'
case 8: // '\b'
case 9: // '\t'
default:
if(false)
;
break;
case 1: // '\001'
testpdf.SignedPDF(documentoAFirmar, documentoFirmado, privke
y, password);
break;
case 2: // '\002'
testpdf.SignedPDF(documentoFirmado, documentoFirmado, privke
y, password);
break;
case 3: // '\003'
SignaturePDF _tmp = testpdf;
SignedTimeStampPDF(documentoAReFirmar, documentoFirmado, pri
vkey, password, "PDFSIGNATURE", "TRADISE");

break;
case 4: // '\004'
testpdf.AttachFilenameToPDF(documentToAttach, pdfTestAttach,
pdfTestAttachResult);
break;
case 5: // '\005'
testpdf.AddPageContent(documentoFirmadoDuplicate1, documento
FirmadoDuplicate2);
break;
case 10: // '\n'
testpdf.generarPDF(xmltotransform, xsltotransform, pdftransf
orm, (new StringBuilder()).append("file:///").append(pathTransform2).toString(),
"nPages", 5);
break;
case 11: // '\013'
ByteArrayOutputStream bOut = new ByteArrayOutputStream();
PdfReader pdf = new PdfReader(documentoFirmadoDuplicate1b);
int numpage = pdf.getNumberOfPages();
pdf.close();
bOut = testpdf.generarPDF(xmltotransform, xsltotransform, (n
ew StringBuilder()).append("file:///").append(pathTransform2).toString(), "nPage
s", numpage);
testpdf.ModifyContent(documentoFirmadoDuplicate1b, documento
FirmadoDuplicate2, bOut.toByteArray());
break;
case 12: // '\f'
xmltotransform = (new StringBuilder()).append(pathTransform)
.append("\\signature.xml").toString();
xsltotransform = (new StringBuilder()).append(pathTransform)
.append("\\signaturePDF.xsl").toString();
pdftransform = (new StringBuilder()).append(pathTransform).a
ppend("\\pdfsignature.pdf").toString();
System.out.println("Modelo 1 Castellano");
testpdf.generarPDF(xmltotransform, xsltotransform, pdftransf
orm, (new StringBuilder()).append("file:///").append(pathTransform2).toString(),
"nPages", 5);
xmltotransform = (new StringBuilder()).append(pathTransform)
.append("\\signature1.xml").toString();
xsltotransform = (new StringBuilder()).append(pathTransform)
.append("\\signaturePDF.xsl").toString();
pdftransform = (new StringBuilder()).append(pathTransform).a
ppend("\\pdfsignature1.pdf").toString();
System.out.println("Modelo 2 Castellano");
testpdf.generarPDF(xmltotransform, xsltotransform, pdftransf
orm, (new StringBuilder()).append("file:///").append(pathTransform2).toString(),
"nPages", 5);
xmltotransform = (new StringBuilder()).append(pathTransform)
.append("\\signature.xml").toString();
xsltotransform = (new StringBuilder()).append(pathTransform)
.append("\\signaturePDF_ca.xsl").toString();
pdftransform = (new StringBuilder()).append(pathTransform).a
ppend("\\pdfsignature_ca.pdf").toString();
System.out.println("Modelo 1 Catal\341n");
testpdf.generarPDF(xmltotransform, xsltotransform, pdftransf
orm, (new StringBuilder()).append("file:///").append(pathTransform2).toString(),

"nPages", 5);
xmltotransform = (new StringBuilder()).append(pathTransform)
.append("\\signature1.xml").toString();
xsltotransform = (new StringBuilder()).append(pathTransform)
.append("\\signaturePDF_ca.xsl").toString();
pdftransform = (new StringBuilder()).append(pathTransform).a
ppend("\\pdfsignature1_ca.pdf").toString();
System.out.println("Modelo 2 Catal\341n");
testpdf.generarPDF(xmltotransform, xsltotransform, pdftransf
orm, (new StringBuilder()).append("file:///").append(pathTransform2).toString(),
"nPages", 5);
break;
}
}
catch(Exception ex)
{
ex.printStackTrace();
}
} while(true);
}
public void SignedPDF(String filenametoSig, String filenameSigned, String ps
w)
{
try
{
CertificateStoreService cStores[] = CryptoService.detectCertificateS
toreServices();
if(cStores.length > 0)
{
PrivateKeyCertificateChain privateKeys[] = cStores[0].getPrivate
KeyCertificateChains();
int idCert = 4;
PrivateKeyCertificateChain privKeyChain = privateKeys[idCert];
PdfReader reader = new PdfReader(filenametoSig);
FileOutputStream fout = new FileOutputStream(filenameSigned);
char versionreader = reader.getPdfVersion();
AcroFields af = reader.getAcroFields();
com.lowagie.text.pdf.PRAcroForm acroForm = reader.getAcroForm();
ArrayList namessigneds = af.getSignatureNames();
PdfStamper stp = PdfStamper.createSignature(reader, fout, versio
nreader, null, namessigneds.size() > 0);
System.out.println((new StringBuilder()).append(" javascript :")
.append(reader.getJavaScript()).toString());
System.out.println((new StringBuilder()).append("permision reade
r :").append(reader.getPermissions()).toString());
System.out.println((new StringBuilder()).append("version reader
:").append(reader.getPdfVersion()).toString());
java.security.PrivateKey key = privKeyChain.getPrivateKey(psw.to
CharArray());
java.security.cert.X509Certificate chain[] = privKeyChain.getMai
nCertificateChain();
if(acroForm != null)
{
ArrayList names = af.getBlankSignatureNames();
System.out.println((new StringBuilder()).append("names.size(
):").append(names.size()).toString());
if(names.size() == 0)
names = af.getSignatureNames();
for(int k = 0; k < names.size(); k++)

{
String name = (String)names.get(k);
System.out.println((new StringBuilder()).append("Signatu
re name: ").append(name).toString());
PdfSignatureAppearance sap = stp.getSignatureAppearance(
);
sap.setCrypto(key, chain, null, PdfSignatureAppearance.W
INCER_SIGNED);
sap.setVisibleSignature(name);
}
stp.close();
} else
{
PdfSignatureAppearance sap = stp.getSignatureAppearance();
sap.setCrypto(key, chain, null, PdfSignatureAppearance.WINCE
R_SIGNED);
stp.close();
}
}
}
catch(Exception ex)
{
ex.printStackTrace();
}
}
public static String asHex(byte buf[])
{
StringBuffer strbuf = new StringBuffer(buf.length * 2);
for(int i = 0; i < buf.length; i++)
{
if((buf[i] & 0xff) < 16)
strbuf.append("0");
strbuf.append(Long.toString(buf[i] & 0xff, 16));
}
return strbuf.toString();
}
public static void SignedTimeStampPDF(String pdfToSign, String pdfSigned, Pr
ivateKeyCertificateChain privkey, String psw, String SoftCode, String VendorName
)
throws Exception
{
SignedTimeStampPDF(pdfToSign, pdfSigned, privkey, psw, SoftCode, VendorN
ame, null);
}
public static void SignedTimeStampPDF(String pdfToSign, String pdfSigned, Pr
ivateKeyCertificateChain privkey, String psw, String SoftCode, String VendorName
, String TimeStamp)
throws Exception
{
PdfReader reader = new PdfReader(pdfToSign);
FileOutputStream fout = new FileOutputStream(pdfSigned);
int SIZE = 64000;
System.out.println((new StringBuilder()).append("SignedTimeStampPDF...")
.append(pdfToSign).append("...").append(pdfSigned).toString());
AcroFields af = reader.getAcroFields();

ArrayList names = af.getSignatureNames();


PdfStamper stp = PdfStamper.createSignature(reader, fout, '\0', null, na
mes.size() > 0);
PdfSignatureAppearance sap = stp.getSignatureAppearance();
PdfDictionary dic = new PdfDictionary();
dic.put(PdfName.TYPE, PdfName.SIG);
dic.put(PdfName.FILTER, new PdfName("Adobe.PPKMS"));
dic.put(PdfName.SUBFILTER, new PdfName("adbe.pkcs7.detached"));
dic.put(PdfName.REASON, new PdfString(PdfPKCS7.getSubjectFields(privkey.
getMainCertificateChain()[0]).getField("CN")));
dic.put(PdfName.NAME, new PdfString(PdfPKCS7.getSubjectFields(privkey.ge
tMainCertificateChain()[0]).getField("CN")));
sap.setCryptoDictionary(dic);
HashMap exc = new HashMap();
exc.put(PdfName.CONTENTS, new Integer(64000));
sap.preClose(exc);
byte data[] = IOUtils.toByteArray(sap.getRangeStream());
ByteArrayInputStream bIn = new ByteArrayInputStream(data);
signatureUtils sigUtils = new signatureUtils();
ByteArrayOutputStream bOut = new ByteArrayOutputStream();
sigUtils.setSoftCode(SoftCode);
sigUtils.setVendorName(VendorName);
if(TimeStamp != null)
sigUtils.setTimeStampService(TimeStamp);
sigUtils.setPaswordCertificate(psw);
sigUtils.signedDocument(bIn, pdfToSign, privkey, 3, bOut, "CMS");
byte ssig[];
ssig = ssig = bOut.toByteArray();
byte outc[] = new byte[31999];
System.arraycopy(ssig, 0, outc, 0, ssig.length);
PdfDictionary dic2 = new PdfDictionary();
dic2.put(PdfName.CONTENTS, (new PdfString(outc)).setHexWriting(true));
sap.close(dic2);
}
public void verify()
{
try
{
PdfReader reader = new PdfReader("c:\\prueba2.pdf");
PdfStamper stp = new PdfStamper(reader, new FileOutputStream("C:\\te
st.pdf"));
PdfSignatureAppearance sap = stp.getSignatureAppearance();
System.out.println((new StringBuilder()).append("Nombre:").append(sa
p).toString());
AcroFields af = reader.getAcroFields();
ArrayList names = af.getSignatureNames();
for(int k = 0; k < names.size(); k++)
{
String name = (String)names.get(k);
System.out.println((new StringBuilder()).append("Signature name:
").append(name).toString());
System.out.println((new StringBuilder()).append("Signature cover
s whole document: ").append(af.signatureCoversWholeDocument(name)).toString());
System.out.println((new StringBuilder()).append("Document revisi
on: ").append(af.getRevision(name)).append(" of ").append(af.getTotalRevisions()
).toString());
System.out.println((new StringBuilder()).append("Dictionary: ").
append(af.getSignatureDictionary(name).get(PdfName.NAME).toString()).toString())
;

FileOutputStream out = new FileOutputStream((new StringBuilder()


).append("C:\\revision_").append(af.getRevision(name)).append(".pdf").toString()
);
byte bb[] = new byte[8192];
InputStream ip = af.extractRevision(name);
for(int n = 0; (n = ip.read(bb)) > 0;)
out.write(bb, 0, n);
out.close();
ip.close();
PdfPKCS7 pk = af.verifySignature(name);
java.util.Calendar cal = pk.getSignDate();
java.security.cert.Certificate pkc[] = pk.getCertificates();
System.out.println((new StringBuilder()).append("Subject: ").app
end(PdfPKCS7.getSubjectFields(pk.getSigningCertificate())).toString());
System.out.println((new StringBuilder()).append("Document modifi
ed: ").append(!pk.verify()).toString());
}
}
catch(Exception ex)
{
ex.printStackTrace();
}
}
public void copyPages(PdfReader pdfReader, PdfCopy writer)
throws IOException, BadPdfFormatException
{
int n = pdfReader.getNumberOfPages();
for(int i = 0; i < n;)
{
i++;
com.lowagie.text.pdf.PdfImportedPage page = writer.getImportedPage(p
dfReader, i);
writer.addPage(page);
}
com.lowagie.text.pdf.PRAcroForm form = pdfReader.getAcroForm();
if(form != null)
writer.copyAcroForm(pdfReader);
}
public int ModifyContent(String pdfFile, String pdfResult, byte bDoc[])
{
try
{
PdfReader readerDoc = new PdfReader(bDoc);
readerDoc.consolidateNamedDestinations();
PdfReader reader = new PdfReader(pdfFile);
reader.consolidateNamedDestinations();
PdfStamper stamp = new PdfStamper(reader, new FileOutputStream(pdfRe
sult), reader.getPdfVersion());
PdfContentByte over = null;
over = stamp.getOverContent(1);
int numpages = reader.getNumberOfPages();
int numpagesDoc = readerDoc.getNumberOfPages();
PdfDictionary dic = readerDoc.getCatalog();
int i = 0;
do

{
if(i >= numpagesDoc)
break;
stamp.insertPage(numpages + 1, PageSize.A4);
over = stamp.getOverContent(numpages + 1);
i++;
com.lowagie.text.pdf.PdfImportedPage pdfImport = stamp.getImport
edPage(readerDoc, i);
PdfContentByte pdfContent = null;
if(pdfImport != null)
{
over.addTemplate(pdfImport, 0.0F, 0.0F);
numpages++;
}
} while(true);
stamp.close();
}
catch(Exception ex)
{
ex.printStackTrace();
}
return 1;
}
public void AddPageContent(String pdfFile, String pdfResult)
{
PdfReader reader = null;
try
{
System.out.println((new StringBuilder()).append("pdfFile:").append(p
dfFile).toString());
reader = new PdfReader(pdfFile);
int n = reader.getNumberOfPages();
Rectangle psize = reader.getPageSize(1);
float width = psize.getWidth();
float height = psize.getHeight();
Document document = new Document(new Rectangle(width, height));
System.out.println((new StringBuilder()).append("pdfResult:").append
(pdfResult).toString());
PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStr
eam(pdfResult));
document.open();
PdfContentByte cb = writer.getDirectContent();
int i = 0;
int p = 0;
while(i < n)
{
document.newPage();
p++;
i++;
com.lowagie.text.pdf.PdfImportedPage page1 = writer.getImportedP
age(reader, i);
cb.addTemplate(page1, 0.0F, 0.0F);
}
}
catch(Exception ex)
{
ex.printStackTrace();
}
}

public void AttachFilenameToPDF(String attachFile, String PDFFile, String PD


FResultant)
throws Exception
{
System.out.println((new StringBuilder()).append("PDFFile::").append(PDFF
ile).toString());
PdfReader reader = new PdfReader(PDFFile);
File fAttach = new File(attachFile);
FileInputStream fStreamAttach = new FileInputStream(fAttach);
ByteArrayOutputStream bOut = new ByteArrayOutputStream();
IOUtils.copy(fStreamAttach, bOut);
FileOutputStream fos = new FileOutputStream(PDFResultant);
PdfStamper stamper = new PdfStamper(reader, fos);
stamper.addFileAttachment("", bOut.toByteArray(), attachFile, attachFile
);
stamper.close();
}
public void SignedPDF(String filenametoSig, String filenameSigned, PrivateKe
yCertificateChain privKeyChain, String psw)
throws Exception
{
PdfReader reader = new PdfReader(filenametoSig);
FileOutputStream fout = new FileOutputStream(filenameSigned);
AcroFields af = reader.getAcroFields();
com.lowagie.text.pdf.PRAcroForm acroForm = reader.getAcroForm();
ArrayList names = af.getSignatureNames();
PdfStamper stp = PdfStamper.createSignature(reader, fout, '\0', null, na
mes.size() > 0);
java.security.PrivateKey key = privKeyChain.getPrivateKey(psw.toCharArra
y());
java.security.cert.X509Certificate chain[] = privKeyChain.getMainCertifi
cateChain();
if(acroForm != null)
{
ArrayList namesBlank = af.getBlankSignatureNames();
System.out.println((new StringBuilder()).append("namesBlank.size():"
).append(namesBlank.size()).toString());
if(namesBlank.size() == 0)
namesBlank = af.getSignatureNames();
for(int k = 0; k < namesBlank.size(); k++)
{
String name = (String)namesBlank.get(k);
System.out.println((new StringBuilder()).append("Signature name:
").append(name).toString());
PdfSignatureAppearance sap = stp.getSignatureAppearance();
sap.setCrypto(key, chain, null, PdfSignatureAppearance.WINCER_SI
GNED);
sap.setReason(CertificateUtil.getSubjectOIDValue(chain[0], "2.5.
4.3"));
sap.setVisibleSignature(name);
}
stp.close();
} else
{
PdfSignatureAppearance sap = stp.getSignatureAppearance();
sap.setCrypto(key, chain, null, PdfSignatureAppearance.WINCER_SIGNED
);

sap.setReason(CertificateUtil.getSubjectOIDValue(chain[0], "2.5.4.3"
));
stp.close();
}
fout.flush();
fout.close();
}
public byte[] getDigest(InputStream inp, String instance)
{
try
{
MessageDigest messageDigest = null;
messageDigest = MessageDigest.getInstance(instance);
byte buf[] = new byte[8192];
int n;
while((n = inp.read(buf)) > 0)
messageDigest.update(buf, 0, n);
return messageDigest.digest();
}
catch(Exception ex)
{
ex.printStackTrace();
}
return null;
}
public void parsePDF(String filename)
{
try
{
System.out.println((new StringBuilder()).append("Documento : ").appe
nd(filename).toString());
PdfReader reader = new PdfReader(filename);
int pagenum = reader.getNumberOfPages();
label0:
for(int cont = 1; cont <= pagenum; cont++)
{
PdfDictionary dic1 = reader.getPageN(cont);
System.out.println((new StringBuilder()).append("reader.getPageN
(").append(cont).append(").toString() :").append(dic1.toString()).toString());
Set keys = dic1.getKeys();
Iterator it = keys.iterator();
do
{
if(!it.hasNext())
continue label0;
Object obj = it.next();
System.out.println((new StringBuilder()).append("nombre de l
a clas del iterator ").append(obj.getClass().getName()).toString());
PdfName value = (PdfName)it.next();
System.out.println((new StringBuilder()).append("value <<<<<
<<<<<>>>>>>>>>>").append(value.toString()).toString());
PdfObject pdfobj = dic1.get(value);
System.out.println((new StringBuilder()).append("class name
<<<<<<<<<<>>>>>>>>>>").append(pdfobj.getClass().getName()).toString());
if("/Contents".equals(value.toString()))
{
System.out.println("entra en CONTENTS");
PRIndirectReference prind = (PRIndirectReference)pdfobj;

System.out.println((new StringBuilder()).append("prind.t
oString() ").append(prind.toString()).toString());
}
if(!"/Resources".equals(value.toString()));
if("/MediaBox".equals(value.toString()))
{
System.out.println("entra en MEDIABOX");
PdfArray pdfarray = (PdfArray)pdfobj;
ArrayList array = pdfarray.getArrayList();
int tam = array.size();
System.out.println((new StringBuilder()).append("tam MED
IABOX ").append(tam).toString());
for(int contq = 0; contq < tam; contq++)
{
Object obj2 = array.get(contq);
PdfNumber num1 = (PdfNumber)array.get(contq);
System.out.println((new StringBuilder()).append("Obj
ect----- ").append(obj2.getClass().getName()).toString());
System.out.println((new StringBuilder()).append("Val
or: ").append(num1.doubleValue()).toString());
}
}
if(value == PdfName.TEXT)
{
pdfobj = dic1.get(value);
System.out.println((new StringBuilder()).append(value.to
String()).append("-->>").append(pdfobj.toString()).toString());
}
if(value.isString())
{
pdfobj = dic1.get(value);
System.out.println((new StringBuilder()).append(value.to
String()).append("-->").append(pdfobj.toString()).toString());
}
} while(true);
}
System.out.println((new StringBuilder()).append("reader.getCatalog()
.toString():").append(reader.getCatalog().toString()).toString());
for(int cont = 1; cont <= pagenum; cont++)
{
byte bPage[] = reader.getPageContent(cont);
System.out.println((new StringBuilder()).append("Contenido page
").append(cont).toString());
}
int acrofieldssize = reader.getAcroFields().getFields().size();
System.out.println((new StringBuilder()).append("--> ").append(acrof
ieldssize).toString());
}
catch(IOException ioe)
{
System.err.println(ioe.getMessage());
}
}
private void _$615()
throws Exception
{

}
protected void generarPDF(String xml, String xslt, String pdf, String basePa
th, String nameParameter, int valueparameter)
throws IOException, FOPException, TransformerException
{
ByteArrayOutputStream bOut = generarPDF(xml, xslt, basePath, nameParamet
er, valueparameter);
FileOutputStream fOut = new FileOutputStream(pdf);
CopyUtils.copy(bOut.toByteArray(), fOut);
fOut.flush();
fOut.close();
}
protected ByteArrayOutputStream generarPDF(String xml, String xslt, String b
asePath, String nameParameter, int valueparameter)
throws IOException, FOPException, TransformerException
{
FopFactory fopFactory;
FOUserAgent foUserAgent;
ByteArrayOutputStream out;
fopFactory = FopFactory.newInstance();
foUserAgent = fopFactory.newFOUserAgent();
foUserAgent.setBaseURL(basePath);
out = new ByteArrayOutputStream();
Fop fop = fopFactory.newFop("application/pdf", foUserAgent, out);
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer(new StreamSource(xslt))
;
transformer.setParameter(nameParameter, new Integer(valueparameter));
transformer.setParameter("versionParam", "2.0");
javax.xml.transform.Source src = new StreamSource(xml);
javax.xml.transform.Result res = new SAXResult(fop.getDefaultHandler());
transformer.transform(src, res);
break MISSING_BLOCK_LABEL_129;
Exception exception;
exception;
throw exception;
return out;
}
public static int SIZETEXT_DEFAULT = 10;
}