Git Product home page Git Product logo

Comments (4)

tiechui1994 avatar tiechui1994 commented on August 27, 2024

可以, 参考使用example当中 ComplexReportFooterExecutor() 的写法

from gopdf.

researchlab avatar researchlab commented on August 27, 2024

用 {#TotalPage#} 脚注页面 RightAlign() 好像不是右对齐了, 右边有空出来一块,

from gopdf.

tiechui1994 avatar tiechui1994 commented on August 27, 2024

你怎样使用的RightAlign(), 有简单的案例吗?

from gopdf.

researchlab avatar researchlab commented on August 27, 2024

@tiechui1994 多谢支持, 下面是对 master分支 example 中的 complex_report_test.go 中 133行的 ComplexReportFooterExecutor 函数进行修订操作,

func ComplexReportFooterExecutor(report *core.Report) {
	content := fmt.Sprintf("第 %v / {#TotalPage#} 页", report.GetCurrentPageNo())
	footer := gopdf.NewSpan(10, 0, report)
	footer.SetFont(textFont)
	footer.SetFontColor("79,79,79")
	footer.SetBorder(core.Scope{Top: 0})
	//footer.HorizontalCentered().SetContent(content).GenerateAtomicCell()
	footer.RightAlign().SetContent(content).GenerateAtomicCell()
}

上述代码仅将最后的格式修订为向右对齐, 最后生成的pdf脚注向右对齐 是有一定的空白的, 下面是添加我自己的代码,

func ComplexReportFooterExecutor(report *core.Report) {
	content := fmt.Sprintf("第 %v / {#TotalPage#} 页", report.GetCurrentPageNo())
	footer := gopdf.NewSpan(10, 0, report)
	footer.SetFont(textFont)
	footer.SetFontColor("79,79,79")
	footer.SetBorder(core.Scope{Top: 0})
	//footer.HorizontalCentered().SetContent(content).GenerateAtomicCell()
	footer.RightAlign().SetContent(content).GenerateAtomicCell()

	footer = gopdf.NewSpan(5, 0, report)
	footer.SetFont(textFont)
	footer.SetBorder(core.Scope{Top: -10})
	footer.SetFontColor("79,79,79")
	footer.RightAlign().SetContent(fmt.Sprintf("The inspection report is generated at %v", time.Now().Format(DateFormat))).GenerateAtomicCell()
}

上面这个代码可以看出来 脚注的两行明显不向右对齐, 下面是我想要的效果,

func ComplexReportFooterExecutor(report *core.Report) {
	//content := fmt.Sprintf("第 %v / {#TotalPage#} 页", report.GetCurrentPageNo())
	content := fmt.Sprintf("第 %v / %v 页", report.GetCurrentPageNo(), 3)
	footer := gopdf.NewSpan(10, 0, report)
	footer.SetFont(textFont)
	footer.SetFontColor("79,79,79")
	footer.SetBorder(core.Scope{Top: 0})
	//footer.HorizontalCentered().SetContent(content).GenerateAtomicCell()
	footer.RightAlign().SetContent(content).GenerateAtomicCell()

	footer = gopdf.NewSpan(5, 0, report)
	footer.SetFont(textFont)
	footer.SetBorder(core.Scope{Bottom: 10})
	footer.SetFontColor("79,79,79")
	footer.RightAlign().SetContent(fmt.Sprintf("The inspection report is generated at %v", time.Now().Format(DateFormat))).GenerateAtomicCell()
}

上面这个代码 没有使用 {#TotalPage#}占位符, 所以 最后这一行记录的坐标是不一样的,这样就能使得两行脚注很对齐了

我看了一下你的代码, 没太看明白 不知道咋修改, 帮忙看一下, 谢谢呢,

from gopdf.

Related Issues (20)

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.