标签: itextsharp

itextsharp pdfpcell标头

我想要一个PdfPCell类的单元格表,每个单元都有一个小标题,主字符串和小页脚.我找不到插入它们的方法,因为HeaderandFooter不允许元素添加到单元格,一个段落覆盖另一个,依此类推.有任何想法吗?

提前致谢

c# java pdf pdf-generation itextsharp

3
推荐指数
1
解决办法
1万
查看次数

iTextSharp - 如何从项目资源输入图像(PNG)?

我有iTextSharp在VB.net中为我创建一个pdf.一切都在着名,除了现在我想嵌入一个图像.我试过这个:

Dim test = My.Resources.MyImage
Dim logo = Image.GetInstance(test)
Run Code Online (Sandbox Code Playgroud)

这是一个错误:

无法使用这些参数调用"GetInstance"

看起来好像它需要一个路径,并且正在获得System.Drawing.Bitmap类型.

有什么办法可以将项目资源图像添加到我的PDF中吗?提前致谢!

vb.net pdf resources itextsharp embedded-resource

3
推荐指数
1
解决办法
1万
查看次数

如何在iTextSharp中使用非中断空格

如何可以使用非中断空间在PdfPTable单元格中具有多行内容.iTextSharp用空格字符分解单词.

场景是我想要一个表头中的多行内容,例如在第一行它可以显示"Text1&",在第二行它将显示"Text",在渲染PDF时Text1在第一行显示,然后在第二行显示,第三行显示第一行的长度,并将剩余的字符截断到下一行.

或者我可以为表格的每一列设置特定宽度,以便容纳其中的文本内容,例如文本将包裹在该特定宽度内.

whitespace itextsharp

3
推荐指数
1
解决办法
5405
查看次数

将页码添加到pdf文档(itextsharp)

我想将页码添加到itextsharp pdf文件的页脚.我从html(asp.net repeater)生成pdf.我使用XMLWorkerHelper来解析html内容.我搜索了很多但是找不到任何有用的东西来实现这一点.

c# asp.net itextsharp

3
推荐指数
1
解决办法
3万
查看次数

如何标记和签署pdf ALREADY签名而不会使之前的签名无效

一些插件和程序可以做到这一点; 是否有任何示例或教程如何使用.net和itextSharp?

我需要签名pdf并在所有页面上标记图像,并添加另一个签名.打开文件时,文档上的第一个签名必须有效.

提前致谢.

pdf sign signature itextsharp

3
推荐指数
1
解决办法
4485
查看次数

读取pdf的ITextSharp异常:重建失败:字典键""不是名称

