Giter Site home page Giter Site logo

adrg / go-wkhtmltopdf Goto Github PK

View Code? Open in Web Editor NEW
210.0 210.0 21.0 84 KB

Go bindings for wkhtmltopdf and high-level HTML to PDF conversion interface

Home Page: https://pkg.go.dev/github.com/adrg/go-wkhtmltopdf

License: MIT License

Go 100.00%
bindings converter go golang golang-library golang-package html html-to-pdf library native pdf pdf-conversion pdf-converter wkhtmltopdf wkhtmltox

go-wkhtmltopdf's Introduction

ADRIAN-GEORGE BOSTAN
SOFTWARE DEVELOPER

👋 Introduction

Hi, I'm Adrian! I'm a software developer based in Romania. I am passionate about Go, C++, Python, Vim, Linux and wrist watches. Nice to see you here! This is the home of my open-source projects.

⚡ Stats

⭐ Repositories adrg's repository stats
🛠️ Languages adrg's most used languages
🔥 Contributions

If you find my projects useful, show some ♥️ by giving them a star!


🔗 Connect with me

adrg's Twitter profile adrg's LinkedIn profile Send adrg an email

go-wkhtmltopdf's People

Contributors

adrg avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

go-wkhtmltopdf's Issues

go-wkhtmltopdf missing wkhtmltox.dll

Hello,

I'm building a program using go-wkhtmltopdf. I followed the install guide and installed the wkhtmltopdf as requested.

When I run my program, I have the following err:
the code cannot proceed because wkhtmltox.dll was not found. Reinstallling may ffix the problem

Any Idea on how to tell go-wkhtmltopdf where to find the requested dll?
Bellow my go env output:

set GO111MODULE=auto
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\xxx\AppData\Local\go-build
set GOENV=C:\Users\xxx\AppData\Roaming\go\env
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\xx\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\xx\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\Users\xx\go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=C:\Users\xxx\go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.16
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\Users\xxx\AppData\Local\Temp\go-build397288522=/tmp/go-build -gno-record-gcc-switches

PS: I'm using mingw64

Getting error on get the package

> go get github.com/adrg/go-wkhtmltopdf
go: finding github.com/adrg/go-wkhtmltopdf v0.2.2
go: downloading github.com/adrg/go-wkhtmltopdf v0.2.2
go: extracting github.com/adrg/go-wkhtmltopdf v0.2.2
# github.com/adrg/go-wkhtmltopdf
../../go/pkg/mod/github.com/adrg/[email protected]/converter.go:7:10: fatal error: wkhtmltox/pdf.h: No such file or directory
 #include <wkhtmltox/pdf.h>
          ^~~~~~~~~~~~~~~~~
compilation terminated.

how let go-wkhtmltopdf know where is wkhtmltox/pdf.h

hi man, sorry i dont where else to ask this, the repo where i used the wkhtmltopdf image not responding the issue.

So, i try to use wkhtmltopdf on my dockerfile which look like this

FROM ghcr.io/surnet/alpine-wkhtmltopdf:3.17.0-0.12.6-small as wkhtmltopdf
FROM golang:1.19.9-alpine3.17

