[
https://issues.apache.org/jira/browse/PDFBOX-4640?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16920962#comment-16920962
]
Tilman Hausherr commented on PDFBOX-4640:
-----------------------------------------
{quote}The issue is when you flatten a document with other annotations (and
their opacity is not 100%), so if we have a document with a PDF Form and other
kind of annotations, and some of these opacity is less than 100%, PDFBox loses
them. I think it is a bug.{quote}
That's what you wrote before. Sadly you didn't attach your other PDF, nor did
you try with the command line utility. Your code is not self-working, some
variables are not declared.
So I tried to reproduce your alleged bug with this code:
{code}
import java.io.File;
import org.apache.pdfbox.io.MemoryUsageSetting;
import org.apache.pdfbox.multipdf.PDFMergerUtility;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.pdmodel.PDPage;
import org.apache.pdfbox.pdmodel.interactive.form.PDAcroForm;
public class PDFBox4640
{
public static void main(String[] args)
{
// create an empty document with 1 empty page (alternatively: load some
document)
PDDocument document = new PDDocument();
document.addPage(new PDPage());
File sourceFile = new File("highlighted pdf.pdf");
PDFMergerUtility ut = new PDFMergerUtility();
PDDocument sourceDocument = null;
try
{
sourceDocument = PDDocument.load(sourceFile,
MemoryUsageSetting.setupTempFileOnly());
sourceDocument.getDocumentCatalog().setDocumentOutline(null);
PDAcroForm acroForm =
sourceDocument.getDocumentCatalog().getAcroForm();
if (acroForm != null)
{
acroForm.flatten();
acroForm.getFields().clear();
}
ut.appendDocument(document, sourceDocument);
document.save("result.pdf");
}
catch (Exception ex)
{
}
}
}
{code}
I have attached the result file. Your annotations are now on page 2 and all
visible. Your document does not have any acroform.
> PDF Annotations missed when merging documents
> ---------------------------------------------
>
> Key: PDFBOX-4640
> URL: https://issues.apache.org/jira/browse/PDFBOX-4640
> Project: PDFBox
> Issue Type: Bug
> Components: Utilities
> Affects Versions: 2.0.16
> Reporter: Daniel Martin Garcia
> Priority: Major
> Labels: merge
> Attachments: highlighted pdf.pdf, result.pdf
>
>
> Hi,
> There is a bug when PDFBox merges documents with annotations, but the
> annotation opacity is not 100%. If the opacity is less than 100%, the
> annotation is lost.
>
> I attach a document with an annotation which opacity is 60%, if you create a
> test to merge this pdf with other PDF, the annotation won't be in the merged
> pdf.
--
This message was sent by Atlassian Jira
(v8.3.2#803003)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]