请问有什么方法可以把文字写入PDF里的表格?

vin3166 2019-03-12 04:00:04
如题

例如下面所示的PDF, 里面有些表格,如果需要对表格写入文字,该有什么样的方法?


...全文
276 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
vin3166 2020-04-10
  • 打赏
  • 举报
回复
才记得在这里发过帖子。 多谢楼上两位大神的解答。 么么哒
  • 打赏
  • 举报
回复
Spire.pdf,有如何操作Form部分内容,不过这个是要收费的,你可以找下破解版……
sinat_38011298 2019-05-10
  • 打赏
  • 举报
回复
pdf文档中本身不存在table概念,获取不出table对象,只能指定位置绘制内容,PDF中添加内容需要指定具体的坐标,如果要在上面加文本可以尝试下面变得编码
Imports Spire.Pdf
Imports Spire.Pdf.Graphics
Public Class Form1

Private Sub btn_Run_Click(sender As Object, e As EventArgs) Handles btn_Run.Click
'Create a pdf document
Dim doc As New PdfDocument()

'从系统中加载文件
doc.LoadFromFile("C:\Program Files\e-iceblue\Spire.Pdf-Fe\Demos\Data\DrawContentWithSpotColor.pdf")
'获取PDF文档的第一页
Dim page As PdfPageBase = doc.Pages(0)

AlignText(page)


'保存PDF文档
doc.SaveToFile("TextDraw.pdf")
doc.Close()

'启动PDF文档
PDFDocumentViewer("TextDraw.pdf")

End Sub

Private Sub AlignText(ByVal page As PdfPageBase)
'绘制文本-对齐
Dim font As New PdfFont(PdfFontFamily.Helvetica, 20.0F)
Dim brush As New PdfSolidBrush(Color.Blue)

Dim leftAlignment As New PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Middle)
'设置绘制文本的位置
page.Canvas.DrawString("Left!", font, brush, 0, 200, leftAlignment)
page.Canvas.DrawString("Left!", font, brush, 0, 250, leftAlignment)

Dim rightAlignment As New PdfStringFormat(PdfTextAlignment.Right, PdfVerticalAlignment.Middle)
page.Canvas.DrawString("Right!", font, brush, page.Canvas.ClientSize.Width, 200, rightAlignment)
page.Canvas.DrawString("Right!", font, brush, page.Canvas.ClientSize.Width, 250, rightAlignment)

Dim centerAlignment As New PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle)
page.Canvas.DrawString("Go! Turn Around! Go! Go! Go!", font, brush, CLng(page.Canvas.ClientSize.Width) \ 2, 240, centerAlignment)

End Sub
Private Sub PDFDocumentViewer(ByVal fileName As String)
Try
Process.Start(fileName)
Catch
End Try
End Sub

End Class

游北亮 2019-03-12
  • 打赏
  • 举报
回复
你用百度搜索 C# pdf

16,549

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