GithubHelp home page GithubHelp logo

sardsay / maroto Goto Github PK

View Code? Open in Web Editor NEW

This project forked from vale-sail/maroto

0.0 1.0 0.0 4.96 MB

A maroto way to create PDFs. Maroto is inspired in Bootstrap and uses gofpdf. Fast and simple.

Home Page: https://pkg.go.dev/github.com/johnfercher/maroto?tab=doc

License: MIT License

Go 99.81% Shell 0.19%

maroto's Introduction

Base on johnfercher/maroto

Add function Base on gofpdf

  1. AddUTF8Font to support chinese
  2. Add SetProtection to support protection pdf

使用更加优雅的方式去书写PDF。不再为每个点定位而苦恼

站在巨人的肩膀

AddUTF8Font 方法,支持自己设定字体:比如使用 NotoSansSC-Regular.ttf 就可以支持中文的展示。

SetProtection 方法,支持PDF设置密码。

maroto的布局是一行12个格子,然后向每个格子每个格子的添加数据。

Example

	m := pdf.NewMaroto(consts.Portrait, consts.A4)
	m.AddUTF8Font("NotoSansSC", "", "./NotoSansSC-Regular.ttf")
	m.AddUTF8Font("NotoSansSC", "I", "./NotoSansSC-Regular.ttf")
	m.AddUTF8Font("NotoSansSC", "B", "./NotoSansSC-Regular.ttf")
	m.AddUTF8Font("NotoSansSC", "BI", "./NotoSansSC-Regular.ttf")
	m.SetPageMargins(10, 35, 10)
	textProps := props.Text{
		Top:    0.5,
		Family: "NotoSansSC",
		Style:  consts.Bold,
		Align:  consts.Left,
	}
	m.Row(5, func() {
		m.ColSpace(5)
		m.Col(2, func() {
			m.Text("世界你好",textProps)
		})
		m.ColSpace(5)
	})
	m.SetProtection(gofpdf.CnProtectPrint, "123", "abc")
	err := m.OutputFileAndClose("世界你好.pdf")
	if err != nil {
		fmt.Println("Could not save PDF:", err)
		os.Exit(1)
	}

maroto's People

Contributors

apissurno avatar aquarat avatar balajitechs avatar happsie avatar johnfercher avatar johnferchermeli avatar kazuhirodk avatar manoelstilpen avatar pensu avatar soulspark666 avatar stanleynguyen avatar suddengunter avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.