WebViewer Version: 11.2.0
Do you have an issue with a specific file(s)? No
Can you reproduce using one of our samples or online demos? NA
Are you using the WebViewer server? No
Does the issue only happen on certain browsers? No
Is your issue related to a front-end framework? No
Is your issue related to annotations? No
Please give a brief summary of your issue:
Hello, I am referencing the code behind the Advanced Diff demo tool here:
Demo tool: https://sdk.apryse.com/samples/web/samples/advanced/diff/
Code: https://sdk.apryse.com/samples/web/samples/advanced/diff/diff.js
In the function ‘onNudgeToolPressed’, we see the use of ‘compareDocs.translate(string, number, number)’ that allows a user to nudge the diff-document in the middle/overlay viewer in the direction we specify. I would like to implement a similar tool in my app, but am not finding the above methods or an up-to-date code sample.
I am loading my document as a Core.PDFNet.PDFDoc, but I could also use a Core.Document if needed. However, I haven’t been successful in translating, rotating, or scaling my document so far. Could you point me in the right direction? I am using Angular 22 with TypeScript
How I am creating the original diff document, before any nudging happens:
async createOverlayDocument(
overlayInstance: WebViewerInstance,
primaryDocument: OverlayDocument,
secondaryDocument: OverlayDocument
): Promise<Core.PDFNet.PDFDoc> {
const { PDFNet } = instance.Core
const newDoc1 = await overlayInstance.Core.createDocument(primaryDocument.downloadUrl)
const doc1 = await newDoc1.getPDFDoc()
const newDoc2 = await overlayInstance.Core.createDocument(secondaryDocument.downloadUrl)
const doc2 = await newDoc2.getPDFDoc()
const arr1 = []
const itr1 = await doc1.getPageIterator(1)
for (; await itr1.hasNext(); itr1.next()) {
const page = await itr1.current()
arr1.push(page)
}
const doc1Pages = arr1
const arr2 = []
const itr2 = await doc2.getPageIterator(1)
for (; await itr2.hasNext(); itr2.next()) {
const page = await itr2.current()
arr2.push(page)
}
const doc2Pages = arr2
const newDoc = await instance.Core.PDFNet.PDFDoc.create()
newDoc.lock()
const biggestLength = Math.max(doc1Pages.length, doc2Pages.length)
for (let i = 0; i < biggestLength; i++) {
let page1 = doc1Pages[i] as InstanceType<typeof PDFNet.Page> | undefined
let page2 = doc2Pages[i] as InstanceType<typeof PDFNet.Page> | undefined
if (page1 == null) {
page1 = await doc1.pageCreate()
}
if (page2 == null) {
page2 = await doc2.pageCreate()
}
await newDoc.appendVisualDiff(page1, page2)
}
newDoc.unlock()
return newDoc
}