5
Come sostituire l'immagine in PDF con un'altra casella di Image pdf. Come farlo?Sostituisci immagine in PDF con un'altra immagine box in pdf
Voglio modificare VisualSignature sul pdf con un'altra immagine.
ottengo visivo Apereance così:
PDDocument doc= PDDocument.load(new FileInputStream("c:\\temp\\template.pdf"));
File dir= new File("c:\\temp\\");
Iterator<Entry<COSObjectKey, Long>> xrefEntriesIt =
doc.getDocument().getXrefTable().entrySet().iterator();
while(xrefEntriesIt.hasNext()) {
COSObject object = doc.getDocument().getObjectFromPool(
xrefEntriesIt.next().getKey());
if (object.getDictionaryObject(COSName.SUBTYPE) == COSName.IMAGE) {
changeImage(object, doc);
}
}
e metodo per per cambiare immagine
private static void changeImage(COSObject obj, PDDocument doc) {
PDXObjectImage imageInPdf =
(PDXObjectImage) PDXObject.createXObject(
(COSStream) obj.getObject());
File inputFile = new File("C:\\temp\\SIGNATURE.jpg");
PDXObjectImage newImage = new PDJpeg(
doc, new FileInputStream(inputFile));
imageInPdf.getCOSStream().replaceWithStream(newImage.getCOSStream());
}
ho provato. imageInPdf è un'immagine rally dall'aspetto visivo di un campo firma firmato.
ora come rimuovere e aggiungere nuovo aspetto visivo di un campo firma firmato?
Intendi l'aspetto visivo di un campo firma firmato? O uno ancora non firmato, vuoto? – mkl
Ho appena aggiornato il mio post. sì, l'aspetto di un campo firma firmato. Ho preso quell'immagine. da COSObject. ma non posso cambiarlo. –