Coder Social home page Coder Social logo

rkusa / pdfjs Goto Github PK

View Code? Open in Web Editor NEW
767.0 26.0 142.0 7.95 MB

A Portable Document Format (PDF) generation library targeting both the server- and client-side.

License: MIT License

JavaScript 83.84% HTML 0.34% TypeScript 15.82%
javascript pdf pdf-generation pdf-report pdf-merge nodejs browser

pdfjs's Introduction

pdfjs

A Portable Document Format (PDF) generation library targeting both the server- and client-side.

NPM

Documentation | Changelog | Playground | Examples

npm install pdfjs

Maintenance Status

On life-support. No new features planned. Only gets fixes if time allows. I recommend that you use something else.

MIT License

MIT

pdfjs's People

Contributors

amauryd avatar antontfd avatar dasprid avatar dependabot-preview[bot] avatar dependabot[bot] avatar dmitriyslabodchikov avatar hillerstorm avatar jpbourgeon avatar kindaok avatar knownasilya avatar minimajack avatar mptr avatar pofider avatar rhodgkins avatar rkusa avatar sannies avatar severi avatar somejeff avatar tim-we avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pdfjs's Issues

appendPageNumber shows pageCount

If I use
var footer = doc.footer()
footer.text({ textAlign: 'right' }).appendPageNumber();

the pdf only contains the last page number on all pages. Could you please check this or give me an advice if Im doing this wrong?

automatic page break not working as expected

Hi,

I append one table after another to a pdfdoc and it works fine on one page. But if a table doesnt fit on page it throws an error:
node_modules/pdfjs/lib/pdf/node/table.js:110
var onTop = this.children[j - 1].refs[index++]
^
TypeError: Cannot read property '0' of undefined
If I include a minimal table that fits on page its no problem, but if this table has one more row and then it doesnt fit on page it throws this error.

If I include doc.pageBreak() before this table, then the new page is shown as page one showing only the last table.

Do I miss a configuration thing to tell pdfjs that it should automatically calculate page breaks?

Thanks for your help
Günter

Is there a way to manually insert page breaks?

I am looking for something like

doc.pageBreak();

or

doc.addPage();

I would expect to add it at the document level, or as an op:

var ops = doc.ops();
ops.op('pgbr');

If it is an op, I'm not sure where I can find that information. Is there another website that shows all possible "pdf operations" ? If so, could you please link to it in your documentation?

Thanks for the great tool!!

Question: Is it possible to place a text on a defined position?

Hi,

just a question:
is it possible to place a text on a defined position? Something like this:
setPos(x,y)
text("Here I am");

Use case is that I have a background pdf (like described in a previous question) and I want to place some text on different places on top of the background without generating a lot of code overhead to position this like its used with images

Thanks for an short answer
Günter

colspan does not work as expected

Hi,
I need to have colspan in some rows and with different cols. Here is my example which results in a corrupt pdf:

var boxFrame = doc.table({
    padding: 5,
    borderWidth: lines.thickness.thin,
    borderColor: colors.lines.gray,
    widths: ['100%']
});

var trOuter = boxFrame.tr({});
var tdOuter = trOuter.td();

var boxContent = tdOuter.table({
    padding: 3,
    borderWidth: lines.thickness.none,
    widths: ['3%', '7%', '80%', '10%']
});
// Header Row
var tr1 = boxContent.tr({borderBottomWidth: lines.thickness.medium});
tr1.td('>', {font: pdfFonts.font.opensans.bold, fontSize: 16, color: colors.text.gray});
tr1.td('lorem', {font: pdfFonts.font.opensans.bold, fontSize: 16, color: colors.text.gray, colspan: 3});

