mdtopdf

package module
v0.0.0-...-71179b8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 11, 2022 License: MIT Imports: 6 Imported by: 0

README

mdtopdf

Converts Markdown to PDF

	md, err := os.Open("example.md")
	if err != nil{
		fmt.Println(err)
		return
	}
	defer md.Close()

	pdf, err := os.Create("example.pdf")
	if err != nil {
		fmt.Println(err)
		return
	}
	defer pdf.Close()

	pageNumExtension := func(pdf *gofpdf.Fpdf) {
        pdf.SetFooterFunc(func() {
            left, _, right, bottom := pdf.GetMargins()
            width, height := pdf.GetPageSize()
            fontSize := 12.0

            pNum := fmt.Sprint(pdf.PageNo())
            pdf.SetXY(width-left/2-pdf.GetStringWidth(pNum), height-bottom/2)
            pdf.SetFontSize(fontSize)
            pdf.SetTextColor(200, 200, 200)
            pdf.SetFontStyle("B")
            pdf.SetRightMargin(0)
            pdf.Write(fontSize, pNum)
            pdf.SetRightMargin(right)
        })
    }

	err = mdtopdf.Convert(md, pdf, pageNumExtension)
	if err != nil {
		fmt.Println(err)
		return
	}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Convert

func Convert(r io.Reader, w io.Writer, extensions ...func(*gofpdf.Fpdf)) error

Convert your Markdown to PDF

func SetStyleFromPdf

func SetStyleFromPdf(pdf *gofpdf.Fpdf) (style *document.Style)

Use styles defined in PDF extensions

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL