kata:
http://sourceforge.net/projects/itextsharp/
http://hardrock.cnblogs.com/
http://www.rubypdf.com/
现在的版本是3.18版,记得在引用里导入itextsharp.下面的代码是把图象合并到一个多页pdf的例子.
proses kekosongan pribadi (string[] file, string newpdf)
{
iTextSharp.text.Document dokumen = baru iTextSharp.text.Document(iTextSharp.text.PageSize.A4, 25, 25, 25, 25);
mencoba
{
iTextSharp.text.pdf.PdfWriter.GetInstance(dokumen, FileStream baru(newpdf, FileMode.Create, FileAccess.ReadWrite));
dokumen.Buka();
iTextSharp.teks.Gambar gambar;
for (int i = 0; i < panjang file; i++)
{
gambar = iTextSharp.text.Image.GetInstance(file[i]);
if (gambar.Tinggi > iTextSharp.teks.UkuranPage.A4.Tinggi - 25)
{
gambar.ScaleToFit(iTextSharp.text.PageSize.A4.Width - 25, iTextSharp.text.PageSize.A4.Height - 25);
}
else if (gambar.Lebar > iTextSharp.teks.UkuranPage.A4.Lebar - 25)
{
gambar.ScaleToFit(iTextSharp.text.PageSize.A4.Width - 25, iTextSharp.text.PageSize.A4.Height - 25);
}
gambar.Alignment = iTextSharp.text.Image.ALIGN_MIDDLE;
//gambar.SetDpi(72, 72);
dokumen.Halaman Baru();
dokumen.Tambahkan(gambar);
//Frasa frase3 = Frasa baru(" [email protected] ", FontFactory.GetFont(FontFactory.TIMES, 9, iTextSharp.text.Font.NORMAL, iTextSharp.text.Color(192, 192, 192) baru) );
//document.Add(phrase3);
}
}
menangkap (Pengecualian IOE)
{
Kotak Pesan.Tampilkan(ioe.Pesan);
}
dokumen.Tutup();
}