pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gilad Denneboom <gilad.denneb...@gmail.com>
Subject Linking to Embedded Files causes them to appear twice
Date Tue, 06 Aug 2013 10:17:47 GMT
Hi all,

I hope someone can help me solve this strange issue.
I've created a tool that converts form field buttons to File Attachment
annotations, pointing to a file already embedded in the PDF. This works
fine. The problem is that in this process the embedded files linked to
become "duplicated" and appear twice in the Attachments panel.

The relevant code is this:

    PDPage p = field.getWidget().getPage();
    Object o = embeddedFiles.getNames().get(fileName);
    if (o!=null && o instanceof PDFileSpecification) {
        List<PDAnnotation> annots = p.getAnnotations();
        PDAnnotationFileAttachment newAnnot = new
PDAnnotationFileAttachment();
        newAnnot.setRectangle(field.getWidget().getRectangle());

newAnnot.setAttachementName(PDAnnotationFileAttachment.ATTACHMENT_NAME_PAPERCLIP);
        newAnnot.setTitlePopup(field.getAlternateFieldName());
        newAnnot.setSubject(fileName.split("\\.")[1]);
        newAnnot.setContents(fileName.split("\\.")[1]);
        newAnnot.setFile((PDFileSpecification) o);
        newAnnot.setLocked(true);
        newAnnot.setCreationDate(Calendar.getInstance());
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
        String modDate = "D:"+ sdf.format(new Date()) + "+00'00";
        newAnnot.setModifiedDate(modDate);
        annots.add(newAnnot);
    }

If anyone has any ideas on what might be causing this behaviour, I'll be
glad to hear them...

Thanks in advance!

Gilad

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message