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

Add support for spot colors #1464

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

aslakhellesoy
Copy link

What kind of change does this PR introduce?

This adds support for spot colors - see PDF Association and Adobe for details.

A new PDFDocument.addSpotColor method has been added:

const doc = new PDFDocument();
doc.addSpotColor('PANTONE185C', 0, 100, 78, 9)

// Draw a triangle with the spot color
doc
  .moveTo(100, 150)
  .lineTo(100, 250)
  .lineTo(200, 250)
  .fill('PANTONE185C');

The code was originally written by @ziaenezhad who mentioned it in #756
Then @sekforde submitted #1457 which was closed unmerged.

My code is based on the two contributions above, but I've also added a test, and updated the documentation and changelog. So hopefully this in a more mergable condition.

Checklist:

  • Unit Tests
  • Documentation
  • Update CHANGELOG.md
  • Ready to be merged

@@ -1,4 +1,4 @@
import diff from 'jest-diff';
import { diff } from 'jest-diff';
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not strictly related to this PR, but as I was running the tests, my new test initially failed, and I had to change this to make the test error correctly.

@ErnestoBorio

This comment was marked as off-topic.

@hubertmuller
Copy link

Hi, I think this is highly expected feature. Anyone to resolve conflicts?

@aslakhellesoy
Copy link
Author

@hubertmuller I've merged the latest from master and resolved merge conflicts.

@@ -40,7 +40,7 @@ class PDFObject {
static convert(object, encryptFn = null) {
// String literals are converted to the PDF name type
if (typeof object === 'string') {
return `/${object}`;
return /^[/[(\d].*/.test(object) ? object : `/${object}`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add unit tests for this change?

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

Successfully merging this pull request may close these issues.

4 participants