Skip to content

support generating svg path only  #23

@julia-vetcove

Description

@julia-vetcove

hi there! great library. using it in react pdf, which requires us to use its own Svg and Path components. it would be useful to have an option to generate just the path of an svg without anything surrounding it. for reference, currently this is my workaround:

const generateQrCodePath = (content: string, size: number) => {
  const htmlStr = new QRCode({ content, join: true, width: size, height: size }).svg({container: 'none'});
  const parsableHtml = new DOMParser().parseFromString(htmlStr, 'text/html');
  return parsableHtml.querySelector('html > body > rect > path')?.getAttribute('d') ?? '';
};
import QRCode from 'qrcode-svg';
...
// in react pdf
return (
  <Svg>
    <Path d={generateQrCodePath(content, size)} fill='black' />
  </Svg>
);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions