Skip to content

Conversation

kunal-595
Copy link

@kunal-595 kunal-595 commented Oct 21, 2025

Closes #455

This PR adds support for custom Unicode fonts in PDF generation, allowing users to render Unicode characters (Arabic, Chinese, Japanese, etc.) by providing their own font files.

Changes

  • Modified PdfTransformerBase.js to accept an optional fonts parameter in pdfMakeToPdfStreamWithCallback() and pdfMakeToPdfStream() methods
  • Updated PdfTransformer.js to accept and pass through the fonts parameter in pdfMakeToPdfBuffer() method
  • Exported defaultFonts from packages/markdown-pdf/index.js to allow users to extend the default Liberation fonts
  • Added documentation in packages/markdown-pdf/README.md with usage examples showing how to use custom Unicode fonts
  • Maintained full backward compatibility - existing code works unchanged

Flags

  • Breaking Changes: None - the fonts parameter is optional and defaults to existing Liberation fonts
  • Testing: Existing unit tests should pass unchanged; new functionality allows Unicode rendering when custom fonts are provided
  • Dependencies: No new dependencies added

Screenshots or Video

N/A - API enhancement for font support

Related Issues

Author Checklist

  • Ensure you provide a DCO sign-off for your commits using the --signoff option of git commit.
  • Vital features and changes captured in unit and/or integration tests
  • Commits messages follow AP format
  • Extend the documentation, if necessary


module.exports.PdfTransformer = require('./lib/PdfTransformer');
module.exports.ToPdfMake = require('./lib/ToPdfMake');
module.exports.defaultFonts = require('./lib/pdfmakeutil').defaultFonts;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
module.exports.defaultFonts = require('./lib/pdfmakeutil').defaultFonts;
module.exports.DefaultFonts = require('./lib/pdfmakeutil').defaultFonts;

Copy link
Author

Choose a reason for hiding this comment

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

Thanks ,I changed the export to DefaultFonts and updated the README example .The PR has been updated. Please let me know if you'd like any additional changes.

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.

Unicode fonts for pdf transform

2 participants