Skip to content

Commit

Permalink
temp fix for watermark issues
Browse files Browse the repository at this point in the history
  • Loading branch information
nkan-aot2 authored Nov 7, 2024
1 parent 431a4ee commit 5437e9c
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions web/src/components/FOI/Home/Redlining.js
Original file line number Diff line number Diff line change
Expand Up @@ -1396,16 +1396,17 @@ const Redlining = React.forwardRef(
if (docInstance && documentList.length > 0) {
const document = docInstance?.UI.iframeWindow.document;
document.getElementById("create_response_pdf").addEventListener("click", handleCreateResponsePDFClick);
docViewer.setWatermark({
docViewer?.setWatermark({
// Draw custom watermark in middle of the document
custom: (ctx, pageNumber, pageWidth, pageHeight) => {
// ctx is an instance of CanvasRenderingContext2D
// https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D
// Hence being able to leverage those properties
let originalPage = pageMappedDocs['stitchedPageLookup'][pageNumber]
let doc = pageFlags.find(d => d.documentid === originalPage.docid);
let pageFlag = doc.pageflag.find(f => f.page === originalPage.page);
if (pageFlag.flagid === pageFlagTypes["Duplicate"]) {
let pageFlagsOnPage = doc?.pageflag?.filter(f => f.page === originalPage.page);
let NrOrDupeFlag = pageFlagsOnPage?.find(pageFlagItem => pageFlagItem.flagid === pageFlagTypes["Duplicate"] || pageFlagItem.flagid === pageFlagTypes["Not Responsive"]);
if (NrOrDupeFlag?.flagid === pageFlagTypes["Duplicate"]) {
ctx.fillStyle = "#ff0000";
ctx.font = "20pt Arial";
ctx.globalAlpha = 0.4;
Expand All @@ -1417,7 +1418,7 @@ const Redlining = React.forwardRef(
ctx.restore();
}

if (pageFlag.flagid === pageFlagTypes["Not Responsive"]) {
if (NrOrDupeFlag?.flagid === pageFlagTypes["Not Responsive"]) {
ctx.fillStyle = "#ff0000";
ctx.font = "20pt Arial";
ctx.globalAlpha = 0.4;
Expand All @@ -1430,6 +1431,8 @@ const Redlining = React.forwardRef(
}
},
});
docViewer?.refreshAll();
docViewer?.updateView();
}
//Cleanup Function: removes previous event listeiner to ensure handleCreateResponsePDFClick event is not called multiple times on click
return () => {
Expand Down

0 comments on commit 5437e9c

Please sign in to comment.