Skip to content

Pdf empty when created with custom font #31

@damianed

Description

@damianed

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();
 });

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