# Install dependencies for wkhtmltopdf
RUN apk add --no-cache \
    libstdc++ libx11  libxrender  libxext libssl1.1 
    ca-certificates fontconfig freetype ttf-dejavu \
    ttf-droid ttf-freefont ttf-liberation \
    # more fonts
  && apk add --no-cache --virtual .build-deps \
    msttcorefonts-installer \
  # Install microsoft fonts
  && update-ms-fonts \
  && fc-cache -f \
  # Clean up when done
  && rm -rf /tmp/* \
  && apk del .build-deps \

COPY --from=wkhtmltopdf /bin/wkhtmltopdf /bin/wkhtmltopdf
COPY --from=wkhtmltopdf /bin/libwkhtmltox* /bin/

WORKDIR /src
COPY . .
RUN go mod vendor && go mod verify
RUN go build -o main .

EXPOSE 8080

CMD ["./main"]

which totally fine when i havent install https://github.com/adrg/go-wkhtmltopdf but when i install it and build again. its always throws this error error during docker build.

> [builder 7/7] RUN go build -o /app-bin /src/main.go:
#0 3.510 # github.com/adrg/go-wkhtmltopdf
#0 3.510 vendor/github.com/adrg/go-wkhtmltopdf/converter.go:7:10: fatal error: wkhtmltox/pdf.h: No such file or directory
#0 3.510     7 | #include <wkhtmltox/pdf.h>
#0 3.510       |          ^~~~~~~~~~~~~~~~~
#0 3.510 compilation terminated

do you know how to let the go compiler where the wkhtmltox is ?
i've stry specify cgo flags but still doesnt work

i really appreciate your answer,

Prerequisites Install Error

Hello

When I followed this instruction to install wkhtmltox in my Windows, some errors occured.

  1. I chose to install wkhtmltopdf in E:\wkhtmltox.
    image

When I tried to use "go build" in cmd, I got the message as follows. It said "package .: no Go files in E:\wkhtmltox". How can I solve this problem?

image

  1. Another issue may associate with the first problem.

Although I "go build" failed, I still tried to run my program. Unfortunately, it did not work and gave me some error messages. How can I solve with it?

Please Help me! Thank you!

image

Inconsistent pdf formatting and output

I am using the code below to generate my pdf using the library. The code executes appropriately. However, most of the time I lose my HTML formatting or even data in many cases. What could be the issue? Could this be memory related?

Note: My HTML has some css and js

package dummy

import (
	"code/common"
	"log"
	"os"

	pdf "github.com/adrg/go-wkhtmltopdf"
)

func GeneratePdf(filename string) {
	

	// Initialize library.
	if err := pdf.Init(); err != nil {
		log.Println(err)
	}
	defer pdf.Destroy()
	

	// Create object from file.
	object, err := pdf.NewObject("./inputhtml/uc_" + filename + ".html")
	if err != nil {
		log.Println(err)
	}

	// Create object from URL.
	object2, err := pdf.NewObject("./inputhtml/tc_" + filename + ".html")
	if err != nil {
		log.Println(err)
	}


	// Create object from reader.
	object3, err := pdf.NewObject("./inputhtml/invoice_" + filename + ".html")
	if err != nil {
		log.Println(err)
	}

	object4, err := pdf.NewObject("./inputhtml/feru_" + filename + ".html")
	if err != nil {
		log.Println(err)
	}



	// Create converter.
	converter, err := pdf.NewConverter()
	if err != nil {
		log.Println(err)
	}
	defer converter.Destroy()

	// Add created objects to the converter.
	converter.Add(object)
	converter.Add(object2)
	converter.Add(object3)
	converter.Add(object4)

	// Set converter options.
	converter.Title = "Out documents"
	converter.PaperSize = pdf.A4
	converter.Orientation = pdf.Portrait
	converter.MarginTop = "1cm"
	converter.MarginBottom = "1cm"
	converter.MarginLeft = "10mm"
	converter.MarginRight = "10mm"

	// Convert objects and save the output PDF document.
	outFile, err := os.Create(common.CONST_TMPPDF_FOLDER + "out_" + filename + ".pdf")
	if err != nil {
		log.Println(err)
	}
	defer outFile.Close()

	if err := converter.Run(outFile); err != nil {
		log.Println(err)
	}
}

Errors

WARNING: QApplication was not created in the main() thread.
QObject::startTimer: QTimer can only be used with threads started with QThread
QObject::startTimer: QTimer can only be used with threads started with QThread
QObject::startTimer: QTimer can only be used with threads started with QThread
QObject::startTimer: QTimer can only be used with threads started with QThread

需要C包的支持

mac环境下golang1.18报错:

github.com/adrg/go-wkhtmltopdf

../../../../pkg/mod/github.com/adrg/[email protected]/converter.go:7:10: fatal error: 'wkhtmltox/pdf.h' file not found
#include <wkhtmltox/pdf.h>
^~~~~~~~~~~~~~~~~
1 error generated.

Creating PDF files in a loop

func main() {
for _, v := range []string{"import1.pdf", "import2.pdf", "import3.pdf"} {
CreatePDFFile("header.html", "footer.html", "content.html", v)
}
}

func CreatePDFFile(header, footer, content, output string) error {
// Initialize library.
if err := pdf.Init(); err != nil {
log.Print("fail init", err)

	return err
}
defer pdf.Destroy()
//Insert the content inside the template
// Create object from URL.
object, err := pdf.NewObject(content)
if err != nil {
	log.Print("fail new object", err)
	return err
}
defer object.Destroy()
object.Header.CustomLocation = header
object.Footer.CustomLocation = footer
converter, err = pdf.NewConverter()
if err != nil {
	log.Print("fail new converter", err)
	return err
}

defer converter.Destroy()

converter.PaperSize = pdf.Letter

// Add created objects to the converter.
converter.Add(object)

// Convert objects and save the output PDF document.
outFile, err := os.Create(output)
if err != nil {
	log.Print("fail create", err)
	return err
}
defer outFile.Close()

// Run converter.
if err := converter.Run(outFile); err != nil {
	log.Print("fail run", err)
	return err
}
return nil

}

Runing this code will create 1 valid file, the first one and two invalid files.

Blank pdf for react website.

I am trying to save a page from my site built in react. It generate the blank pdf as site is take sometime to load.
Is there any way to fix this issue?

Converting in gofuncs failed

I tried to spawn x gofuncs, each created a converter but failed on access violation. Is this library safe for a concurrency use?

Thanks

where to set CGO_LDFLAGS and CGO_CFLAGS

Hi, i had follow instruction of how to install wkhtmltopdf on windows. But i still confused about command

set CGO_LDFLAGS=-L{your-sdk-path}\bin
set CGO_CFLAGS=-I{your-sdk-path}\include

was this command supposed to set at my project path or at wkhtmltopdf path?
and also how to run go build on wkhtmltopdf, since there is no go.mod in it?

regarding to it, i had error like this when go build my project:

# runtime/cgo
gcc.exe: warning: Files\wkhtmltopdf\include: linker input file unused because linking not done
gcc.exe: error: Files\wkhtmltopdf\include: linker input file not found: No such file or directory

Error install package

Hi,
when i try to install this package one error ocurred.

go get github.com/adrg/go-wkhtmltopdf
# github.com/adrg/go-wkhtmltopdf
github.com/adrg/go-wkhtmltopdf/converter.go:7:27: fatal error: wkhtmltox/pdf.h: No such file or directory
compilation terminated.

panic happens

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x4433cf4]

goroutine 1 [running]:
github.com/adrg/go-wkhtmltopdf.(*objectRegistry).add(0x0, 0x7b117c0, 0x44daf40, 0xc0001c3ab0)
/Users/machel/gopath/pkg/mod/github.com/adrg/[email protected]/object_registry.go:39 +0x34
github.com/adrg/go-wkhtmltopdf.NewConverterWithOpts(0xc0001ab440, 0xc0001a9e90, 0xc00000ed40, 0x0)
/Users/machel/gopath/pkg/mod/github.com/adrg/[email protected]/converter.go:276 +0x1e5
github.com/adrg/go-wkhtmltopdf.NewConverter(...)
/Users/machel/gopath/pkg/mod/github.com/adrg/[email protected]/converter.go:235
main.HtmlCvtPdf(0x459dc00, 0xc00002c0a8, 0xc00002cb6c, 0x4, 0x4, 0x0, 0x0, 0x0, 0x0, 0x0)

Panic WARNING: QApplication was not created in the main() thread.

Test demo ,Two requst will be panic

package main

import (
	"log"
	"net/http"
	"os"

	pdf "github.com/adrg/go-wkhtmltopdf"
)

func PrintHandle(w http.ResponseWriter, r *http.Request) {
	if err := pdf.Init(); err != nil {
		log.Fatal(err)
	}
	defer pdf.Destroy()

	// Create object from file.
	object, err := pdf.NewObject("https://www.baidu.com")
	if err != nil {
		log.Fatal(err)
	}

	// Create converter.
	converter, err := pdf.NewConverter()
	if err != nil {
		log.Fatal(err)
	}
	defer converter.Destroy()

	// Add created objects to the converter.
	converter.Add(object)

	// Set converter options.
	converter.Title = "Sample document"
	converter.PaperSize = pdf.A4

	// Convert objects and save the output PDF document.
	outFile, err := os.OpenFile("output.pdf", os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0755)
	if err != nil {
		log.Fatal(err)
	}
	defer outFile.Close()

	if err := converter.Run(outFile); err != nil {
		log.Fatal(err)
	}
	w.Write([]byte("ok"))
}

func main() {
	http.HandleFunc("/", PrintHandle)
	http.ListenAndServe("127.0.0.1:10000", nil)
}

Panic Data

WARNING: QApplication was not created in the main() thread.
QObject::startTimer: QTimer can only be used with threads started with QThread
QObject::startTimer: QTimer can only be used with threads started with QThread
QObject::connect: Cannot connect (null)::configurationAdded(QNetworkConfiguration) to QNetworkConfigurationManager::configurationAdded(QNetworkConfiguration)
QObject::connect: Cannot connect (null)::configurationRemoved(QNetworkConfiguration) to QNetworkConfigurationManager::configurationRemoved(QNetworkConfiguration)
QObject::connect: Cannot connect (null)::configurationChanged(QNetworkConfiguration) to QNetworkConfigurationManager::configurationChanged(QNetworkConfiguration)
QObject::connect: Cannot connect (null)::onlineStateChanged(bool) to QNetworkConfigurationManager::onlineStateChanged(bool)
QObject::connect: Cannot connect (null)::configurationUpdateComplete() to QNetworkConfigurationManager::updateCompleted()
fatal error: unexpected signal during runtime execution
[signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x7f6a131f884e]

runtime stack:
runtime.throw({0x65eb86, 0x7f6a135b7028})
        /usr/local/go/src/runtime/panic.go:1198 +0x71
runtime.sigpanic()
        /usr/local/go/src/runtime/signal_unix.go:719 +0x396

goroutine 6 [syscall]:
runtime.cgocall(0x5f51c0, 0xc00015b8f0)
        /usr/local/go/src/runtime/cgocall.go:156 +0x5c fp=0xc00015b8c8 sp=0xc00015b890 pc=0x4067dc
github.com/adrg/go-wkhtmltopdf._Cfunc_wkhtmltopdf_convert(0x7f69d80154f0)
        _cgo_gotypes.go:137 +0x4c fp=0xc00015b8f0 sp=0xc00015b8c8 pc=0x5ee48c
github.com/adrg/go-wkhtmltopdf.(*Converter).Run.func1(0xc0000b6000)
        /home/aveyuan/go/pkg/mod/github.com/adrg/[email protected]/converter.go:304 +0x46 fp=0xc00015b928 sp=0xc00015b8f0 pc=0x5ef766
github.com/adrg/go-wkhtmltopdf.(*Converter).Run(0xc0000b6000, {0x6a64e0, 0xc0000ba008})
        /home/aveyuan/go/pkg/mod/github.com/adrg/[email protected]/converter.go:304 +0x73 fp=0xc00015b990 sp=0xc00015b928 pc=0x5ef3d3
main.PrintHandle({0x6aaea0, 0xc0000aa000}, 0x0)
        /home/aveyuan/project/go/fkpdf/main.go:44 +0x2d7 fp=0xc00015ba48 sp=0xc00015b990 pc=0x5f4c57
net/http.HandlerFunc.ServeHTTP(0x0, {0x6aaea0, 0xc0000aa000}, 0x0)
        /usr/local/go/src/net/http/server.go:2047 +0x2f fp=0xc00015ba70 sp=0xc00015ba48 pc=0x5dcbcf
net/http.(*ServeMux).ServeHTTP(0x0, {0x6aaea0, 0xc0000aa000}, 0xc000184100)
        /usr/local/go/src/net/http/server.go:2425 +0x149 fp=0xc00015bac0 sp=0xc00015ba70 pc=0x5de4c9
net/http.serverHandler.ServeHTTP({0xc000090030}, {0x6aaea0, 0xc0000aa000}, 0xc000184100)
        /usr/local/go/src/net/http/server.go:2879 +0x43b fp=0xc00015bb80 sp=0xc00015bac0 pc=0x5df7fb
net/http.(*conn).serve(0xc000110960, {0x6abca0, 0xc000100de0})
        /usr/local/go/src/net/http/server.go:1930 +0xb08 fp=0xc00015bfb8 sp=0xc00015bb80 pc=0x5dbf28
net/http.(*Server).Serve·dwrap·87()
        /usr/local/go/src/net/http/server.go:3034 +0x2e fp=0xc00015bfe0 sp=0xc00015bfb8 pc=0x5e014e
runtime.goexit()
        /usr/local/go/src/runtime/asm_amd64.s:1581 +0x1 fp=0xc00015bfe8 sp=0xc00015bfe0 pc=0x465281
created by net/http.(*Server).Serve
        /usr/local/go/src/net/http/server.go:3034 +0x4e8

goroutine 1 [IO wait]:
internal/poll.runtime_pollWait(0x7f69e860bf58, 0x72)
        /usr/local/go/src/runtime/netpoll.go:234 +0x89
internal/poll.(*pollDesc).wait(0xc000144000, 0xc00002a000, 0x0)
        /usr/local/go/src/internal/poll/fd_poll_runtime.go:84 +0x32
internal/poll.(*pollDesc).waitRead(...)
        /usr/local/go/src/internal/poll/fd_poll_runtime.go:89
internal/poll.(*FD).Accept(0xc000144000)
        /usr/local/go/src/internal/poll/fd_unix.go:402 +0x22c
net.(*netFD).accept(0xc000144000)
        /usr/local/go/src/net/fd_unix.go:173 +0x35
net.(*TCPListener).accept(0xc00000e0d8)
        /usr/local/go/src/net/tcpsock_posix.go:140 +0x28
net.(*TCPListener).Accept(0xc00000e0d8)
        /usr/local/go/src/net/tcpsock.go:262 +0x3d
net/http.(*Server).Serve(0xc000142000, {0x6aacf0, 0xc00000e0d8})
        /usr/local/go/src/net/http/server.go:3002 +0x394
net/http.(*Server).ListenAndServe(0xc000142000)
        /usr/local/go/src/net/http/server.go:2931 +0x7d
net/http.ListenAndServe(...)
        /usr/local/go/src/net/http/server.go:3185
main.main()
        /home/aveyuan/project/go/fkpdf/main.go:52 +0x65

goroutine 7 [IO wait]:
internal/poll.runtime_pollWait(0x7f69e860bd88, 0x72)
        /usr/local/go/src/runtime/netpoll.go:234 +0x89
internal/poll.(*pollDesc).wait(0xc000144100, 0xc000158000, 0x0)
        /usr/local/go/src/internal/poll/fd_poll_runtime.go:84 +0x32
internal/poll.(*pollDesc).waitRead(...)
        /usr/local/go/src/internal/poll/fd_poll_runtime.go:89
internal/poll.(*FD).Read(0xc000144100, {0xc000158000, 0x1000, 0x1000})
        /usr/local/go/src/internal/poll/fd_unix.go:167 +0x25a
net.(*netFD).Read(0xc000144100, {0xc000158000, 0x400, 0xc00015f6b0})
        /usr/local/go/src/net/fd_posix.go:56 +0x29
net.(*conn).Read(0xc000010040, {0xc000158000, 0x400, 0xc000100f38})
        /usr/local/go/src/net/net.go:183 +0x45
net/http.(*connReader).Read(0xc000100f30, {0xc000158000, 0x1000, 0x1000})
        /usr/local/go/src/net/http/server.go:780 +0x16d
bufio.(*Reader).fill(0xc00006c300)
        /usr/local/go/src/bufio/bufio.go:101 +0x103
bufio.(*Reader).ReadSlice(0xc00006c300, 0x40)
        /usr/local/go/src/bufio/bufio.go:360 +0x2f
bufio.(*Reader).ReadLine(0xc00006c300)
        /usr/local/go/src/bufio/bufio.go:389 +0x27
net/textproto.(*Reader).readLineSlice(0xc000100f90)
        /usr/local/go/src/net/textproto/reader.go:57 +0x99
net/textproto.(*Reader).ReadLine(...)
        /usr/local/go/src/net/textproto/reader.go:38
net/http.readRequest(0xc000010040)
        /usr/local/go/src/net/http/request.go:1029 +0x79
net/http.(*conn).readRequest(0xc000110a00, {0x6abbf8, 0xc000028280})
        /usr/local/go/src/net/http/server.go:966 +0x225
net/http.(*conn).serve(0xc000110a00, {0x6abca0, 0xc000100de0})
        /usr/local/go/src/net/http/server.go:1856 +0x865
created by net/http.(*Server).Serve
        /usr/local/go/src/net/http/server.go:3034 +0x4e8

goroutine 34 [IO wait]:
internal/poll.runtime_pollWait(0x7f69e860be70, 0x72)
        /usr/local/go/src/runtime/netpoll.go:234 +0x89
internal/poll.(*pollDesc).wait(0xc000144080, 0xc000090041, 0x0)
        /usr/local/go/src/internal/poll/fd_poll_runtime.go:84 +0x32
internal/poll.(*pollDesc).waitRead(...)
        /usr/local/go/src/internal/poll/fd_poll_runtime.go:89
internal/poll.(*FD).Read(0xc000144080, {0xc000090041, 0x1, 0x1})
        /usr/local/go/src/internal/poll/fd_unix.go:167 +0x25a
net.(*netFD).Read(0xc000144080, {0xc000090041, 0x0, 0x0})
        /usr/local/go/src/net/fd_posix.go:56 +0x29
net.(*conn).Read(0xc000010038, {0xc000090041, 0x0, 0x0})
        /usr/local/go/src/net/net.go:183 +0x45
net/http.(*connReader).backgroundRead(0xc000090030)
        /usr/local/go/src/net/http/server.go:672 +0x3f
created by net/http.(*connReader).startBackgroundRead
        /usr/local/go/src/net/http/server.go:668 +0xcf
exit status 2

Two Objects with web url fail the rendering

In the example present in readme.md, I made a small change. Added two urls, thus two objects. This fails with

2021/10/06 12:09:50 could not convert the added objects

package main

import (
	"log"
	"os"

	pdf "github.com/adrg/go-wkhtmltopdf"
)

func main() {
	// Initialize library.
	if err := pdf.Init(); err != nil {
		log.Fatal(err)
	}
	defer pdf.Destroy()

	// Create object from file.
	object, err := pdf.NewObject("https://google.com")
	if err != nil {
		log.Fatal(err)
	}
	object.Header.ContentCenter = "[title]"
	object.Header.DisplaySeparator = true

	// Create object from URL.
	object2, err := pdf.NewObject("https://google.com")
	if err != nil {
		log.Fatal(err)
	}
	object.Footer.ContentLeft = "[date]"
	object.Footer.ContentCenter = "Sample footer information"
	object.Footer.ContentRight = "[page]"
	object.Footer.DisplaySeparator = true


	// Create converter.
	converter, err := pdf.NewConverter()
	if err != nil {
		log.Fatal(err)
	}
	defer converter.Destroy()

	// Add created objects to the converter.
	converter.Add(object)
	converter.Add(object2)

	// Set converter options.
	converter.Title = "Sample document"
	converter.PaperSize = pdf.A4
	converter.Orientation = pdf.Landscape
	converter.MarginTop = "1cm"
	converter.MarginBottom = "1cm"
	converter.MarginLeft = "10mm"
	converter.MarginRight = "10mm"

	// Convert objects and save the output PDF document.
	outFile, err := os.Create("out.pdf")
	if err != nil {
		log.Fatal(err)
	}
	defer outFile.Close()

	if err := converter.Run(outFile); err != nil {
		log.Fatal(err)
	}
}

how to disable-javascript config

Hi guys,

how can i pass disable-javascript to wkhtmltopdf? Currently, the converter will hang up at 10%, and someone told disable-javascript need to set, this is link, so i want try.

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.