// Content Rows
var tr2 = boxContent.tr({borderBottomWidth: lines.thickness.thin});
tr2.td(' 1', {font: pdfFonts.font.opensans.bold, fontSize: 9});
tr2.td('2+3', {font: pdfFonts.font.opensans.bold, fontSize: 9, colspan: 2});
tr2.td('4', {font: pdfFonts.font.opensans.regular, fontSize: 9});
var tr2 = boxContent.tr({borderBottomWidth: lines.thickness.thin});
tr2.td(' 1', {font: pdfFonts.font.opensans.bold, fontSize: 9});
tr2.td(' 2', {font: pdfFonts.font.opensans.bold, fontSize: 9});
tr2.td('2', {font: pdfFonts.font.opensans.regular, fontSize: 9});
tr2.td('4', {font: pdfFonts.font.opensans.regular, fontSize: 9});
var tr2 = boxContent.tr({borderBottomWidth: lines.thickness.thin});
tr2.td(' 1', {font: pdfFonts.font.opensans.bold, fontSize: 9});
tr2.td('2+3', {font: pdfFonts.font.opensans.bold, fontSize: 9, colspan: 2});
tr2.td('4', {font: pdfFonts.font.opensans.regular, fontSize: 9});
var tr2 = boxContent.tr({borderBottomWidth: lines.thickness.thin});
tr2.td(' 1', {font: pdfFonts.font.opensans.bold, fontSize: 9});
tr2.td(' 2', {font: pdfFonts.font.opensans.bold, fontSize: 9});
tr2.td('3', {font: pdfFonts.font.opensans.regular, fontSize: 9});
tr2.td('4', {font: pdfFonts.font.opensans.regular, fontSize: 9});
var tr2 = boxContent.tr({borderBottomWidth: lines.thickness.thin});
tr2.td(' 1', {font: pdfFonts.font.opensans.bold, fontSize: 9});
tr2.td(' 2', {font: pdfFonts.font.opensans.bold, fontSize: 9});
tr2.td('3', {font: pdfFonts.font.opensans.bold, fontSize: 9});
tr2.td('4', {font: pdfFonts.font.opensans.regular, fontSize: 9});

production without errors, but if I open the file then

bildschirmfoto 2015-05-20 um 19 10 57

It occurs if different cols in different rows are colspan'ed, the first colspan: 3 works as expected.

Out of memory when using pdf as image

I've used a small (50kb) PDF as image

pdfjs.load(__dirname + '/images/e.pdf', function(err, buf) {
    img = new pdfjs.Image(buf);
}); 

And than...

row.td(tdStyle).image(img, imgStyle);

The PDF is being generated quickly, but when I open it (acrobat) I get a message 'Out of memory'.

Any idea?

Missing Low-Level PDF Page Markup Operators

  • b closepath, fill,and stroke path.
  • B fill and stroke path.
  • b* closepath, eofill,and stroke path.
  • B* eofill and stroke path.
  • BI begin image.
  • BMC begin marked content.
  • BT begin text object.
  • BX begin section allowing undefined operators.
  • c curveto.
  • cm concat. Concatenates the matrix to the current transform.
  • cs setcolorspace for fill.
  • CS setcolorspace for stroke.
  • d setdash.
  • Do execute the named XObject.
  • DP mark a place in the content stream, with a dictionary.
  • EI end image.
  • EMC end marked content.
  • ET end text object.
  • EX end section that allows undefined operators.
  • f fill path.
  • f* eofill Even/odd fill path.
  • g setgray (fill).
  • G setgray (stroke).
  • gs set parameters in the extended graphics state.
  • h closepath.
  • i setflat.
  • ID begin image data.
  • j setlinejoin.
  • J setlinecap.
  • k setcmykcolor (fill).
  • K setcmykcolor (stroke).
  • l lineto.
  • m moveto.
  • M setmiterlimit.
  • n end path without fill or stroke.
  • q save graphics state.
  • Q restore graphics state.
  • re rectangle.
  • rg setrgbcolor (fill).
  • RG setrgbcolor (stroke).
  • s closepath and stroke path.
  • S stroke path.
  • sc setcolor (fill).
  • SC setcolor (stroke).
  • sh shfill (shaded fill).
  • Tc set character spacing.
  • Td move text current point.
  • TD move text current point and set leading.
  • Tf set font name and size.
  • Tj show text.
  • TJ show text, allowing individual character positioning.
  • TL set leading.
  • Tm set text matrix.
  • Tr set text rendering mode.
  • Ts set super/subscripting text rise.
  • Tw set word spacing.
  • Tz set horizontal scaling.
  • T* move to start of next line.
  • v curveto.
  • w setlinewidth.
  • W clip.
  • y curveto.

