Skip to content

Commit

Permalink
Merge pull request #1232 from bcgov/main-NK-watermark-hotfix
Browse files Browse the repository at this point in the history
minor fix to save page flag callback inorder to fix watermark issue
  • Loading branch information
nkan-aot2 authored Dec 10, 2024
2 parents edae91a + 0360e6c commit bb15d55
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 38 deletions.
4 changes: 2 additions & 2 deletions web/src/components/FOI/Home/ContextMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,14 @@ const ContextMenu = ({
savePageFlag(
requestId,
flagId,
(data: any, flagid: number) => {
(data: any) => {
if(data.status == true){
const updatedPageFlags = updatePageFlagOnPage(
data.updatedpageflag,
pageFlags
);
if(updatedPageFlags?.length > 0)
syncPageFlagsOnAction(updatedPageFlags, [pageFlagTypes["Duplicate"], pageFlagTypes["Not Responsive"]].includes(flagid));
syncPageFlagsOnAction(updatedPageFlags, [pageFlagTypes["Duplicate"], pageFlagTypes["Not Responsive"]].includes(flagId));
}
},
(error: any) => console.log(error),
Expand Down
74 changes: 38 additions & 36 deletions web/src/components/FOI/Home/Redlining.js
Original file line number Diff line number Diff line change
Expand Up @@ -1444,42 +1444,44 @@ const Redlining = React.forwardRef(


const setWatermarks = () => {
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"]) {
ctx.fillStyle = "#ff0000";
ctx.font = "20pt Arial";
ctx.globalAlpha = 0.4;

ctx.save();
ctx.translate(pageWidth / 2, pageHeight / 2);
ctx.rotate(-Math.PI / 4);
ctx.fillText("DUPLICATE", 0, 0);
ctx.restore();
}

if (pageFlag?.flagid === pageFlagTypes["Not Responsive"]) {
ctx.fillStyle = "#ff0000";
ctx.font = "20pt Arial";
ctx.globalAlpha = 0.4;

ctx.save();
ctx.translate(pageWidth / 2, pageHeight / 2);
ctx.rotate(-Math.PI / 4);
ctx.fillText("NOT RESPONSIVE", 0, 0);
ctx.restore();
}
},
});
docViewer?.refreshAll();
docViewer?.updateView();
if (docViewer && pageMappedDocs && pageFlags) {
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"]) {
ctx.fillStyle = "#ff0000";
ctx.font = "20pt Arial";
ctx.globalAlpha = 0.4;

ctx.save();
ctx.translate(pageWidth / 2, pageHeight / 2);
ctx.rotate(-Math.PI / 4);
ctx.fillText("DUPLICATE", 0, 0);
ctx.restore();
}

if (pageFlag?.flagid === pageFlagTypes["Not Responsive"]) {
ctx.fillStyle = "#ff0000";
ctx.font = "20pt Arial";
ctx.globalAlpha = 0.4;

ctx.save();
ctx.translate(pageWidth / 2, pageHeight / 2);
ctx.rotate(-Math.PI / 4);
ctx.fillText("NOT RESPONSIVE", 0, 0);
ctx.restore();
}
},
});
docViewer.refreshAll();
docViewer.updateView();
}
}

const stitchPages = (_doc, pdftronDocObjs) => {
Expand Down

0 comments on commit bb15d55

Please sign in to comment.