0

itextsharpを使用して、何百もの画像(実際のサイズは縮小/圧縮なし)をPDFに追加するにはどうすればよいですか。これらを特定の表形式で追加し、PDFページあたりの画像数を修正したいと思います。すべての画像は同じサイズです。どうすればいいですか?

4

1 に答える 1

3

このコードを試して、PDFに画像を追加できます

Document doc = new Document(PageSize.A4, 10, 10, 30, 30);
MemoryStream PDFData = new MemoryStream();
PdfWriter writer = PdfWriter.GetInstance(doc, PDFData);
doc.Open();

PdfPTable table = new PdfPTable(1);
table.WidthPercentage = 100F;

Image imgLogo = Image.GetInstance(<image_path>);
PdfPCell cell1 = new PdfPCell { BorderWidth = 0F,  Padding = 3 };
cell1.AddElement(imgLogo);
table.AddCell(cell1);

//Add your more images.

doc.Add(table );
doc.Close();

writer.Close();
于 2012-10-24T06:43:56.833 に答える