PDF doesn't render correctly in Windows 8.1 viewer

The PDF viewer that comes with Windows 8.1 doesn't render the text output from pdfjs.

Using the example on your website, here is what the PDF looks like:

pdfjs-windows

The PDF renders fine in Google Chrome.

I would be happy to experiment with some code changes to try to fix this if you don't have a Windows machine available.

Node Response output PDF file

I am using Node.js to generate PDF documents and their content based on MySQL DB data. However I am not sure on how to automatically open the document in the browser (not an dataURL / IFrame) and also automatically download the file.

Previously I would have used something like the following to download and output to the browser using PDFKit:

doc.pipe(fs.createWriteStream(filename));
// Respond to the Request with the Response (PDF File)
doc.pipe(res);
// Close the Document
doc.end();

If I have missed something in the docs apologies.

PNG image support

I recognize that the library doesn't currently support PNG images.

I looked into the effort involved, and created a fork with an initial attempt at it. Parsing image dimensions was easy, but dealing with color profiles and transparency is much more work. I had it working at one point, but don't have a decent example of it yet.

Any advice on how to move forward, or if this feature is planned?

justify alignment not working

Embedding fonts as Type 2 CID fonts (#6) broke the justify alignment, because strings are now glyph-index encoded. That is, the space character is not mapped to 0x20 anymore and the Tw operator only applies to 0x20 (and not to remaped spaces).

Question .add('text', {textAlign: right})

is textAlign possible in a .add() extension of a text object?
I tried to use this but it throws an error: ReferenceError: right is not defined
I want to know if this is possible?
otherwise I have to split the text into different columns to do the alignment which is much more work
thanks for a short advice

Vertical Text Alignment

Working on getting labels to position correctly, but they always keep to the top. Would love an option to vertical align inside of a cell.

Inconsistent whitespace

In comment you say trailing whitespace, but first .replace(/^\s+/, '') removing leading whitespaces too.

// remove trailing whitespaces if white-space style is set to normal
if (style.whiteSpace === 'normal') {
  word = word.replace(/^\s+/, '').replace(/\s+$/, '')
}

Also there is no other options for whitespace handling. If I set for example whiteSpace: null, then it inserts double spaces.

Improve Table headers

Adobe reader throw error page....
image

      // header
      if (this.opts.header === true && i > 0) {
        page.cursor.x = left
        height += this.rows[0].render(page, columns, context)
      }

code above disable double header render...
maybe first transaction include " header + first row " ?

Fragment Properties

Sizing

  • width (absolute, relative)
  • height = minHeight (absolute, relative)
  • padding

Style

  • backgroundColor

pdf.toStream() ? Issues with larger pdfs

I think I'm running into memory issues when rendering larger pdfs.

Right now I'm creating 3 similar pdf files. The page on each pdf contains a table with 25 columns and anywhere from 4 to 25 rows.

2 of the 3 pdf files work fine, because at most they produce 3 pages each. But the 3rd pdf is big. It is 6 Mb size, and has 28 pages in it. Pages 19-28 cannot be viewed in Adobe Reader (but they can be viewed in Mac Preview.)

I've tested the big pdf at "http://www.pdf-tools.com/pdf/validate-pdfa-online.aspx", PDF/A-1b, which gives me the following error:
The content stream contains an invalid operator. (10)

It says the error occurred 10 times, which makes sense since pages 19-28 cannot be viewed.

Now, if I render the same document, but only render pages 19-28, they render just fine. So there must be some resource limitation that is causing the issue.

I've tried rendering the pdf on different machines, and each machine produces the same result.

Instead of using pdf.toString() to trigger the building of the pdf, I'm wondering if creating a text stream from the pdf via a method like pdf.toStream() would prevent the resource limitation. Is this even possible to do with the code? I'm going to fork the code and try it, but if you think this is all but impossible, please let me know.

I cannot share the json data used to render the pdf, since it has client info. If you think it would really help to have this data in order to debug the issue, let me know and I'll try to obfuscate the data.

Streaming API

Streaming API for improved computing time and lower file sizes when creating large PDF documents.
Refs #46

I am not yet sure, if there will be two APIs: a streaming and the current non-streaming API. Or just a streaming one. Streaming the document has the drawbacks of not being able to look far ahead, which is relevant for things like page count and automatic table layouts.

nested tables with different border color

Hi Markus,
I'm using nested tables and want to have different color for the inner table borders. If I specify borderColor in the inner table it was rendered with color defined in the outer table. Is it possible to have different colors for this case? And in inner table I don't want to have vertical borders, but styles for inner table borders seems to have no effect. Is it possible to achieve this and how would it work? Example code (not complete):

var boxFrame = doc.table({
    padding: 5,
    borderWidth: 1,
    borderColor: 0xdddddd,
    widths: ['100%']
});

var trOuter = boxFrame.tr({});
tdOuter = trOuter.td();

var boxContent = tdOuter.table({
    padding: 5,
    borderHorizontalWidth: 1,
    borderColor: 0xff0000,
    widths: ['3%', '87%', '10%']
});
var tr1A = boxContent.tr({});
tr1A.td('', {fontSize: 16, color: 0xdddddd});
tr1A.td('Datenblatt', {fontSize: 16, color: 0x000000});
tr1A.td('gültig ab 29.12.2014', {fontSize: 7.5, color: 0x000000, textAlign: 'right'});

var tr1B = boxContent.tr({borderWidth: 0});
tr1B.td('', {fontSize: 9, color: 0x000000});
tr1B.td('lorem ipsum', {font: pdfFonts.font.opensans.italics, fontSize: 9, color: 0x000000, textAlign: 'left'});
tr1B.td('', {});

Thanks for your help
Günter

Table sizing not behaving

var avery5160 = {
        table: {
          paddingTop: 36,
          paddingBottom: 36,
          paddingLeft: 15.822,
          paddingRight: 15.822,
          widths: [189, 189, 189]
        },
        row: {
          height: 72,
          padding: 0
        },
        cell: {
          height: 72,
          padding: 0
        }
      }

I have that and I'm trying to create a template like http://www.worldlabel.com/Pages/wl-ol875.htm

It seems like either the cells or the rows are bigger then one inch..

Should pdfjs use opentype.js for font parsing?

I was thinking about replacing the current used font parsing rkusa/ttfjs with nodebox/opentype.js (there is already a test implementation in place). When I had started to implement pdfjs, opentype.js did not exist and I had to write my own font parsing (ttfjs). But it exists now and seems to be more mature (according to star and commit count). I don't have problems with parsing fonts with ttfjs, but my own use case is limited to only a couple of different fonts making "I don't have problems" a bad metric. The only drawback from using opentype.js seems to be the increased size of pdfjs (about 35% bigger) and I personally use pdfjs almost exclusively on the client-side.

If you read this and have an opinion, please let me know!
Thanks

How can do you can set the doc.image in the table layout?

@rkusa

Please teache me.

I want to set the image in the table td.

var Pdfjs = require('pdfjs');
var fs = require('fs');
os = require('os').platform();


if(os === 'linux') {
    var fonts = new Pdfjs.Font({
        //regular: fs.readFileSync(__dirname + '/open-sans/OpenSans-Regular.ttf'),
        regular: fs.readFileSync('/usr/share/fonts/vlgothic/VL-Gothic-Regular.ttf'),
        //regular: fs.readFileSync(__dirname + '/open-sans/OpenSans-Regular.ttf'),
        bold: fs.readFileSync('/usr/share/fonts/vlgothic/VL-Gothic-Regular.ttf')
    });
}

if(os === 'darwin') {
    var fonts = new Pdfjs.Font({
        //regular: fs.readFileSync(__dirname + '/open-sans/OpenSans-Regular.ttf'),
        regular: fs.readFileSync('/Library/Fonts/Osaka.ttf'),
        //regular: fs.readFileSync(__dirname + '/open-sans/OpenSans-Regular.ttf'),
        bold: fs.readFileSync('/Library/Fonts/Osaka.ttf')
    });
}

// JPEG Only
var logo = fs.readFileSync('stamp/stmp-32.jpg');

var doc = new Pdfjs(fonts);

doc.table({ header: false }, function() {
    this.tr({ bold: false, size: 11 }, function () {
        this.td();
        this.td();
        this.td();
        this.td('company', { align: 'justify', size: 14, colspan: 2 });
        this.td(doc.image(logo, { width: 64, height: 64, align:"right", warp:false }), {rowspan: 4});
    });

  ....

but now, image only line create.

will not be able like this?

Row/column height seems not to work

I've tried setting the height on the row and the columns, but nothing seems to work. The data dictates the height. I'm using master branch (0.8).

var doc = pdfjs.createDocument({
  font: fonts.openSansRegular
});
var table = doc.table({
  width: 595.296,
  height: 841.896,
  widths: ['33.3%', '33.3%', '33.3%']
});
var row = table.tr();

data.forEach(function (item, index) {
  row.td(item.ownerName + '\n' + item.address + '\n' + item.city + (item.zip ? ', ' + item.zip : ''), {
    height: 300
  });

  // Create new row after every third column (3 column setup)
  if ((index + 1) % 3  === 0) {
    row = table.tr();
  }
});

Error: Font for `bold` not provided.

@rkusa

README.md example not execute.

var Document = require('pdfjs')
var fs = require('fs')

fs.readFile('/usr/share/fonts/open-sans/OpenSans-Regular.ttf', function(err, b) {
  if (err) throw err
  var doc = new Document(new Document.Font(b))

  doc.table({ header: true, size: 11 }, function() {
    this.tr({ bold: true, borderWidth: { bottom: 1.5 } }, function() {
      this.td('#')
      this.td('Unit')
      this.td('Subject')
      this.td('Price', { align: 'right' })
      this.td('Total', { align: 'right' })
    })
    this.tr({ borderWidth: { horizontal: 0.1 } }, function() {
      this.td('2')
      this.td('pc.')
      this.td(function() {
    this.text('Article A', { size: 11, bold: true })
    this.text('Lorem ipsum ...', { size: 9, align: 'justify' })
      })
      this.td('500.00€', { align: 'right' })
      this.td('1,000.00€', { align: 'right' })
    })
    this.tr({ borderWidth: { horizontal: 0.1 } }, function() {
      this.td('1')
      this.td('pc.')
      this.td(function() {
    this.text('Article B', { size: 11, bold: true })
    this.text('Cum id fugiunt ...', { size: 9, align: 'justify' })
      })
      this.td('250.00€', { align: 'right' })  
      this.td('250.00€', { align: 'right' })
    })
    this.tr({ bold: true, align: 'right' }, function() {
      this.td('Total', { colspan: 4 })
      this.td('1,250.00€')
    })
  })

  fs.writeFile(__dirname + '/test.pdf', doc.toString(), 'ascii')

})

ERROR

/home/dai_yamashita/Source/pdfjs/node_modules/pdfjs/lib/font.js:53
  if (!(type in this)) throw new Error('Font for `' + type + '` not provided.'
                             ^
Error: Font for `bold` not provided.
    at Subset.fromOpts (/home/dai_yamashita/Source/pdfjs/node_modules/pdfjs/lib/font.js:53:30)
    at text (/home/dai_yamashita/Source/pdfjs/node_modules/pdfjs/lib/content/text.js:31:97)
    at module.exports [as text] (/home/dai_yamashita/Source/pdfjs/node_modules/pdfjs/lib/content/text.js:11:10)
    at new Cell (/home/dai_yamashita/Source/pdfjs/node_modules/pdfjs/lib/content/table.js:313:20)
    at Row.td (/home/dai_yamashita/Source/pdfjs/node_modules/pdfjs/lib/content/table.js:236:14)
    at null.<anonymous> (/home/dai_yamashita/Source/pdfjs/sample1.js:10:12)
    at new Row (/home/dai_yamashita/Source/pdfjs/node_modules/pdfjs/lib/content/table.js:212:30)
    at Table.tr (/home/dai_yamashita/Source/pdfjs/node_modules/pdfjs/lib/content/table.js:41:13)
    at null.<anonymous> (/home/dai_yamashita/Source/pdfjs/sample1.js:9:10)
    at new Table (/home/dai_yamashita/Source/pdfjs/node_modules/pdfjs/lib/content/table.js:37:30)
[23:28] dai_yamashita@localhost pdfjs $ node sample1.js 

/home/dai_yamashita/Source/pdfjs/node_modules/pdfjs/lib/document.js:64
  this.subsets.push(font.subset(this, id))
                         ^
TypeError: Object

How can I get I set the font?

my enviroment Fedora20

ls /usr/share/fonts/open-sans/

OpenSans-Bold.ttf        OpenSans-ExtraBoldItalic.ttf  OpenSans-LightItalic.ttf  OpenSans-SemiboldItalic.ttf
OpenSans-BoldItalic.ttf  OpenSans-Italic.ttf           OpenSans-Regular.ttf
OpenSans-ExtraBold.ttf   OpenSans-Light.ttf            OpenSans-Semibold.ttf

1. Character width calculation problem with some glyphs of Cyrillic fonts. 2. Unsupported characters issue

Hi rkusa, first of all thank you for the great job and useful library.

I'm recently started to use pdfjs, and looks like i've got some issues here...

  1. I think here wrong calculation for character width for character "ы"
    https://www.dropbox.com/s/bkkjslefdguvf1e/%EC%8A%A4%ED%81%AC%EB%A6%B0%EC%83%B7%202015-06-03%2018.34.07.png?dl=0 - here you can check, how the word which finished with "ы" stuck to following word.
  2. If used font have no support for the used characters(like korean) everything is destroyed like that:
    https://www.dropbox.com/s/i79l1j548y7d7t2/%EC%8A%A4%ED%81%AC%EB%A6%B0%EC%83%B7%202015-06-03%2018.38.35.png?dl=0

are you familiar with such issues? any workarounds?

Best,
S.

Semver

Just something to think about, but if you are changing the API so that they are breaking changes from 0.5, then this version should be 1.0. If you are still iterating, then release it as 1.0.0-beta.1 or something along those line. Otherwise, people will have issues if they used ^0.5.3 to install this module.

Table Properties

Sizing

  • width (absolute, relative)
  • padding

Structure

  • colspan
  • rowspan (tracked here #16)

Alignment

  • align

Style

  • backgroundColor

Border

  • width
  • color

Images

Images in you wish list?
image
I try to [re]write new content object like images( only jpeg for now). What do you think about this?

Angular app - How to load font files?

I am trying to generate a client-side PDF file. I looked at examples and the like but did not find a way to read in a ttf file. It looks like the code is using an XMLHttpRequest obj but the file is bundled with the app like an image file would so not clear how I would do that. Any helpful code samples would be appreciated.

Units undocumented

It's not very clear what the numbers mean, and which units to use. Is it pixels (for widths/heights)? Seems weird since 8.5"x11" = 816px * 1056px, but defaults are different.

text color not working as expected

Thanks for this nice package. I tried to use text colors in my generated pdf like described in the documentation (if I've understood correctly):

doc.text('Example:', {size: 14, color: 0x666666});

but text color keeps black as defined in pdf.js defaults (0x000000)

What am I doing wrong?

.line doesnt include line break like expected

just updated to the newest version and now:
var s1 = 'text1';
var s2 = 'text2';
var tr5c = tr5.td({font: pdfFonts.font.opensans.regular, fontSize: 9});
tr5c.text(s1, {})
.line(s2, {});
pruduced the desired table cell including the text from s1 and s2 but without expected line break before s2
Could you please help?
thanks in advance

e.t.a. on 0.8 version

Hi @rkusa ,

First of all: great lib for generating pdf's! I use it for displaying tables. I am currently using version 0.5.4, but the 0.8 version offers a lot more features. When do you think 0.8 will be a stable version? Is it a mattor of weeks or months?

footer, pageNumber with Text prefix

need your help again:
.text('Seite:', {textAlign: 'right', font: pdfFonts.font.opensans.bold, fontSize: 9}).appendPageNumber();
works as expexted. If I replace _ after Seite with a blank then this blank does not appear in output, pageNumber is appended directly to :
Using .add(' ') doesnt work also if included between text and pageNumber, if .add('
',color: colors.text.white) is used between those parts then the pageNumber is not shown (issue of box calculation?)

could you plz check this? Thanks in advance

Question: full page background pdf within generated pdf

hi,
just a question: is it possible (and how) to place an a4 pdf as background into a pdf document and then place some text boxes in front of this to make something like an individualization of the complete document. in detail, i want to place an individual address into an existing pdf document (or as new box over the existing document. It would be great if you have a helpful idea to resolve this with pdfjs.
thanks in advance
günter

append() after pageNumber() is not working

Hi,

I'm using version 0.8.0 and I tried your example with the footer showing the page number and the page count concatenated with a forward slash "/".

It seems that the append after the pageNumber is not working:

footer.text({textAlign: 'center'}).pageNumber().append('/').pageCount();

It renders the page number and the page count but misses the "/".

A simple append on footer.text is working though.

Am I doing something wrong or is it bug? Any workaround on this?

Thanks a lot. By the way: great job! Well done!

line thickness changes in table row

Hi,
please have a look on this

    var boxFrame = doc.table({
        padding: 5,
        borderWidth: lines.thickness.thin,
        borderColor: colors.lines.gray,
        widths: ['100%']
    });

    var trOuter = boxFrame.tr({});
    var tdOuter = trOuter.td();

    var boxContent = tdOuter.table({
        padding: 3,
        borderWidth: lines.thickness.none,
        widths: ['3%', '5%', '72%', '20%']
    });
    // Header Row
    var tr1  = boxContent.tr({borderBottomWidth: lines.thickness.medium});
    var tr1c = tr1.td({});
    // include gray triangle as image
    tr1c.image(triangle, {align: 'center', width: 8})
    // tr1.td('>', {font: pdfFonts.font.opensans.bold, fontSize: 16, color: colors.text.gray});
    var _reference1 = 'text1';
    var _reference2 = 'text2';
    var td1c        = tr1.td('', {colspan: 2});
    var td1ctxt     = td1c.text('headline', {
        font: pdfFonts.font.opensans.bold,
        fontSize: 16,
        color: colors.text.gray
    });
    var td1c        = tr1.td('', {});
    var td1ctxt     = td1c.text(_reference1, {
        font: pdfFonts.font.opensans.regular,
        fontSize: 9,
        color: colors.text.black
    }).br()
        .line(_reference2, {font: pdfFonts.font.opensans.regular, fontSize: 9, color: colors.text.black});

with this code the following result appears
![bildschirmfoto 2015-06-06 um 14 26 32]

(https://cloud.githubusercontent.com/assets/4963530/8019621/1970e360-0c58-11e5-90b5-6943c16ce4ca.png)

I do not understand what I'm doing wrong. Could you help me?
Thanks for ungoing support

DIsplay glyfs

image
at the end have error with glyfs
"PЮocter&GambleW" - don't display correctly
only first 128 symbols embeded correctly from subsets...

embedding PDFs

Hi rkusa

I have a requirement to be able to place one or more .PDF files within a dynamically generated .PDF, in a similar fashion as you might insert an image JPEG, PNG etc... Would the current system be capable of this?

Better text wrapping support

I have the following issue, sometimes text wraps if the space is close to the border, and other times it doesn't. See the photo below

image001

Here's my setup:

var columnWidth = 198;
      var avery5160 = {
        document: {
          width: 612,
          height: 792,
          font: fonts.openSansRegular,
          // TODO: fontSize is used for layout fixes, remove once layouts more flexible
          fontSize: 9,
          paddingTop: 36,
          paddingBottom: 36,
          paddingLeft: 15.822,
          paddingRight: 15.822
        },
        table: {
          widths: [columnWidth, columnWidth, columnWidth]
        },
        row: {
          height: 72 // 1 inch
        },
        cell: {
          paddingLeft: 7,
          width: 189.36
        }
      };

Looking at the docs I don't see anything about wrapping for text.

is there a doc.ops example/documentation that works?

No issue, its a question.

I have seen, that pdfjs allows to work with direct pdf ops. What i want to achieve is to integrate three (simple) draws in the pdf on multiple places in a table. Therefore it seems to be not a good decision to make this with images. I attached the three forms to aks for an example on how to create those little drawings.
bildschirmfoto 2015-05-22 um 14 39 13
bildschirmfoto 2015-05-22 um 14 38 24
marked

Do you have any idea to achieve this with doc.ops? Or if you have a source to read something about this, where can I get this information. The little example is only in the documentation, not in the test.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.