Giter Site home page Giter Site logo

pdfmake-utils's People

Contributors

blikblum avatar dependabot[bot] avatar rotzbua avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

pdfmake-utils's Issues

Dynamical load of standard fonts for pdf creation?

Hi,

is it possible to add standard fonts dynamically for pdf creation? (Browser)

I tested following script but it does not work:

assetsLoader.registerFont({
    name: 'Courier',
    fileName: 'Courier',
    URL: 'assets/font/data/Courier.afm',
    styles: ['normal']
});

Error:

ERROR Error: "File '../font/data/Courier.afm' not found in virtual file system"

It seems that the standard font are only stored in pdfMake.rawFiles and not processed further on.

pdfmake-lite bundling for 0.1.65

Hi, @blikblum . First, thanks for you awesome work with pdfmake-lite and pdfmake-utils.
We're using them on production and they helped us in reducing our bundle size.

I'm opening this issue over this repository because I didn't finded the proper repository for pdkmake-lite, so sorry by that. We noticed that pdfmake-lite is behind pdfmake by some versions, being 0.1.65 the last one.

Thanks!

Uncaught (in promise) Error: Font 'Roboto' in style 'normal' is not defined in the font section of the document definition.

Hi,

I am testing this library but unfortunately can't make it work. Here is what I am trying to do. At this point I am literally copying your example from README.

      const pdfContent = {
        content: ["My test"],
      };

      const assetsLoader = new PdfAssetsLoader();
      pdfMake.fonts = assetsLoader.fonts;
      pdfMake.vfs = assetsLoader.vfs;

      // register Roboto font, normal variant. Roboto-Regular.woff must be in root path
      assetsLoader.registerFont({
        name: "Roboto",
        fileName: "Roboto-Regular.woff",
        styles: ["normal"],
      });
      // register Roboto font, bolditalics variant using a custom file location
      assetsLoader.registerFont({
        name: "Roboto",
        fileName: "Roboto-MediumItalic.woff",
        URL: "fonts/Roboto-MediumItalic.woff",
        styles: ["bolditalics"],
      });

      // register a file to be loaded in the root path
      assetsLoader.registerFile({ name: "MyLogo.png" });
      // register a file with a custom location
      assetsLoader.registerFile({
        name: "MyHeader.png",
        URL: "images/sunshine.png",
      });

      assetsLoader
        .load()
        .then(() => {
          console.log("assets loaded");
        })
        .catch((errors) => {
          // errors -> array with all file loading errors
          console.error("assets loading", errors);
        });

      pdfMake
        .createPdf(pdfContent)
        .download("mytest.pdf");

and the error in browser console says:

Uncaught (in promise) Error: Font 'Roboto' in style 'normal' is not defined in the font section of the document definition.
    at FontProvider.provideFont (pdfmake.min.js:2:580246)
    at pdfmake.min.js:2:103003
    at Array.forEach (<anonymous>)
    at measure (pdfmake.min.js:2:102066)
    at TextTools.buildInlines (pdfmake.min.js:2:103564)
    at DocMeasure.measureLeaf (pdfmake.min.js:2:600645)
    at pdfmake.min.js:2:598540
    at StyleContextStack.auto (pdfmake.min.js:2:163364)
    at DocMeasure.measureNode (pdfmake.min.js:2:597427)
    at DocMeasure.measureVerticalContainer (pdfmake.min.js:2:601611)

Any idea of what I'm doing wrong?

thank you very much

Create LazyPdfMake

Add a class that handles loading assets as well the pdfMake bundle

Should accept fonts and files as params and a ready method

Example:

const fonts = {
  Roboto: {italics: '[url]'}
}
const pdfMake = new LazyPdfMake({fonts})
await pdfMake.ready()
pdfMake.instance // actual pdfMake
pdfMake.fileExists('[filePath]')

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.