mdtopdf

package module
v0.0.0-...-01dcca9 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2024 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

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