Reputation: 33
I have a request to select a portion of a pdf document and save/email that generated image in an ASP.NET website. My initial thought was to load the pdf document and then utilize a draggable/resizable canvas to select a portion of the document and save it out. Does anyone know how to accomplish this or know of an alternative method of doing this.
I visualize a draggable/resizable box that they can move around a multipage document and select a save a portion of it.
Upvotes: 3
Views: 2953
Reputation: 41832
I would suggest looking at Mozilla's pdf.js project. It renders PDFs to a canvas for you. So you can then capture which section you want with your mouse, and copy out the image data:
var context = canvas.getContext("2d");
var image = context.getImageData(x, y, width, height);
In order to get mouse positions inside of a canvas, checkout thess SO questions: getting mouse position with javascript within canvas and Draw on HTML5 Canvas using a mouse
Upvotes: 3