gpt4 book ai didi

c# - itextsharp pdf页面边框?

转载 作者:行者123 更新时间:2023-11-30 15:01:38 25 4
gpt4 key购买 nike

我正在使用 itext sharp 创建 PDF 格式的报告。
我想要页面边框。我尝试了一些方法。我没有成功。
如何使用 iText for .NET 获得顶部、底部、左侧、右侧的页面边框?
我添加了一张图片 1 .我想要图片中描述的边框。

最佳答案

您可以尝试使用此代码手动添加页眉图像。

//第一步:添加图片文件

strImgPath is refer the directory Info..

Image imgLogo = Image.GetInstance(strImgPath.ToString()+"\\abcdur compe.Jpg");
imgLogo.Alignment = Image.ALIGN_CENTER;
imgLogo.ScalePercent(50f);

//第二步:

Add this ImgLogo to the PdfPTable by use of this
PdfPCell pdfcellImage = new PdfPCell(imgLogo, true);
pdfcellImage.FixedHeight = 40f;
pdfcellImage.HorizontalAlignment = Element.ALIGN_CENTER;
pdfcellImage.VerticalAlignment = Element.ALIGN_CENTER;
pdfcellImage.Border = Rectangle.NO_BORDER;
pdfcellImage.Border = Rectangle.NO_BORDER;
pdftblImage.AddCell(pdfcellImage);

//第三步:

Create Chunck to add Text for address or others
fntBoldComHd is a Base Font Library Object

Chunk chnCompany = new Chunk("Your CompanyName\nAddress", fntBoldComHd);

//Step 4:

Create Phrase For add the Chunks and PdfPTables

Phrase phHeader = new Phrase();

phHeader.Add(pdftblImage);
phHeader.Add(chnCompany);

//第五步:

Assign the Phrase to PDF Header
HeaderFooter header = new HeaderFooter(phHeader, false);
header.Border = Rectangle.NO_BORDER;
header.Alignment = Element.ALIGN_CENTER;
docPDF.Header = header;

关于c# - itextsharp pdf页面边框?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13927858/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com