Giter VIP home page Giter VIP logo

gopdf's People

Contributors

tiechui1994 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

gopdf's Issues

是否可以支持写入io.Writer里?

你好,是否可以支持写入io.Writer里?这样的话,可以直接写入浏览器的缓存了,就越过写pdf文件而直接在浏览器打开。
谢谢

表格内容自动换行bug

image

单某个单元格内容过多时,会撑破表格布局。 当吧-工作单位 单元格里的内容清掉,表格就正常了

建议出个模板解析器

用模板描述生成操作,然后解析执行,这样会方便很多,现在所有PDF生成器都没这功能,你弄一个,简单的生成语句就行,肯定很受欢迎

请求帮助 invalid memory address or nil pointer dereference

如何复现:如下所示,把示例文件 simple_table_test.go 的一部分注释掉了。
期望的结果:只生成0-0,0-1,0-3,1-0四个单元格。

package example

import (
	"fmt"
	"github.com/tiechui1994/gopdf"
	"github.com/tiechui1994/gopdf/core"
	"testing"
)

const (
	TABLE_IG = "IPAexG"
	TABLE_MD = "MPBOLD"
	TABLE_MY = "微软雅黑"
)

func SimpleTable() {
	r := core.CreateReport()
	font3 := core.FontMap{
		FontName: TABLE_MY,
		FileName: "D:/microsoft.ttf",
	}
	r.SetFonts([]*core.FontMap{&font3})
	r.SetPage("A4", "P")

	r.RegisterExecutor(core.Executor(SimpleTableExecutor), core.Detail)

	r.Execute("D:/simple_table.pdf")
	fmt.Println(r.GetCurrentPageNo())
}
func SimpleTableExecutor(report *core.Report) {
	lineSpace := 1.0
	lineHeight := 18.0

	table := gopdf.NewTable(5, 100, 415, lineHeight, report)
	table.SetMargin(core.Scope{})

	// 先把当前的行设置完毕, 然后才能添加单元格内容.
	c00 := table.NewCellByRange(1, 1)
	c01 := table.NewCellByRange(2, 1)
	c03 := table.NewCellByRange(2, 2)
	c10 := table.NewCellByRange(3, 1)

	f1 := core.Font{Family: TABLE_MY, Size: 15, Style: ""}
	border := core.NewScope(4.0, 4.0, 4.0, 3.0)
	c00.SetElement(gopdf.NewTextCell(table.GetColWidth(0, 0), lineHeight, lineSpace, report).SetFont(f1).SetBorder(border).HorizontalCentered().SetContent("0-0"))
	c01.SetElement(gopdf.NewTextCell(table.GetColWidth(0, 1), lineHeight, lineSpace, report).SetFont(f1).SetBorder(border).RightAlign().SetContent("0-1"))
	c03.SetElement(gopdf.NewTextCell(table.GetColWidth(0, 3), lineHeight, lineSpace, report).SetFont(f1).SetBorder(border).RightAlign().SetContent("0-3近日,江苏苏州市姑苏区市场监督管理局向苏州定园旅游服务有限公司送达行政处罚决定书,对定园进行处罚,吊销其营业执照,此举开创了我国旅游景点因虚假宣传被吊销营业执照的先河"))
	c10.SetElement(gopdf.NewTextCell(table.GetColWidth(1, 0), lineHeight, lineSpace, report).SetFont(f1).SetBorder(border).VerticalCentered().SetContent("1-0近日,江苏苏州市姑苏区市场监督管理局向苏州定园旅游服务有限公司送达行政处罚决定书了我国旅游景点因虚假宣传被吊销营业执照的先河"))

	//f1 = core.Font{Family: TABLE_MY, Size: 10}
	//border = core.NewScope(4.0, 4.0, 0, 0)
	//
	//for i := 0; i < 98; i++ {
	//	cells := make([]*gopdf.TableCell, 5)
	//	for j := 0; j < 5; j++ {
	//		cells[j] = table.NewCell()
	//	}
	//
	//	for j := 0; j < 5; j++ {
	//		str := `有限公司送达行政处罚决定书`
	//		s := fmt.Sprintf("%v-%v", i+2, str)
	//		w := table.GetColWidth(i+2, j)
	//		e := gopdf.NewTextCell(w, lineHeight, lineSpace, report)
	//		e.SetFont(f1)
	//		if i%2 == 0 {
	//			e.SetBackColor("255,192,203")
	//		}
	//		e.SetBorder(border)
	//		e.SetContent(s)
	//		cells[j].SetElement(e)
	//	}
	//}

	table.GenerateAtomicCell()
}

func TestSimpleTable(t *testing.T) {
	SimpleTable()
}

markdown file contains table, fails to resolve them.

四个单词 四个单词 四个单词 四个单词 四个单词 四个单词 四个单词 四个单词 四个单词 四个单词
2020-01-10 10:10:10 2020-01-10 10:10:10 2020-01-10 10:10:10 2020-01-10 10:10:10 2020-01-10 10:10:10 2020-01-10 10:10:10 2020-01-10 10:10:10 2020-01-10 10:10:10 2020-01-10 10:10:10 2020-01-10 10:10:10
2020-01-10 10:10:10 2020-01-10 10:10:10 2020-01-10 10:10:10 2020-01-10 10:10:10 2020-01-10 10:10:10 2020-01-10 10:10:10 2020-01-10 10:10:10 2020-01-10 10:10:10 2020-01-10 10:10:10 2020-01-10 10:10:10

结果如下
18:09:17 markdown.go:1017: children 0

可以指定新起一页写入内容吗?

现在页面是自动分页的, 里面只有 detail, header, footer 分类,
想请问一下, 比如写入内容已占满了半页纸张, 后继的内容想从下一页(新的页面)开始写入, 如何指定? 可以指定吗?

not found glyph

处理的文本有异常数据(因为编码等原因导致乱码产生),导致直接panic了,需要怎么处理?前提:异常数据肯定是会存在的。
微信图片_20230509113935

跨页空页问题

在测试使用过程中,发现当报告生成页数超过15页后, 在第15页会存在大版空页,是的前后内容中间空出来一大片, 这个是什么原因?

目前的解决方法是将第15页的内容 强制设置一个比较大的div top值, 使得15页直接全部留空, 不知道是不是因为使用的格式问题还是页面超过15页导致的这个问题

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.