1
This commit is contained in:
parent
6a06a21c2a
commit
200e821c85
|
@ -6,7 +6,7 @@ import (
|
|||
)
|
||||
|
||||
// html转 Pdf dataType = 1 为网页url dataType = 2为网页内容 outFile为空则不保存
|
||||
func HtmlToPdf(content string, dataType int, outFile string) ([]byte, error) {
|
||||
func HtmlToPdf(content string, dataType int, outFile ...string) ([]byte, error) {
|
||||
pdfg, err := wkhtmltopdf.NewPDFGenerator()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -26,8 +26,8 @@ func HtmlToPdf(content string, dataType int, outFile string) ([]byte, error) {
|
|||
return nil, err
|
||||
}
|
||||
// Write PDF to file
|
||||
if outFile != "" {
|
||||
if err = pdfg.WriteFile(outFile); err != nil {
|
||||
if len(outFile) != 0 {
|
||||
if err = pdfg.WriteFile(outFile[0]); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user