2016-04-26 10 views
0

私は、文書にいくつかの句を追加すると、それはうまく動作しますが、私はこの文書の中に表を追加していますが、表は追加されていません私がここで何をしているのか誰にでも教えてもらえますか?前もって感謝します。ここ はpdf.Everythingを生成するための私のコードですPDF文書にPDF表を追加する

public Document GetPDFparams(Document disclaimer) 
    { 
     StringBuilder Content = new StringBuilder(); 
     Content.Append("Testing"); 
     Paragraph NullContent = new Paragraph(Content.ToString(), FontFactory.GetFont(FontFactory.TIMES_ROMAN, font_size, Font.NORMAL)); 
     disclaimer.Add(NullContent); 
     PdfPTable tableh = new PdfPTable(6); 
     tableh.WidthPercentage = 100; 
     tableh.SetTotalWidth(new float[] { 300f, 300f, 300f, 300f,300f,300f }); 
     tableh.HorizontalAlignment = Element.ALIGN_CENTER; 

     iTextSharp.text.Image img = iTextSharp.text.Image.GetInstance(HttpContext.Current.Server.MapPath("~/Images/ORIXLOGO.png")); 
     //img.ScaleToFit(100, 40); 
     PdfPCell LogoCell = new PdfPCell(img); 
     LogoCell.HorizontalAlignment = Element.ALIGN_RIGHT; 
     LogoCell.VerticalAlignment = Element.ALIGN_BOTTOM; 
     LogoCell.Colspan = 2; 
     LogoCell.Padding = 20; 
     LogoCell.Border = 0; 
     LogoCell.Indent = 0;   

     tableh.AddCell(LogoCell); 


     Phrase LogoText = new Phrase("abc", FontFactory.GetFont(FontFactory.TIMES_BOLD, font_size)); 
     PdfPCell LogoTextCell = new PdfPCell(LogoText); 
     LogoTextCell.HorizontalAlignment = Element.ALIGN_LEFT; 
     LogoTextCell.VerticalAlignment = Element.ALIGN_LEFT; 
     LogoTextCell.Border = Rectangle.NO_BORDER; 
     LogoTextCell.PaddingTop = 15; 
     LogoTextCell.PaddingBottom = 5; 
     LogoTextCell.PaddingLeft = 5; 
     LogoTextCell.PaddingRight = 5; 
     tableh.AddCell(LogoTextCell); 

     disclaimer.Add(tableh); 
     return disclaimer; 
    } 
+0

http://www.dotnetfox.com/articles/how-to-create-table-in-pdf-document-using-Asp-Net-with-C-Sharp- and-itextsharp-1027.aspx –

+1

私はそれを済ませましたが、まだテーブルはドキュメントに追加されていません。 –

+0

http://www.codeproject.com/Articles/18040/Tutorials-on-creating-PDF-files-using-C http://developers.itextpdf.com/examples/tables –

答えて

0

最後に私がsolution.Theの問題を得たPDFテーブルを除いて結構ですthaの表では、行ごとに6列を持っていたと私はそうした後、わずか3列を追加した後にテストしていました行テーブルの6つの列すべてを追加すると追加されます:)。 ここに私のコードです:

public Document GetPDFparams(Document disclaimer) 
    { 
     StringBuilder Content = new StringBuilder(); 
     Content.Append("Testing"); 
     Paragraph NullContent = new Paragraph(Content.ToString(), FontFactory.GetFont(FontFactory.TIMES_ROMAN, font_size, Font.NORMAL)); 
     disclaimer.Add(NullContent); 
     PdfPTable tableh = new PdfPTable(6); 
     tableh.WidthPercentage = 100; 
     tableh.SetTotalWidth(new float[] { 30f, 30f, 30f, 30f,30f,30f }); 
     iTextSharp.text.Image img = iTextSharp.text.Image.GetInstance(HttpContext.Current.Server.MapPath("~/Images/ORIXLOGO.png")); 
     //img.ScaleToFit(100, 40); 
     PdfPCell LogoCell = new PdfPCell(img); 
     LogoCell.HorizontalAlignment = Element.ALIGN_RIGHT; 
     LogoCell.VerticalAlignment = Element.ALIGN_BOTTOM; 
     LogoCell.Colspan = 2; 
     LogoCell.Padding = 20; 
     LogoCell.Border = 0; 
     //LogoCell.Indent = 0;   

     tableh.AddCell(LogoCell); 


     Phrase LogoText = new Phrase("abc", FontFactory.GetFont(FontFactory.TIMES_BOLD, font_size)); 
     PdfPCell LogoTextCell = new PdfPCell(LogoText); 
     LogoTextCell.HorizontalAlignment = Element.ALIGN_LEFT; 
     LogoTextCell.VerticalAlignment = Element.ALIGN_LEFT; 
     LogoTextCell.Border = Rectangle.NO_BORDER; 
     tableh.AddCell(LogoTextCell); 
     tableh.AddCell(LogoTextCell); 
     tableh.AddCell(LogoTextCell); 
     tableh.AddCell(LogoTextCell); 

     disclaimer.Add(tableh); 
     return disclaimer; 
    } 
関連する問題