求一个可以用的itextsharp.dll 在网上下了2个dll,5.0的dll出现这个问题。而4.0的dll的接口本身就很少,当然,document不能实例化的问题仍然存在。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 http://download.csdn.net/detail/happy09li/6468669这个一个绝对是可以用的,自己用的就是这个 去itextsharp下个最新的呗。http://sourceforge.net/projects/itextsharp/files/latest/download 大哥,送佛送到西,我是直接加项目到我的里面?还是3个dll加进去?或者是一个dll? 楼主 为什么 要new 那个类 呢?我感觉 是没 弄 明白 这个 dll 内部的东西你想实现什么功能 我 用过这个 dll 或许可以帮你 我要将datagridview图表的内容导出为pdf文档。pdf内容添加不是就有doc.add和table.add都需要用个类。 如果 你要 导出 图片 简单 如果导出 数据 会 复杂一点需要 向 pdf 写数据 /// <summary> /// 单张图片生成PDF /// </summary> /// <param name="pathName">PDF生成位置</param> /// <param name="path">单证图片路径</param> public static void ExportDataIntoPDF(string pathName, string path) { iTextSharp.text.Document document = new iTextSharp.text.Document(iTextSharp.text.PageSize.A4, 25, 25, 25, 25); try { PdfWriter writer = iTextSharp.text.pdf.PdfWriter.GetInstance(document, new FileStream(pathName, FileMode.Create)); document.Open(); iTextSharp.text.Image image = iTextSharp.text.Image.GetInstance(path); //调整图片大小,使之适合A4 if (image.Height > iTextSharp.text.PageSize.A4.Height - 25) { image.ScaleToFit(iTextSharp.text.PageSize.A4.Width - 25, iTextSharp.text.PageSize.A4.Height - 25); } else if (image.Width > iTextSharp.text.PageSize.A4.Width - 25) { image.ScaleToFit(iTextSharp.text.PageSize.A4.Width - 25, iTextSharp.text.PageSize.A4.Height - 25); } //调整图片位置,使之居中 image.Alignment = iTextSharp.text.Image.ALIGN_MIDDLE; document.NewPage(); document.Add(image); } catch (Exception e) { MessageBoxHepler.ShowErrorMsgBox(e.ToString()); } document.Close(); } 而且你这个也创建了document实例了。 导出数据 需要 你 自己 写 这个 比较麻烦 我记得 网上 有 想 pdf 写内容 的 代码 恩,我只是觉得奇怪你说不需要创建document的实例是怎么回事。 恩,导出数据。不是导出图片导出表格很麻烦,要自己画表格的,不如导成excel吧。 恩,导出数据。不是导出图片导出表格很麻烦,要自己画表格的,不如导成excel吧。我已经导成excel了,但是需要也能同时导成PDF。。 可以调用用office 2007自带的导出pdf功能。导出pdf还是自己画表格把,深入研究itext就可以了,java的代码很好懂,就当是c#看就行了,itextsharp资料比较少。 .net SerialPort Close()导致程序被挂起! 存储过程 急!大家给点思路 无焦点模式窗体获得键盘输入 求教textbox控件限制输入格式问题````在线等``` 大家帮我看看这个方法有什么错误 谢谢 怎样获取文本框中的多个数值 关于制作检查listbox里内容是否有更新的监视器,各位前辈进来看看 winform安装时,如何获取旧版本安装路径? 基于Internet网分布式数据库系统的问题。急急急急 C#如何动态提升管理员权限 如果在自己定义的类中写一个类似invoke()的跨线程回调方法
http://sourceforge.net/projects/itextsharp/files/latest/download
我感觉 是没 弄 明白 这个 dll 内部的东西
你想实现什么功能 我 用过这个 dll 或许可以帮你
/// <summary>
/// 单张图片生成PDF
/// </summary>
/// <param name="pathName">PDF生成位置</param>
/// <param name="path">单证图片路径</param>
public static void ExportDataIntoPDF(string pathName, string path)
{
iTextSharp.text.Document document = new iTextSharp.text.Document(iTextSharp.text.PageSize.A4, 25, 25, 25, 25);
try
{
PdfWriter writer = iTextSharp.text.pdf.PdfWriter.GetInstance(document, new FileStream(pathName, FileMode.Create));
document.Open(); iTextSharp.text.Image image = iTextSharp.text.Image.GetInstance(path);
//调整图片大小,使之适合A4
if (image.Height > iTextSharp.text.PageSize.A4.Height - 25)
{
image.ScaleToFit(iTextSharp.text.PageSize.A4.Width - 25, iTextSharp.text.PageSize.A4.Height - 25);
}
else if (image.Width > iTextSharp.text.PageSize.A4.Width - 25)
{
image.ScaleToFit(iTextSharp.text.PageSize.A4.Width - 25, iTextSharp.text.PageSize.A4.Height - 25);
}
//调整图片位置,使之居中
image.Alignment = iTextSharp.text.Image.ALIGN_MIDDLE;
document.NewPage();
document.Add(image);
}
catch (Exception e)
{
MessageBoxHepler.ShowErrorMsgBox(e.ToString());
}
document.Close();
}