完整**:
1.匯出資料到pdf(部分**)
downloaddata *defs.memberinfo // 資料
curx float64
cury float64
k int
page int
)func getslicebystring(str string) string
return s
}func getstringformslicestring(strslice string) string
return str
}func writepdf(filepath string, data *defs.memberinfo) error
pdf := gopdf.gopdf{}
defer pdf.close()
pdf.start(gopdf.config)
pdf.addpage()
page = page + 1 //
err := pdf.addttffont("msyh", "./pdf/ttf/microsoftyaqiheilight-2.ttf") // 新增字型檔案
if err != nil
err = pdf.setfont("msyh", "", 14) // 設定字型和大小
if err != nil
pdf.setlinewidth(0.5) // 設定線寬度
pdf.setlinetype("normal") // 設定線型別
pdf.setx(220)
pdf.sety(40)
pdf.text("斗羅大陸史萊克七怪人員名單")
pdf.line(30, 60, 565.28, 60) // 表單頂部
pdf.line(30, 60, 30, 815) // 表單左1
pdf.line(70, 60, 70, 815) // 表單左2
pdf.line(140, 60, 140, 815) // 表單左3
pdf.line(210, 60, 210, 815) // 表單左4
pdf.line(280, 60, 280, 815) // 表單左5
pdf.line(320, 60, 320, 815) // 表單左6
pdf.line(565.28, 60, 565.28, 815) // 表單右1
pdf.line(30, 815, 565.28, 815) // 表單底部
for i := 0; i <= 12; i++
// 表單頭部
pdf.setx(36)
pdf.sety(70)
pdf.cell(nil, "序號")
pdf.setx(90)
pdf.sety(70)
pdf.cell(nil, "封號")
pdf.setx(160)
pdf.sety(70)
pdf.cell(nil, "外號")
pdf.setx(230)
pdf.sety(70)
pdf.cell(nil, "姓名")
pdf.setx(285)
pdf.sety(70)
pdf.cell(nil, "性別")
// pdf.setx(420)
pdf.sety(70)
pdf.cell(nil, "簽名")
// 主體
生成pdf檔案
public void createpdf throws exception tablet.settotalwidth f this.addcell tablet,姓名 yy 1,0,20,fontcn.getnormalfont element.align left,0,0,0,0 this.ad...
java生成pdf檔案
先附上我寫的 再慢慢解析內容 doc.open 開啟文件 pdfptable pdfpcell 單元格 paragraph 段落 doc.newpage 新開一頁 paragraph.setalignment 1 設定居中 document doc new document doc.setmargi...
java 生成PDF檔案
工具 adobe acrobat 1 選擇準備表單 2 設定表單 解決中文字元問題 com.itextpdf groupid itext asian artifactid 5.2.0 version dependency 定義乙個與模板表單中名稱對應的bean class contentbean p...