September 16, 2024


pdfjs missing text when render

When getDocument, should have cMapUrl and cMapPacked options

https://github.com/mozilla/pdf.js/blob/014ce7c1dbf0ff8659a3afb965d45fe5931962a6/examples/node/pdf2png/pdf2png.mjs#L69C3-L71C47

const pdf = await getDocument({
  url,
  cMapUrl: 'public/cmaps/',
  cMapPacked: true,
}).promise

Use vite-plugin-static-copy to copy the cmaps folder from node_modules to public

https://blog.csdn.net/Li_Ning21/article/details/133890431

https://stackoverflow.com/questions/77828784/does-vite-plugin-static-copy-work-in-dev-mode

https://github.com/sapphi-red/vite-plugin-static-copy

viteStaticCopy({
  targets: [
    {
      src: path.resolve(__dirname, 'node_modules/pdfjs-dist/cmaps/'),
      dest: 'public/',
    },
  ],
}),

July 26, 2024


Rotate image with restrict directions

https://github.com/tldraw/tldraw/blob/87b231abcfe247c95615d4b979f6e523a6a25dc2/packages/editor/src/lib/editor/Editor.ts#L5521

We want something similar to rotate when holding shift key, since we don’t have access to Rotating tool state, we update the rotation after Rotating tool finish its job, aka onRotateEnd

The rotateShapesBy function also trigger another rotating event making onRotateEnd runs again so we need to unselect current shape to stop this loop.