Skip to content

node-demo produces 2 blank pages #8

Description

@dlcurry

Using latest pdf.js - the one with drawLine...
With node.js v0.4.12, which might have something to do with it, the demo produces 2 blank pages; no text or graphics. Select All, copy, paste into a text doc pastes nothing. testFile57.pdf in the repo and download displays properly, select/copy/paste pastes the text into a text editor. Ubuntu Natty 11.04.

I note that in the repo/download file, the node version is v0.3.0-pre.

There are differences between the files:
testFile57:
%PDF-1.3

<>
BT /F1 16.00 Tf ET
BT 56.69 785.20 Td (hello, I am PDF.) Tj ET
BT 56.69 756.85 Td (i was created using node.js version: v0.3.0-pre) Tj ET
BT 56.69 728.50 Td (i can also be created from the browser) Tj ET

endstream
endobj

testFile44 (mine):
%PDF-1.3

<>
BT undefined 16.00 Tf ET
BT /F0 16.00 Tf ET
BT 56.69 785.20 Td (hello, I am PDF.) Tj ET
BT /F0 16.00 Tf ET
BT 56.69 756.85 Td (i was created using node.js version: v0.4.12) Tj ET
BT /F0 16.00 Tf ET
BT 56.69 728.50 Td (i can also be created from the browser) Tj ET

endstream
endobj

Similar block a bit later on - also has 'undefined'.

Update: I was able to get it to work:

  1. node-demo.js:
    var doc = new pdf();
    doc.setFont(1); //<<<< added to make sure fonts[] had 1 font
    doc.text(20, 20, 'hello, I am PDF.');
    doc.text(20, 30, 'i was created using node.js version: ' + process.version);
    doc.text(20, 40, 'i can also be created from the browser');
  2. pdf.js:
    var _addPage = function() {
    beginPage();
    // Set line width
    out(sprintf('%.2f w', (lineWidth * k)));
// 16 is the font size
pageFontSize = fontSize;
pageFont = font;
//DLC-->>>>>delete out('BT ' + fonts[font] + ' ' + parseInt(fontSize) + '.00 Tf ET');    
//fonts[] is undefined at this point when called by _addPage();

}

Alternately, rename setFont: function... to var _setFont = function... and move the function up where _addPage() is. Then create
setFont: function(f){
_setFont(f);
},
in its place. Then, where _addPage() is called to automatically create the first page, FIRST call
_setFont(1);

This change removes the need for node-demo.js to have an initializing call to setFont.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions