Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

numbered list type is not working #839

Open
alexaung opened this issue Jul 4, 2018 · 8 comments
Open

numbered list type is not working #839

alexaung opened this issue Jul 4, 2018 · 8 comments

Comments

@alexaung
Copy link

alexaung commented Jul 4, 2018

doc.list(["item1", "item2", "item3"], { listType: 'numbered' } as any);

it is only show bullted

@paul-vd
Copy link

paul-vd commented Jul 10, 2018

i checked the source and i see they dont have any numbered options
here are a list of available options,

        lineBreak?: boolean;
        width?: number;
        height?: number;
        ellipsis?: boolean|string;
        columns?: number;
        columnGap?: number;
        indent?: number;
        paragraphGap?: number;
        lineGap?: number;
        wordSpacing?: number;
        characterSpacing?: number;
        fill?: boolean;
        stroke?: boolean;
        link?: string;
        underline?: boolean;
        strike?: boolean;
        continued?: boolean;
        align?: string;```

@paul-vd
Copy link

paul-vd commented Jul 10, 2018

@devongovett Any plans for adding numbered list styling, as to pass an option like @alexaung suggests,

doc.list(["item1","item2","item3"],{numbered: true}) will return

  1. item1
  2. item2
  3. item3

instead of

  • item1
  • item2
  • item3

@paul-vd
Copy link

paul-vd commented Jul 10, 2018

@alexaung if you really need this you can simply do the following

  doc.text("2. domingo")
  doc.text("3. kilo")
  doc.text("4. dev")

@alafr
Copy link
Collaborator

alafr commented Jul 10, 2018

It works but you will have to use the new version v0.8.3 which is not yet released.

@paul-vd
Copy link

paul-vd commented Jul 10, 2018

Thanks added it to my node environment with coffee-script works perfect

@lukasvan3l
Copy link

With current version you can use listType: 'numbered' or listType: 'lettered'. No mention of this in the documentation, but here it is in the code: https://github.com/foliojs/pdfkit/blob/master/lib/mixins/text.js#L146

My working example:

doc.list(words, left, top, { listType: 'numbered' })

@bart
Copy link

bart commented Nov 27, 2024

I know this is an old issue. I'm using pdfkit in NodeJS and having a problem using listType numbered. I tried a couple of things but problem is that numbers are always 1.. Here is an example:

import * as fs from "fs"
import PDFDocument from "pdfkit"

const doc = new PDFDocument({ size: "A4" })
doc.pipe(fs.createWriteStream("file.pdf"))
doc.list(["Number 1", "Number 2", "Number 3"], { listType: "numbered" })
doc.end()

Results in a PDF like this:

1. Number 1
1. Number 2
1. Number 3

Do you have any idea and/or solution for this issue? Thanks in advance.

@bart
Copy link

bart commented Nov 27, 2024

Update: I also found this: #1517 so seems to be an open issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants