Skip to content
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

Pdf empty when created with custom font #31

Open
damianed opened this issue Jan 3, 2019 · 0 comments
Open

Pdf empty when created with custom font #31

damianed opened this issue Jan 3, 2019 · 0 comments

Comments

@damianed
Copy link

damianed commented Jan 3, 2019

So I'm trying to load a pdf created with jspdf using a custom font, but when I try to load the file in a webview it appears as an empty pdf, if I don't use the custom it shows the text but if I try to use a font the text disappear. The pdf created with the custom font works in Firefox, Chrome, and Edge.

This is a piece of code to exemplify what I'm trying to do.

 const PDFWindow = require('electron-pdf-window');
 const fs = require('fs');

 let webview = document.querySelector("webview");
 webview.webContents = webview.getWebContents();
 PDFWindow.addSupport(webview);

 let doc = new jsPDF();
 doc.setFont("Roboto-Regular"); // if I coment this it works
 doc.setFontSize(8);
 doc.setFontType('bold');
 doc.text('Hello world!', 10, 10)
 let file = doc.output();

 fs.writeFile(name_of_file, file, 'utf8', function(err){
   webview.loadURL(path_to_file);
   $("#modalPDF").modal();
 });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant