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

Tiling pattern support #2348

Closed
jlogar opened this issue Oct 13, 2021 · 7 comments
Closed

Tiling pattern support #2348

jlogar opened this issue Oct 13, 2021 · 7 comments

Comments

@jlogar
Copy link

jlogar commented Oct 13, 2021

I've implemented the tiling pattern support for pdfkit (foliojs/pdfkit#526). The PR foliojs/pdfkit#1311 is awaiting review/merge.

I'm currently developing support for that on our fork pdfmake (using the forked pdfkit). If the mentioned PR gets merged I would also like to add support for patterns to pdfmake.

Patterns need to be defined as resources in PDF so a patterns field would need to be added to the document definition. Something along the lines of:

var docDefinition = {
// ..
content: [
  // ..
],
patterns: {
  stripe45d: {
    boundingBox: [1, 1, 4, 4],
    xStep: 3,
    yStep: 3,
    pattern: '1 w 0 1 m 4 5 l s 2 0 m 5 3 l s'
  }
}};

I was wondering how I should go about implementing pattern usage in the content though. Looking at gradients implementation (in 0.2 branch) i see that a separate linearGradient field has been added. I was considering adding a pattern field (let's say for text and table cells/layouts). But I have second thoughts on that. The pattern and fillColor for table cells are more or less mutually exclusive. And pdfkit itself (and PDF spec itself) more or less treats patterns as just another color. So I am more inclined to just make the color/fillColor/background field accept a pattern tuple.
So that is:

{text: 'Some ipsum', pattern: ['stripe45d', 'yellow']}

vs.:

{text: 'Some ipsum', background: ['stripe45d', 'yellow']}

I would like to hear your thoughts on that. And whether such a PR would be needed/accepted.

jlogar added a commit to plandela/pdfmake that referenced this issue Oct 13, 2021
@jlogar
Copy link
Author

jlogar commented Oct 15, 2021

In our fork I went with the option to set the pattern as color for vector, background for text and fillColor for table cells. Also added additional overlayPattern and overlayOpacity to table cell that adds a pattern rectangle over the cell.
(can be seen at https://github.com/plandela/pdfmake)

@liborm85
Copy link
Collaborator

PR is welcome.

jlogar added a commit to plandela/pdfmake that referenced this issue Oct 16, 2021
@jlogar
Copy link
Author

jlogar commented Oct 16, 2021

Great. Will create the PR as soon as the pdfkit PR is merged. I suppose that a new version of foliojs-fork/pdfkit with the mentioned changes would need to be released.

jlogar added a commit to plandela/pdfmake that referenced this issue Oct 29, 2021
jlogar added a commit to plandela/pdfmake that referenced this issue Oct 29, 2021
@jlogar
Copy link
Author

jlogar commented Nov 2, 2021

Thanks for the merge!

Anything I can do to get this into master too?

liborm85 added a commit that referenced this issue Nov 4, 2021
@liborm85
Copy link
Collaborator

liborm85 commented Nov 4, 2021

Ported to master by commit 1a06114.

@liborm85
Copy link
Collaborator

liborm85 commented Nov 6, 2021

New version released.

@liborm85
Copy link
Collaborator

liborm85 commented Nov 6, 2021

@jlogar Would be good add to documentation https://github.com/pdfmake/docs

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

No branches or pull requests

2 participants