0
我怎樣才能在文檔中平行設置兩個表 如何在itextsharp文檔中並行設置兩個表格?
用於生成PDF是我的示例代碼,
Document doc = new Document(new Rectangle(288f, 144f), 10, 10, 10, 10);
doc.SetPageSize(iTextSharp.text.PageSize.A4.Rotate());
PdfWriter writer = PdfWriter.GetInstance(doc, Response.OutputStream);
doc.Open();
PdfPTable table = new PdfPTable(3);
table.TotalWidth = 144f;
table.LockedWidth = true;
PdfPCell cell = new PdfPCell(new Phrase("This is table 1"));
cell.Colspan = 3;
cell.HorizontalAlignment = 1;
table.AddCell(cell);
table.AddCell("Col 1 Row 1");
table.AddCell("Col 2 Row 1");
table.AddCell("Col 3 Row 1");
table.AddCell("Col 1 Row 2");
table.AddCell("Col 2 Row 2");
table.AddCell("Col 3 Row 2");
table.WriteSelectedRows(0, -1, doc.Left, doc.Top, writer.DirectContent);
table = new PdfPTable(3);
table.TotalWidth = 144f;
table.LockedWidth = true;
cell = new PdfPCell(new Phrase("This is table 2"));
cell.Colspan = 3;
cell.HorizontalAlignment = 1;
table.AddCell(cell);
table.AddCell("Col 1 Row 1");
table.AddCell("Col 2 Row 1");
table.AddCell("Col 3 Row 1");
table.AddCell("Col 1 Row 2");
table.AddCell("Col 2 Row 2");
table.AddCell("Col 3 Row 2");
table.WriteSelectedRows(0, -1, doc.Left + 200, doc.Top, writer.DirectContent);
doc.Close();
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment;" + "filename=Sample .pdf");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Write(doc);
Response.End();
當運行這段代碼,PDF格式下載,但表示無法載入PDF文件的錯誤消息」 「。請幫我解決錯誤並獲得預期的輸出