我在.net(c#)项目中使用iTextSharp库收到特定pdf文件的未处理异常.我无法理解我想要上传的pdf的具体内容,虽然我可以看到基本的pdf我从互联网功能下载工作.以下部分代码:

string pdfTemplate ="url to specific pdf"; var pdfReader = new PdfReader(pdfTemplate);

抛出异常:重建失败:字典键Z不是名称.在文件指针224; 原始消息:字典键Z不是名称.在文件指针224处

请问有什么建议吗?我没有想法......

c# pdf itextsharp

3
推荐指数
1
解决办法
2238
查看次数

转换加盖页面时,PDF到PostScript的转换速度很慢

我一直在使用Ghostscript将PDF文档转换为PS.转换速度接近瞬间,直到我开始在PDF页面上标记签名.现在每个加盖的页面都会增加2-3秒,从而导致巨大的瓶颈.

  1. 有没有什么方法可以通过GS命令提高转换效率?
  2. 是否有更好的方式来标记PDF文档?

我不确切知道发生了什么,但我猜这个标记为PDF添加了一层,一旦转换为PS就会产生更多的工作?

我正在使用C#,iTextSharp来添加图章.

我试图用FormFlattening = true添加图章.
我在这个问题中尝试过以下建议[ 有关加速GhostScript的任何提示吗?]无济于事.

c# pdf postscript ghostscript itextsharp

3
推荐指数
1
解决办法
549
查看次数

将参数传递给重写的OnEndPage方法

我需要将参数传递给"OnEndPage"方法的重写版本,当我声明参数时我没有得到任何错误但是当我调用该方法时它告诉我"不能隐式地将void转换为itextsharp.text.pdf .ipdfpageevent"

这是我的OnEndPage方法:

  public class pdfPage : iTextSharp.text.pdf.PdfPageEventHelper
{           
    public override void OnEndPage(PdfWriter writer, Document doc, int parametro)
    {
        PdfPTable headerTbl = new PdfPTable(1);

        headerTbl.TotalWidth = doc.PageSize.Width;

        Image logo = Image.GetInstance("logo.png");

        logo.ScalePercent(42);

        PdfPCell cell = new PdfPCell(logo);

        cell.HorizontalAlignment = Element.ALIGN_LEFT;

        cell.PaddingRight = 52;

        cell.Border = 0;

        headerTbl.AddCell(cell);

        headerTbl.WriteSelectedRows(0, -1, 0, (doc.PageSize.Height - 10), writer.DirectContent);

        PdfPTable headerrow = new PdfPTable(7);
        headerrow.TotalWidth = 570f;
        headerrow.LockedWidth = true;
        headerrow.AddCell(new Phrase("TIPO DOCUMENTO", new Font(Font.FontFamily.HELVETICA, 6f)));

        headerrow.WriteSelectedRows(0, -1, 0, (doc.PageSize.Height - 50), writer.DirectContent);
    }
} …
Run Code Online (Sandbox Code Playgroud)

c# itextsharp

3
推荐指数
2
解决办法
5243
查看次数

使用itextsharp c#在现有PDF上绘制圆圈

我在现有的PDF上画了一些麻烦,我找到了一个代码来在现有的PDF上添加文字,我试图让它适应画圈,但结果只是一个空白页有没有人知道如何解决这个问题?

我的代码:

        string oldFile = @"C:\...6166-21.pdf";
        string newFile = @"C:\...NEW.pdf";

        // open the reader
        PdfReader reader = new PdfReader(oldFile);
        Rectangle size = reader.GetPageSizeWithRotation(1);
        Document document = new Document(size);

        FileStream fs = new FileStream(newFile, FileMode.Create, FileAccess.Write);
        PdfWriter writer = PdfWriter.GetInstance(document, fs);
        document.Open();

        // the pdf content
        PdfContentByte cb = writer.DirectContent;

        cb.Circle(150f, 150f, 50f);
        cb.SetColorStroke(iTextSharp.text.BaseColor.GREEN);

        // create the new page and add it to the pdf
        PdfImportedPage page = writer.GetImportedPage(reader, 1);
        cb.AddTemplate(page, 0, 0);

        // close the streams and voilá the file …
Run Code Online (Sandbox Code Playgroud)

c# itextsharp

3
推荐指数
1
解决办法
2531
查看次数

如何使用iTextsharp在服务器地图路径上保存pdf

我使用以下代码生成pdf,它是完美的工作:

  string strQuery = "select * from userdata";
        SqlCommand cmd = new SqlCommand(strQuery);
        DataTable dt = GetData(cmd);

        //Create a dummy GridView
        GridView GridView1 = new GridView();
        GridView1.AllowPaging = false;
        GridView1.DataSource = dt;
        GridView1.DataBind();

        Response.ContentType = "application/pdf";
        Response.AddHeader("content-disposition", "attachment;filename=GridViewExport.pdf");
        Response.Cache.SetCacheability(HttpCacheability.NoCache);
        StringWriter sw = new StringWriter();
        HtmlTextWriter hw = new HtmlTextWriter(sw);
        GridView1.RenderControl(hw);

        StringReader sr = new StringReader(sw.ToString());
        Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 10f, 0f);
        HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
        PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
        pdfDoc.Open();

        htmlparser.Parse(sr);
        pdfDoc.Close();

        Response.Write(pdfDoc);
        Response.End();  
Run Code Online (Sandbox Code Playgroud)

它运作良好.但我能够将此pdf保存到服务器地图路径上.

我在pdfDoc.Close()之后写了下面的内容.

   String path …
Run Code Online (Sandbox Code Playgroud)

c# pdf asp.net itextsharp

3
推荐指数
1
解决办法
2万
查看次数