pankaj
October 13, 2021, 1:14pm
1
Which product are you using?
PDF.js Express Plus
PDF.js Express Version
8.0.0
Detailed description of issue
How to set the maximum size of a FreeText annotation?
Expected behaviour
Does your issue happen with every document, or just one?
Link to document
Code snippet
system
October 13, 2021, 1:14pm
2
Hello, I’m Ron, an automated tech support bot
While you wait for one of our customer support representatives to get back to you, please check out some of these documentation pages:
Guides:
APIs:
Forums:
Logan
October 18, 2021, 8:13pm
3
Hey there!
What do you mean by “maximum size”? Do you mean maximum width and height? Maximum size in bytes? Maximum character count?
Please give a bit more details.
Thanks!
Logan
pankaj
October 19, 2021, 7:17am
4
Hi,
We need to set maximum width and height of annotation.
Thanks!
pankaj
October 29, 2021, 12:25pm
5
Please assist, still waiting for a response.
Logan
October 29, 2021, 2:57pm
6
Hey!
Sorry for the delay - we have some internal APIs that I was trying to make work for your use case but couldn’t figure it out. I think we will add a nice API for this in the future, but for now this should do the trick:
const MAX_WIDTH = 300;
const MAX_HEIGHT = 300;
const oldFunc = instance.Core.Tools.GenericAnnotationCreateTool.prototype.mouseMove;
instance.Core.Tools.GenericAnnotationCreateTool.prototype.mouseMove = function(...args) {
oldFunc.apply(this, args)
if(this.annotation) {
this.annotation.Width = Math.min(this.annotation.Width, MAX_WIDTH)
this.annotation.Height = Math.min(this.annotation.Height, MAX_HEIGHT)
}
}
This will work for any annotation that requires 2 clicks to make (shapes, lines, etc). For things like freehand annotations it becomes a lot more complicated, so hopefully this is all you need.
Thanks for your patience,
Logan