-
Notifications
You must be signed in to change notification settings - Fork 451
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Vsualized region of figure or table by pdfbox #528
Comments
Hello @Sunnycheey Yes you can have a look at the class |
Any luck in doing so? I believe it should look something like this based on the code sample
but it totally points to something else in my case |
@ehapmgs hello! Do you want to annotate a PDF with pdfbox (so producing a new PDF with annotations) or annotate a PDF with PDF.js in a browser? If first, you have examples under If second, you are in the wrong issue, but look at the web demo: Basically you need to scale the annotations (which have no unit) according to the canvas where the PDF is displayed. var page = thePos.p;
var pageDiv = $('#page-'+page);
var canvas = pageDiv.children('canvas').eq(0);;
var canvasHeight = canvas.height();
var canvasWidth = canvas.width();
var scale_x = canvasHeight / page_height;
var scale_y = canvasWidth / page_width;
var x = thePos.x * scale_x;
var y = thePos.y * scale_y;
var width = thePos.w * scale_x;
var height = thePos.h * scale_y; |
Hey @kermitt2 Thanks for the help yes it is the first case but it seems there is something wrong with the coords probably a bug that I need to open a new issue for. Using the example in I believe it used to work in version |
Indeed thanks ! I didn't look at this part since very long, I am re-discovering it :) There are actually web services to get the annotated PDF: curl -v --form input=@./s41523-020-00198-1.pdf --form type=2 localhost:8070/api/annotatePDF > s41523-020-00198-1-annot.pdf
This is working on some PDF: But for the one you tested, there is a scaling problem. I think Achraf fixed this problem in pdfalto with kermitt2/pdfalto#43 - see #330 So just need to do the same with pdfbox here... mmm |
For reference, failing PDF https://onlinelibrary.wiley.com/doi/pdf/10.1087/20100308 |
Normally fixed with 33b50b7 curl -v --form input=@./20100308.pdf --form type=2 localhost:8070/api/annotatePDF > 20100308-annot.pdf |
@kermitt2 nice! it is working as expected now thanks |
Is there some demo code for marking the content out by the coordinate (i.e, p, x, y, w, h) with pdfbox, since I really don't want to go deep with pdf....
Any help will be appreciated.
The text was updated successfully, but these errors were encountered: