mirror of
https://github.com/gotenberg/gotenberg.git
synced 2026-08-18 13:12:17 +01:00
fixing/simplifying godoc
This commit is contained in:
@@ -94,7 +94,7 @@ func print(c echo.Context, p printer.Printer, r *resource) error {
|
|||||||
if r.webhookURL() == "" {
|
if r.webhookURL() == "" {
|
||||||
// if no webhook URL given, run conversion
|
// if no webhook URL given, run conversion
|
||||||
// and directly return the resulting PDF file
|
// and directly return the resulting PDF file
|
||||||
// or and error.
|
// or an error.
|
||||||
if err := p.Print(fpath); err != nil {
|
if err := p.Print(fpath); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ func merge(c echo.Context) error {
|
|||||||
if r.webhookURL() == "" {
|
if r.webhookURL() == "" {
|
||||||
// if no webhook URL given, run merge
|
// if no webhook URL given, run merge
|
||||||
// and directly return the resulting PDF file
|
// and directly return the resulting PDF file
|
||||||
// or and error.
|
// or an error.
|
||||||
if err := printer.Merge(fpaths, fpath); err != nil {
|
if err := printer.Merge(fpaths, fpath); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,52 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
Package printer contains structs which convert
|
Package printer contains structs which convert
|
||||||
a specific file type to PDF:
|
a specific file type to PDF.
|
||||||
|
|
||||||
// converting HTML to PDF.
|
It is also able to merge a list of PDF files.
|
||||||
p := &printer.HTML{
|
|
||||||
Context: context.Background(),
|
|
||||||
PaperWidth: 8.27,
|
|
||||||
PaperHeight: 11.7,
|
|
||||||
Landscape: false,
|
|
||||||
}
|
|
||||||
p.WithLocalURL("index.html")
|
|
||||||
if err := p.Print("result.pdf"); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// converting Markdown to PDF:
|
|
||||||
// it assumes here that our template "index.html"
|
|
||||||
// will call toHTML method to convert
|
|
||||||
// markdown files to HTML.
|
|
||||||
p := &printer.Markdown{
|
|
||||||
Context: context.Background(),
|
|
||||||
TemplatePath: "index.html",
|
|
||||||
PaperWidth: 8.27,
|
|
||||||
PaperHeight: 11.7,
|
|
||||||
Landscape: false,
|
|
||||||
}
|
|
||||||
if err := p.Print("result.pdf"); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// converting Office documents to PDF:
|
|
||||||
// it converts each files independently and
|
|
||||||
// then merge them.
|
|
||||||
//
|
|
||||||
// Also, as unoconv cannot perform
|
|
||||||
// concurrent conversions, a lock is applied.
|
|
||||||
p := &printer.Office{
|
|
||||||
Context: ctx,
|
|
||||||
FilePaths: []string{"document.docx", "presentation.pptx"}
|
|
||||||
}
|
|
||||||
if err := p.Print("result.pdf"); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
It is also able to merge a list of PDF files:
|
|
||||||
|
|
||||||
if err := printer.Merge([]string{"foo.pdf", "bar.pdf"}, "result.pdf"); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
*/
|
*/
|
||||||
package printer
|
package printer
|
||||||
|
|||||||
Reference in New Issue
Block a user