{"id":22893339,"url":"https://github.com/yet3/svg2jspdf","last_synced_at":"2025-03-31T22:32:44.277Z","repository":{"id":65605744,"uuid":"595311444","full_name":"yet3/svg2jspdf","owner":"yet3","description":"Insert svgs into pdfs without converting them into images","archived":false,"fork":false,"pushed_at":"2023-02-07T01:40:12.000Z","size":61,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-08-12T19:14:21.947Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yet3.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-01-30T20:32:32.000Z","updated_at":"2023-12-08T15:39:35.000Z","dependencies_parsed_at":"2023-02-16T18:46:18.398Z","dependency_job_id":null,"html_url":"https://github.com/yet3/svg2jspdf","commit_stats":{"total_commits":10,"total_committers":3,"mean_commits":"3.3333333333333335","dds":"0.30000000000000004","last_synced_commit":"44b3fb93df6d187072686fa3fd46d0495ae840ef"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yet3%2Fsvg2jspdf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yet3%2Fsvg2jspdf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yet3%2Fsvg2jspdf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yet3%2Fsvg2jspdf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yet3","download_url":"https://codeload.github.com/yet3/svg2jspdf/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246552398,"owners_count":20795812,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-13T23:14:05.285Z","updated_at":"2025-03-31T22:32:44.258Z","avatar_url":"https://github.com/yet3.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# svg2jspdf\n\n![GitHub license](https://img.shields.io/github/license/yet3/svg2jspdf?style=flat)\n\u003ca href='https://www.npmjs.com/package/@yet3/svg2jspdf'\u003e\n![npm](https://img.shields.io/npm/v/@yet3/svg2jspdf)\n\u003c/a\u003e\n\nI was making a pdf using [jsPDF](https://github.com/parallax/jsPDF) and wanted to insert svg into pdf without transforming it into image so I made this.\n\n## Installation\n\n```sh\nnpm install @yet3/svg2jspdf\n```\n\nor\n\n```sh\nyarn add @yet3/svg2jspdf\n```\n\n## Usage\n\n```js\nimport JsPdf from \"jspdf\";\nimport { addSvgFromFile, addSvgFromString } from \"@yet3/svg2jspdf\";\n\nconst thirdSvgString = `your svg`;\nconst doc = new JsPdf();\n\naddSvgFromFile(doc, \"./first-svg.svg\");\naddSvgFromFile(doc, \"./second-svg.svg\", { x: 30, y: 50 });\naddSvgFromString(doc, thirdSvgString, { width: 35, height: \"auto\" });\n\ndoc.save(\"pdf.pdf\");\n```\n\nor\n\n```js\nimport JsPdf from \"jspdf\";\nimport { Svg2Pdf } from \"@yet3/svg2jspdf\";\n\nconst thirdSvgString = `your svg`;\nconst doc = new JsPdf();\nconst svg2pdf = new Svg2Pdf(doc);\n\nsvg2pdf.fromFile(\"./first-svg.svg\");\nsvg2pdf.fromFile(\"./second-svg.svg\", { y: 10 });\nsvg2pdf.fromString(thirdSvgString, { height: 25 });\n\ndoc.save(\"pdf.pdf\");\n```\n\n### Exposed functions\n\n```ts\nsetSvg2PdfHandler\u003cT extends string\u003e(tagName: T, handler: SvgHandler\u003cT\u003e): void\naddSvgFromString(doc: JsPdf, svgString: string, options?: Svg2PdfOptions = {}): void\naddSvgFromFile(doc: JsPdf, filePath: string, options?: Svg2PdfOptions = {}): void\n```\n\n### Svg2Pdf methods\n\n```ts\nsetHandler\u003cT extends string\u003e(tagName: T, handler: SvgHandler\u003cT\u003e): void\nfromString(svgString: string, options?: Svg2PdfOptions): void\nfromFile(filePath: string, options?: Svg2PdfOptions): void\n```\n\n### Svg2PdfOptions\n\n| **Name** |           **Type**            | **Default value** |\n| :------: | :---------------------------: | :---------------: |\n|    x     |      number \\| undefined      |         0         |\n|    y     |      number \\| undefined      |         0         |\n|  width   | number \\| 'auto' \\| undefined |      'auto'       |\n|  height  | number \\| 'auto' \\| undefined |      'auto'       |\n\n### Supported svg tags\n\n- path\n- polygon\n- polyline\n- line\n- rect\n- circle\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyet3%2Fsvg2jspdf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyet3%2Fsvg2jspdf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyet3%2Fsvg2jspdf/lists"}