私はiTextSharpの初心者です。このコードを記述して、RoundRectangleをPdfPTableに作成し、ページの中央にテーブルを配置します。
string pdfpath = Server.MapPath("PDFs");
RoundRectangle rr = new RoundRectangle();
using (Document document = new Document())
{
PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(pdfpath + "/Graphics6.pdf", FileMode.CreateNew));
document.Open();
PdfPTable table = new PdfPTable(1);
float[] f=new float[]{0.5f};
table.SetWidths(f);
PdfPCell cell = new PdfPCell()
{
CellEvent = rr,
Border = PdfPCell.NO_BORDER,
Phrase = new Phrase("test")
};
table.AddCell(cell);
document.Add(table);
テーブル幅を変更したいコードを変更した
string pdfpath = Server.MapPath("PDFs");
RoundRectangle rr = new RoundRectangle();
using (Document document = new Document())
{
PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(pdfpath + "/Graphics6.pdf", FileMode.CreateNew));
document.Open();
PdfPTable table = new PdfPTable(1);
table.TotalWidth = 5;
int[] w = new int[] { 12};
table.SetWidths(w);
PdfPCell cell = new PdfPCell()
{
CellEvent = rr,
Border = PdfPCell.NO_BORDER,
Phrase = new Phrase("test")
};
table.AddCell(cell);
document.Add(table);
しかし、ページに作業も変更幅の表もありません。私を助けてください。皆さんありがとう