[
https://issues.apache.org/jira/browse/PDFBOX-4797?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17057476#comment-17057476
]
Andrei Toropov commented on PDFBOX-4797:
----------------------------------------
Thank you [~mkl] and [~tilman]
There is the code that works fine:
{code:java}
//{code}
{code:java}
public JSONObject overLay(String firstOverlayFile, String secondOverlayFile,
String outputFileName) throws IOException { JSONObject json = new
JSONObject();
Overlay overlayer = new Overlay();
shell.log(5, "=== overLay.firstPageOverlayFile === ",firstOverlayFile);
shell.log(5, "=== overLay.lastPageOverlayFile === ",secondOverlayFile);
overlayer.setOverlayPosition(Overlay.Position.FOREGROUND);
PDDocument firstFile = PDDocument.load(aws.getAwsFile(firstOverlayFile));
PDDocument secondFile = PDDocument.load(aws.getAwsFile(secondOverlayFile));
String pdfFirstData = pdfContent(firstFile);
String pdfLastData = pdfContent(secondFile);
overlayer.setInputPDF(firstFile);
overlayer.setAllPagesOverlayPDF(secondFile);
try ( PDDocument result = overlayer.overlay(Collections.emptyMap()) ) {
shell.log(5, "=== result.getNumberOfPages === ", result.getNumberOfPages()
+ " ");
for (int p = 0; p < result.getNumberOfPages(); p++) {
try (
PDPageContentStream canvas = new PDPageContentStream(result, result.getPage(p),
AppendMode.PREPEND, false, false)) {
PDExtendedGraphicsState extGState = new PDExtendedGraphicsState();
extGState.setBlendMode(BlendMode.MULTIPLY);
canvas.setGraphicsStateParameters(extGState); }
catch( Exception ex) {
ex.printStackTrace(); } }
result.save(new File(outputFileName)); }
firstFile.close();
secondFile.close();
overlayer.close();
shell.log(5, "=== overLay === ",outputFileName);
json.put("fileName",outputFileName);
json.put("pdfFirstData", pdfFirstData);
json.put("pdfLastData", pdfLastData);
return json; }
{code}
> Overlayed PDF file do not shows the difference
> -----------------------------------------------
>
> Key: PDFBOX-4797
> URL: https://issues.apache.org/jira/browse/PDFBOX-4797
> Project: PDFBox
> Issue Type: Bug
> Affects Versions: 2.0.19
> Environment: Java Maven
> Reporter: Andrei Toropov
> Priority: Major
> Attachments: 10.pdf, 114.pdf, 1583843507134004.overlay.PDF,
> 2020-03-10_10-34-56.png, screenshot-1.png, screenshot-2.png
>
>
> There are two differences in this two files, in the table on last page and in
> the table on the previous page the second row, column "% since inception" has
> values 11.74 in one pdf and 11.75 in another one. The textual html diff picks
> up and shows both cases. However, visual overlay shows this on page 5, but
> doesn't show on page 6.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]