-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generate PDF from SVG #14
Comments
Tried this code: form-ular.html: <script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.3.1/jspdf.umd.min.js"></script>
<script src="lib/svg2pdf.umd.js"></script> fu-svg.js: async toPdf() {
const svgE = $(this.svgElement).get(0);
svgE.getBoundingClientRect();
const width = svgE.width.baseVal.value;
const height = svgE.height.baseVal.value;
const pdf = new jspdf.jsPDF(width > height ? 'l' : 'p', 'pt', [width, height]);
const font = await fetch('forms/jsd_14312/fonts/LiberationSans-Regular.ttf').then(res => res.text());
pdf.addFileToVFS("LiberationSans-Regular.ttf", font);
pdf.addFont("LiberationSans-Regular.ttf", "Liberation Sans", "normal");
pdf.svg(svgE, { width, height }).then(() => { pdf.save('myPdf.pdf')});
} and when called it throws
and
for every rendered text. |
The font is rendered properly after that, but unicode chars (glyphs, etc.) are rendered as from different encoding.
|
Moreover Acrobat Reader reports 'The font LiberationSans-Regular.ttf' contains a bad /BBox' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
There is a js library to generate PDF from SVG (https://github.com/yWorks/svg2pdf.js/ ) that can generate PDF from SVG (so it is not necessary to include redundant PDF in sources).
Let's try it and if it works, remove the PDF (or make possible both - generate from SVG or use attached PDF)
The text was updated successfully, but these errors were encountered: