首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ITextSharp边缘

ITextSharp边缘
EN

Stack Overflow用户
提问于 2015-01-30 22:40:17
回答 1查看 1.8K关注 0票数 0

我正在使用itexsharp,我有问题,因为它没有分配文档的页边距,这是代码。

代码语言:javascript
复制
Dim pdfw As PdfWriter
    Dim documentoPDF As New Document(iTextSharp.text.PageSize.A4.Rotate(), 20, 20, 20, 20) 'Creamos el objeto documento PDF
    documentoPDF.SetMargins(0.0F, 0.0F, 10.0F, 10.0F)

    pdfw = PdfWriter.GetInstance(documentoPDF, New FileStream(urlFija & "\" & "Manifiesto-" & Manifiesto & ".pdf", FileMode.Create))
    documentoPDF.Open()


    documentoPDF.NewPage()
    Dim aTable = New iTextSharp.text.pdf.PdfPTable(3)
    Dim Ancho0 As Single() = {0.75F, 1.45F, 0.75F}
    'aTable.DefaultCell.Border = BorderStyle.None

    Dim Imagen As iTextSharp.text.Image
    Imagen = iTextSharp.text.Image.GetInstance(path & "Ministerio-3.jpg")
    Imagen.ScalePercent(25)
    Imagen.SetAbsolutePosition(25.0F, 25.0F)

    Dim Img = New PdfPCell
    Img.Border = Rectangle.NO_BORDER
    Img.AddElement(Imagen)

    aTable.AddCell(Img)

    Dim C1 = New PdfPCell(New Paragraph("Formato", FontFactory.GetFont(FontFactory.TIMES, 13, iTextSharp.text.Font.BOLD)))
    C1.HorizontalAlignment = 1
    C1.VerticalAlignment = 2
    C1.Border = Rectangle.NO_BORDER

    aTable.AddCell(C1)

    Dim C2 = New PdfPCell(New Paragraph("Prueba", FontFactory.GetFont(FontFactory.TIMES, 7, iTextSharp.text.Font.NORMAL)))
    C2.HorizontalAlignment = 3
    C2.Border = Rectangle.NO_BORDER
    aTable.AddCell(C2)
    aTable.SetWidths(Ancho0)
documentoPDF.Add(aTable)
documentoPDF.AddAuthor(Session("IDUsuario").ToString)
    documentoPDF.AddTitle("Manifiesto")
    documentoPDF.AddCreationDate()
    documentoPDF.Close() 

在此之后,我添加了一个包含信息的表,将我移动到最上面的边距。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-02-02 13:20:11

如文档所示,在将PdfPTable添加到页面时,默认情况下,它的宽度仅占可用宽度的80% (除非定义了绝对宽度而不是相对宽度)。它将居中,所以你将有一个左和右边距10%的可用宽度。

如果希望表跨100%,则需要添加以下行:

代码语言:javascript
复制
aTable.WidthPercentage = 100;

现在这张桌子将横跨整个宽度。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/28245824

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档