2012-06-22 10 views
0
public void genreatePdf() 
    { 
     StringBuilder sb = new StringBuilder(); 
     sb.Append("<table>"); 
     sb.Append("<tr><td><img src='images/my.jpg'/></td></tr>"); 
     sb.Append("<tr><td>some text</td></tr>"); 
     sb.Append("</table>"); 

     string path = Server.MapPath("~/invoice/invoice.pdf"); 
     Document document = new Document(PageSize.A4); 
     PdfWriter.GetInstance(document, new FileStream(path, FileMode.Create)); 
     document.Open(); 
     document.Add(new Paragraph(strMailMsg.ToString())); 
     document.Close(); 
    } 

출력됩니다 사용하여 이미지와 테이블이 포함되어 예상되는 형식이 그 안에 이미지와 텍스트가있는 테이블과 같다. 왜 그 형식으로 PDF 파일이 만들어지지 않는지.은 iTextSharp에게</p> <pre><code><table><tr><td><img src='images/my.jpg'/></td></tr><tr><td>some text</td></tr></table> </code></pre> <p>QUS pdf 파일의

답변

0

테이블을 만들어 pdf 파일에 추가해야합니다. XHTML을 추가하지 않고 C#의 내부 테이블을 사용합니다.

Table aTable = new Table(2, 2); // 2 rows, 2 columns 
theTable.AddCell("0.0"); 
theTable.AddCell("0.1"); 
theTable.AddCell("1.0"); 
theTable.AddCell("1.1"); 

//add the table to the document 
document.Add(theTable); 

here는 itextsharp 간단한 튜토리얼입니다.