3
私はWindowsフォームでiTextSharpを使用してC#でpdfファイルを作成します。リソースフォルダ(イメージ名:LOGO.png)からファイルにイメージを追加します。私はExportToPdf.csクラスを持っていて、このクラスはApp_Classフォルダにあります。私は以下のコードを使用しています。誰でも助けてください。それは他のバイナリファイルでないようiTextSharp pdfイメージからリソースファイル
internal static void exportEchoReport(Patient p)
{
using (var ms = new MemoryStream())
{
using (var doc1 = new iTextSharp.text.Document(PageSize.A4, 50, 50, 15, 15))
{
try
{
PdfWriter writer = PdfWriter.GetInstance(doc1, new FileStream("echo.pdf", FileMode.Create));
doc1.Open();
string imagePath = // I want to use this image LOGO.png (Resources.LOGO)
iTextSharp.text.Image logoImg = iTextSharp.text.Image.GetInstance(imagePath);
PdfPTable headerTable = createTable(logoImg, p);
doc1.Add(headerTable);
}
catch (Exception ex)
{
}
finally
{
doc1.Close();
}
}
System.Diagnostics.Process.Start("echo.pdf");
}
}