Skip to content

sait/pdfmakego

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pdfmakego

Create PDF Documents in Golang, using PdfMake-JS in a Embbed V8 Engine

This is an easy way to create PDF Documents in a Golang enviroment, using the pdfmake javascript library

It works running javascript code in a V8 Engine, and then returning the PDF to Golang

PDFMake Playground

Golang, Javascript and C++ dancing together

Enjoy it !

Build and Run

Build program:

# Before test this program, get pdfmake.js, using:
wget https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.12/pdfmake.js
go mod tidy
go build
./pdfmakego

Error: TypeError: Cannot read properties of undefined (reading 'navigator')

./pdfmakego

TypeError: Cannot read properties of undefined (reading 'navigator')
pdfmakecode.js:61176:1184
TypeError: Cannot read properties of undefined (reading 'navigator')
    at Object.<anonymous> (pdfmakecode.js:61176:1184)
    at pdfmakecode.js:61175:35
    at 42616 (pdfmakecode.js:61176:109)
    at __webpack_require__ (pdfmakecode.js:74137:42)
    at 45314 (pdfmakecode.js:54432:17)
    at __webpack_require__ (pdfmakecode.js:74137:42)
    at 36164 (pdfmakecode.js:21432:34)
    at __webpack_require__ (pdfmakecode.js:74137:42)
    at pdfmakecode.js:74173:37
    at pdfmakecode.js:74176:12
2025/09/12 16:26:28 Failed to run JS module: TypeError: Cannot read properties of undefined (reading 'navigator')

Comment some request in pdfmake.js

  • Open pdfmake.js
  • Search for: FileSaver
  • Comment this 2 lines
  • Save
54432 // var FileSaver = __webpack_require__(42616);
54433 // var saveAs = FileSaver.saveAs;

Final Run

ignacio@igt25:~/projects/go/pdfmakego$ ./pdfmakego 
Tests using v8 Version: 10.9.194.9-v8go
RunScript(pdfmake.js): undefined

starting myScript.js...
ending myScript.js...
RunScript(myScript.js): Finish myScript.js
PDF in Base64 is ready
File 'myDocument.pdf' saved successfully from base64 string.
ending main.go  !

About

Run pdfmake in golang

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages