我在使用iTextSharp重叠表时遇到问题.
我有多个表(来自gridviews),我想用iTextSharp写入pdf.
我希望每个表之间只有10px的间隙(垂直方向),并且表的高度总是不同.
有没有人有一篇我可以阅读的文章来帮助我解决这个问题?还是有什么建议?绝对定位对我不起作用.
我们有一个ASP.NET应用程序,用户可以使用它来生成某些报告.到目前为止,我们有一个PDF模板,上面有一个图像,我们只需用我们编程生成的图像(图形)替换该图像.
我们使用了本网站的代码:http://blog.rubypdf.com/2007/12/12/how-to-replace-images-in-a-pdf/
现在的问题是我们在一个PDF页面上有两个不同的图像,上面链接的代码在一个页面上选择两个图像,并用我们生成的图像一次性替换它们.
有没有人知道如何用itext替换一个页面上的多个不同的图像?
谢谢
我有一个动态的PDF表单,该表单已填充并展平。此PDF可以工作,并且可以在任何版本的IE上正确显示。使用Firefox时,出现以下错误:
损坏的内容错误
由于检测到数据传输错误,因此无法显示您要查看的页面。
由于检测到数据传输错误,因此无法显示您要查看的页面。请与网站所有者联系,以告知他们该问题。
任何人都可以在不破坏我的功能性IE PDF代码的情况下帮助我解决为什么出现此错误以及需要解决的问题。
我在网上查看了一些示例,并提出了使用iTextSharp合并pdfs的代码.但我收到一个错误:.
{"该文档没有页面."}
它在Page = writer.GetImportedPage(reader,X)失败;
这是堆栈跟踪:
at iTextSharp.text.pdf.PdfPages.WritePageTree()
at iTextSharp.text.pdf.PdfWriter.Close()
at iTextSharp.text.pdf.PdfCopy.Close()
at iTextSharp.text.Document.Close()
Run Code Online (Sandbox Code Playgroud)
我调试它时有3页.这有什么不对?
这是我的代码
public static MemoryStream MergePdfs(List<MemoryStream> pdfStreams)
{
//Create output stream
MemoryStream OutStream = new MemoryStream();
Document Document = null;
try
{
//Create Main reader
PdfReader Reader = new PdfReader(pdfStreams.ElementAt(0));
//Create Main Doc
Document = new Document(Reader.GetPageSizeWithRotation(1));
//Create main writer
PdfCopy Writer = new PdfCopy(Document, OutStream);
//Open document for writing
Document.Open();
//Add pages
AddPages(Reader.NumberOfPages, Reader, ref Writer);
//For each additional pdf after first …Run Code Online (Sandbox Code Playgroud) 我需要为图像设置不透明度,并使用iTextSharp将其添加到PDF中.我查看了http://itextpdf.com/examples/但找不到任何这样做的工作示例.
任何人都可以帮助我或指导我找到合适的资源.
是否可以在C#中的单元格(行)元素之间添加空格?我正在visual studio 2012中创建一个pdf,并希望在行之间设置一些空间.我有这样的事情:
PdfPTable cellTable = new PdfPTable(1);
PdfPCell cell= new PdfPCell();
for(i=0; i < 5; i++)
{
var titleChunk = new Chunk(tittle[i], body);
var descriptionChunk = new Chunk(" " description[i], body2);
var phrase = new Phrase(titleChunk);
phrase.Add(descriptionChunk);
cell.AddElement(phrase);
}
cellTable.AddCell(cell);
Run Code Online (Sandbox Code Playgroud) 我假设我需要展平XFA表单,以便在使用Nuance的CSDK的应用程序的UI上正确显示.当我现在处理它时,我收到一条通用消息"请等待......如果此消息最终没有被替换......".
寻找一些示例iTextSharp代码来做到这一点.
看到这个链接将html转换为pdf我在webconfig中得到了这个版本错误让一些天才找到并解决了qustion.
我的模特
public class Customer
{
public int CustomerID { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
我的控制器这是正常的代码
public ActionResult Index()
{
List<Customer> customers = new List<Customer>();
for (int i = 1; i <= 10; i++)
{
Customer customer = new Customer
{
CustomerID = i,
FirstName = string.Format("FirstName{0}", i.ToString()),
LastName = string.Format("LastName{0}", i.ToString())
};
customers.Add(customer);
}
return View(customers);
}
Run Code Online (Sandbox Code Playgroud)
这是为pdf转换控制器
public ActionResult PDF()
{
List<Customer> customers = …Run Code Online (Sandbox Code Playgroud) 我有一个包含数千个PDF文件的文件夹.我需要根据文件名(将这些文件分组为2个或更多PDF文件)过滤这些文件,然后将这2个以上的PDF合并为1个PDF.
我可以对文件进行分组,但不确定将这些文件合并为1个PDF的最佳方法.我研究了iTextSharp,但无法在PowerShell中使用它.
iTextSharp是最好的方法吗?任何有关此代码的帮助将非常感激.
非常感谢保罗
我正在成功合并PDF文档; 现在因为我试图在没有选择PDF文档的情况下实现错误处理,它在关闭文档时会抛出错误:文档没有页面
如果在"foreach" - 循环中没有添加PDF文档,我仍然需要关闭文件!?或不?如果你打开一个物体,那么它在某个时刻就会被关闭.那么如果没有添加页面,如何正确转义?
private void MergePDFs()
{
DataSourceSelectArguments args = new DataSourceSelectArguments();
DataView view = (DataView)SourceCertCockpit.Select(args);
System.Data.DataTable table = view.ToTable();
List<PdfReader> readerList = new List<PdfReader>();
iTextSharp.text.Document document = new iTextSharp.text.Document();
PdfCopy copy = new PdfCopy(document, Response.OutputStream);
document.Open();
int index = 0;
foreach (DataRow myRow in table.Rows)
{
if (ListadoCertificadosCockpit.Rows[index].Cells[14].Text == "0")
{
PdfReader Reader = new PdfReader(Convert.ToString(myRow[0]));
Chapter Chapter = new Chapter(Convert.ToString(Convert.ToInt32(myRow[1])), 0);
Chapter.NumberDepth = 0;
iTextSharp.text.Section Section = Chapter.AddSection(Convert.ToString(myRow[10]), 0);
Section.NumberDepth = 0;
iTextSharp.text.Section SubSection = …Run Code Online (Sandbox Code Playgroud)