【发布时间】:2016-02-28 13:22:58
【问题描述】:
我想在图片上方添加一些文字。我的代码是这样的:
Dim pdfcb As PdfContentByte = Writer.DirectContent
Dim code128 As New Barcode128()
code128.Code = partnumber
code128.Extended = False
code128.CodeType = iTextSharp.text.pdf.Barcode.CODE128
code128.AltText = ""
code128.BarHeight = 13
code128.Size = 6
code128.Baseline = 8
code128.TextAlignment = Element.ALIGN_CENTER
Dim image128 As iTextSharp.text.Image = code128.CreateImageWithBarcode(pdfcb, Nothing, Nothing)
Dim phrase As New Phrase()
phrase.Font.Size = 10
Dim cell As New PdfPCell(phrase)
cell.FixedHeight = 68.69F
cell.HorizontalAlignment = Element.ALIGN_CENTER
cell.VerticalAlignment = Element.ALIGN_MIDDLE
cell.Border = iTextSharp.text.Rectangle.NO_BORDER
phrase.Add(New Chunk(Environment.NewLine + "Companyname"))
phrase.Add(New Chunk(Environment.NewLine + "address"))
phrase.Add(New Chunk(image128, 10, 30))
phrase.Add(New Chunk(Environment.NewLine + partnumber))
phrase.Add(New Chunk(Environment.NewLine + "111"))
tbl.AddCell(cell)
我总是在我的图片下方显示我的地址和公司名称。
我想在我的图像上方制作它
我能为此做些什么?任何帮助都是非常可观的。
【问题讨论】:
-
您使用的是哪个版本的 iTextSharp?你为什么使用
Phrase?为什么要在创建PdfPCell之后将内容添加到Phrase?这一切都非常非常奇怪……就好像你从未读过official documentation。 -
我正在使用 Itextsharp 版本 5.5.8.0。实际上,先生,我从谷歌搜索中获得了此代码,然后我尝试打印条形码,条形码正在打印。但我想在上面的条形码中添加一些文本,即s 我正在尝试做的事情..但没有工作
-
优秀的编码人员从文档中学习如何编码。其他编码人员使用 Google 搜索来查找他们可以复制/粘贴的代码。请看看我的回答,你就会明白你搜索得不够好。 2016 年 1 月 26 日回答了与您现在发布的完全相同的问题。
标签: vb.net pdf-generation itextsharp