Click here to Skip to main content
15,741,391 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Below i have pasted working code. The code fetches a pdf and re sizes the canvas to that size.
Now i want to place text on the same canvas which can be moved and re sized. Code for placing text and re sizing is here : Can any one merge both the code and help me out.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"                 "">

<html xmlns="">
<head runat="server">
<script src=>
<canvas id="canvas" style="border:1px solid black">

  var pdf = null;
PDFJS.disableWorker = true;
var pages = new Array();
var canvas = document.getElementById('canvas');
var context = canvas.getContext('2d');
var scale = 1.5;
var canvasWidth = 0;
var canvasHeight = 0;
var pageStarts = new Array();
pageStarts[0] = 0;
var url = 'pdf/PRO1000093000.pdf';
PDFJS.getDocument(url).then(function getPdfHelloWorld(_pdf) {
    pdf = _pdf;
    //Render all the pages on a single canvas
    for (var i = 1; i <= pdf.numPages; i++) {
        pdf.getPage(i).then(function getPage(page) {
            var viewport = page.getViewport(scale);
            canvas.width = viewport.width;    // changing canvas.width and/or     canvas.height auto-clears the canvas
            canvas.height = viewport.height;
            page.render({ canvasContext: context, viewport: viewport });
            pages[i - 1] = context.getImageData(0, 0, canvas.width, canvas.height);
            if (canvas.width > canvasWidth) {  // calculate the width of the final display canvas
                canvasWidth = canvas.width;
            canvasHeight += canvas.height;   // calculate the accumulated with of the final display canvas
            pageStarts[i] = pageStarts[i - 1] + canvas.height;    // save the "Y" starting position of this pages[i]
    canvas.width = canvasWidth;
    canvas.height = canvasHeight;  // this auto-clears all canvas contents
    for (var i = 0; i < pages.length; i++) {
        context.putImageData(pages[i], 0, pageStarts[i]);

<form id="form1" runat="server">

Updated 6-Jul-14 19:28pm
Mohibur Rashid 7-Jul-14 1:28am    
The answer is no.
Member 10212996 7-Jul-14 1:33am    
i mean dont know ans?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900