[
https://issues.apache.org/jira/browse/PDFBOX-4312?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16620963#comment-16620963
]
Tilman Hausherr commented on PDFBOX-4312:
-----------------------------------------
{quote}{color:#333333}yet my signature in not inserting in the blankbox please
guide me it's very important to me to solve this issue .{color}
{quote}
{color:#333333}indeed. It is still 00000.{color}
{color:#333333}1) Your file looks as if you called save(). I wonder if
saveIncremental(filename) works at all (your file is also cut off at the end),
our examples use the two parameter method. Make sure that the output file name
is not identical to the input file name.{color}
{code:java}
public File signPDF(File document) throws IOException, COSVisitorException,
SignatureException
{
byte[] buffer = new byte[8 * 1024];
if (document == null || !document.exists())
{
new RuntimeException("Document for signing does not exist");
}
// creating output document and prepare the IO streams.
String name = document.getName();
String substring = name.substring(0, name.lastIndexOf("."));
File outputDocument = new File(document.getParent(),
substring+"_signed.pdf");
FileInputStream fis = new FileInputStream(document);
FileOutputStream fos = new FileOutputStream(outputDocument);
int c;
while ((c = fis.read(buffer)) != -1)
{
fos.write(buffer, 0, c);
}
fis.close();
fis = new FileInputStream(outputDocument);
…
…
PDDocument doc = PDDocument.loadNonSeq(document, randomAccessFile);
// create signature dictionary
PDSignature signature = new PDSignature();
signature.setFilter(PDSignature.FILTER_ADOBE_PPKLITE); // default filter
// subfilter for basic and PAdES Part 2 signatures
signature.setSubFilter(PDSignature.SUBFILTER_ADBE_PKCS7_DETACHED);
signature.setName("signer name");
signature.setLocation("signer location");
signature.setReason("reason for signature");
// the signing date, needed for valid signature
signature.setSignDate(Calendar.getInstance());
// register signature dictionary and sign interface
if (options==null)
{
doc.addSignature(signature, this);
}
else
{
doc.addSignature(signature, this, options);
}
// write incremental (only for signing purpose)
doc.saveIncremental(fis, fos);
{code}
{color:#333333}2) Your image is a png image. Please pass a jpeg image. This is
not documented, sadly.{color}
> byte array format to pass to sign method
> ----------------------------------------
>
> Key: PDFBOX-4312
> URL: https://issues.apache.org/jira/browse/PDFBOX-4312
> Project: PDFBox
> Issue Type: Wish
> Components: .NET, PDModel, Signing
> Affects Versions: 1.8.9
> Reporter: bal
> Priority: Major
> Attachments: Screenshot (30).png, Screenshot (31).png, Screenshot
> (31).png, testingSignature.pdf, testingSignature.pdf
>
>
> Hi ,
> I want to sign pdf using signature in pkcs 7 format . I am converting pkcs 7
> signature to byte array using Convert.FromBase64String method in .net . I am
> passing this byte array to sign method in signature interface which gets
> called after calling saveincremental. My byte array is inserting proper but
> the name of which signature is not shown when i open pdf. May be my byte
> conversion may not proper or something else i am doing wrong. please let me
> know.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]