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 metadata methods to PDFDocument #204

Merged
merged 10 commits into from
Oct 1, 2019
Merged

Add metadata methods to PDFDocument #204

merged 10 commits into from
Oct 1, 2019

Conversation

Hopding
Copy link
Owner

@Hopding Hopding commented Sep 27, 2019

Closes #162.

  • Add utf8Encode(...) and utf16Encode(...) functions for strings.
  • Add PDFHexString.fromText(...) method to create hex strings from the input string's UTF-16 encoding.
  • Add PDFString.fromDate(...) method to create a literal string from a date object.
  • Add several new methods to PDFDocument to easily add metadata to documents:
    • PDFDocument.setTitle(string)
    • PDFDocument.setAuthor(string)
    • PDFDocument.setSubject(string)
    • PDFDocument.setKeywords(string[])
    • PDFDocument.setProducer(string)
    • PDFDocument.setCreator(string)
    • PDFDocument.setCreationDate(Date)
    • PDFDocument.setModificationDate(Date)

@Hopding Hopding merged commit 7e06c40 into master Oct 1, 2019
@Hopding Hopding deleted the Utf8EncodeStrings branch October 1, 2019 19:46
@Hopding
Copy link
Owner Author

Hopding commented Oct 9, 2019

Version 1.2.0 is now published. It contains the changes from this PR. The full release notes are available here.

You can install this new version with npm:

npm install pdf-lib@1.2.0

It's also available on unpkg:

Hopding added a commit that referenced this pull request Aug 30, 2021
* UTF-8 encode strings

* Add unit tests for utf8Encode

* Add another utf8Encode test

* Supporting UTF-16 encoding of PDFHexStrings

* Add tests for PDFHexString and PDFString

* Add PDFDocument metadata methods

* Add doc comments to PDFDocument metadata methods

* Update scratchpad

* Update test apps
@viniciusbenite
Copy link

Hello,

Does the PDFDocument methods (setCreator for e.g.) updates the metadata info if it is already there? Or it just adds if doesn't exists?

I am having troubles trying to update (to delete, in my case) the metadata info using those methods.

Thanks in advance.

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.

None yet

2 participants