Okay chat, I'm displaying a pdf page on a canvas on a webpage, I have another canvas…
- User
Okay chat, I'm displaying a pdf page on a canvas on a webpage, I have another canvas ontop of it that I'm drawing on. I'm then sending the drawing data to my controller along with the startX, startY, width, and height. I'm using Telerik Document Processing library to add the drawing to the pdf. But it never lines up right. I've been getting the startx and the starty like this: canvas.addEventListener('pointerdown', (e) => { // Start drawing the rectangle isDrawing = true; startX = e.offsetX; startY = e.offsetY; });
and getting the width and height like this:
canvas.addEventListener('pointerup', (e) => { if (!isDrawing) return;
codeisDrawing = false; let endX = e.offsetX; let endY = e.offsetY; rectWidth = endX - startX; rectHeight = endY - startY;}
But I don't think the values of the canvas is going to line up with the values of the pdf. So, I want to switch to dealing with these points with a percentage based system.
the startx will be saved as what percentage of the canvas is to the left of this point, so when it's all the way to the left it is 0% all the way to the right is 100% starty will be the same but will be indicated as the percentage of canvas above it. likewise width and height will be what percentage of the canvas the rect covers.
Then in the back end, I need to get the width and height of the page and calculate where the startx and starty are in the pdf page and how large the rect will be on the page.
- Assistant
- User
Any clue why this line document.Pages[pageNumber].Annotations.Add(widget);
would get this error. System.ArgumentException: 'The document element is associated with another parent. Parameter name: item'
document def:
var currentPDF = db.PDFs.Where(x => x.id == pdfId).Select(pdf => pdf.PDFfile).FirstOrDefault();
string fileDownloadName = "test.pdf"; string mimeType = String.Empty; using (MemoryStream input = new MemoryStream(currentPDF)) { RadFixedDocument document = new Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.PdfFormatProvider().Import(input);
- Assistant