Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var input = `Молоко и творог`
- var output = "test.pdf"
- func main() {
- pf := mdtopdf.NewPdfRenderer("", "", output, "trace.log")
- // if I want to stylize a simple paragraph then isn't `pf.Normal` intended for it?
- // What does it affect then?
- pf.Normal = mdtopdf.Styler{Font: "Arial", Style: "", Size: 5, Spacing: 2,
- TextColor: mdtopdf.Color{Red: 0, Green: 0, Blue: 0}}
- err := pf.ProcessString(input)
- if err != nil {
- log.Fatalf("pdf.OutputFileAndClose() error:%v", err)
- }
- }
- // ProcessString takes the markdown content, parses it to generate the PDF
- func (r *PdfRenderer) ProcessString(content string) error {
- var f *os.File
- var err error
- if r.tracerFile != "" {
- f, err = os.Create(r.tracerFile)
- if err != nil {
- return fmt.Errorf("os.Create() on tracefile error:%v", err)
- }
- defer f.Close()
- r.w = bufio.NewWriter(f)
- defer r.w.Flush()
- }
- content = strings.Replace(content, "\r\n", "\n", -1)
- _ = bf.Run([]byte(content), bf.WithRenderer(r))
- err = r.Pdf.OutputFileAndClose(r.pdfFile)
- if err != nil {
- return fmt.Errorf("Pdf.OutputFileAndClose() error on %v:%v", r.pdfFile, err)
- }
- return nil
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement