标签: itextsharp

从 PDF 文档中删除超链接 (iTextSharp)

我正在尝试利用 iTextSharp(该产品非常新)从 PDF 文档中删除超链接。有谁知道这是否可能?我一直在挖掘 API,但还没有找到一种明显的方法来做到这一点。

我的问题是我正在对一个系统进行维护,该系统在 iframe 中嵌入了 PDF,并且 PDF 中的链接导致用户最终在 iframe 中而不是在新窗口或选项卡中浏览网站,所以我正在寻找一种在请求时终止 PDF 中链接的方法。

提前致谢,斯科特

c# pdf hyperlink itextsharp

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

尝试将 ItextSharp 列表(不是像列表框那样的列表,而是项目符号列表)添加到 PDF

我正在使用 ItextSharp Stamper 加载模板化 PDF,并希望将项目符号列表添加到 PDF 中的特定位置。

拳头这可能吗?我在 mikesdotnetting 博客中看到了如何创建列表,它看起来像我需要的。但是,我想定位列表。

我意识到有很多关于 ItextSharp 的文章和主题,但没有找到任何东西。

谢谢!

.net pdf silverlight itextsharp

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

itextsharp html 到 pdf 创建没有边框

我使用 iTextSharp(在 SharePoint 上,但我希望这无关紧要)将 HTML 文档转换为 PDF。到目前为止,我无法在元素周围获得任何边框。我该怎么做呢?这不支持吗?

我尝试过的事情:

  // in c# code
StyleSheet styles = new iTextSharp.text.html.simpleparser.StyleSheet();
styles.LoadStyle("borderCls", "border-style", "solid"); // <td class="borderCls">
styles.LoadStyle("borderCls", "border-width", "1px");
styles.LoadStyle("borderCls", "border-color", "#000");
  //
styles.LoadStyle("borderCls", "border", "solid 1px #000");

  // in html
<td style="border:solid 1px #000">
  //
<td border="1">
  //
<td style="border-style:solid;border-width:1px">
Run Code Online (Sandbox Code Playgroud)

但这些都不起作用。我只是无法让 iTextSharp 创建任何边框。

更新:也可以只在特定的一侧定义一个边框吗?

html c# border itextsharp

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

itextSharp - html 到 pdf 缺少一些土耳其语字符

当我尝试从 HTML 生成 PDF 时,PDF?Ü??ÖÇ ?ü??öç中缺少一些土耳其语字符,我看到一个空格代替这些字符,但我想打印该字符。

我的代码是:

public virtual void print pdf(string html, int id)
{
    String htmlText = html.ToString();
    Document document = new Document();
    string filePath = HostingEnvironment.MapPath("~/Content/Pdf/");
    PdfWriter.GetInstance(document, new FileStream(filePath + "\\pdf-"+id+".pdf", FileMode.Create));
    document.Open();
    iTextSharp.text.html.simpleparser.HTMLWorker hw =
                     new iTextSharp.text.html.simpleparser.HTMLWorker(document);

    hw.Parse(new StringReader(htmlText));
    document.Close();
}
Run Code Online (Sandbox Code Playgroud)

如何在 PDF 上打印所有土耳其语字符?

itextsharp

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

从我的 ActiveX 禁用 Adob​​e Reader 工具栏

我正在使用 AxAcroPDFLib 和 iTextSharp 库在我的 ActiveX 中加载 PDF 文档。我想从加载的 PDF 中禁用工具栏(具有保存、打印等选项),以便用户无法从 ActiveX 中“保存”PDF。

我有以下代码:

axAcroPDF1.Width = someWidth;
axAcroPDF1.Height = someHeight;
axAcroPDF1.LoadFile(documentPath);
axAcroPDF1.setPageMode("none");
axAcroPDF1.setShowToolbar(false);

axAcroPDF1.Show();
axAcroPDF1.Focus();
Run Code Online (Sandbox Code Playgroud)

所述axAcroPDF1.setShowToolbar(false)禁用工具栏,但其它灰度工具栏,在底部(如图此链路上的PDF)当我在那个区域中移动鼠标。该工具栏也有保存选项,我也想禁用这个选项。

如果它只允许禁用“保存”选项并在工具栏上启用其他选项,那就太好了。

pdf adobe axacropdf toolbar itextsharp

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

命名空间"iTextSharp"中不存在类型或命名空间名称"工具"(您是否缺少程序集引用?)

命名空间"iTextSharp"中不存在类型或命名空间名称"工具"(您是否缺少程序集引用?)

itextsharp

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

C# iTextSharp:进程无法访问该文件,因为它正被另一个进程使用

我正在使用 iTextSharp 从模板生成 pdf 文件,填充此代码部分中的每个字段:

        PdfReader pdfReader = new PdfReader(templatePath);
        try
        {
            using (FileStream newFileStream = new FileStream(newFilePath, FileMode.Create))
            {
                using (PdfStamper stamper = new PdfStamper(pdfReader, newFileStream))
                {
                    // fill each field
                    AcroFields pdfFormFields = stamper.AcroFields;
                    foreach (KeyValuePair<string, string> entry in content)
                    {
                        if (!String.IsNullOrEmpty(entry.Value))
                            pdfFormFields.SetField(entry.Key, entry.Value);
                    }

                    //The below will make sure the fields are not editable in
                    //the output PDF.
                    stamper.FormFlattening = true;
                    stamper.Close();
                }                    
            }
        }
        finally
        {
            pdfReader.Close();
        }
Run Code Online (Sandbox Code Playgroud)

一切顺利,文件看起来不错,但是当我尝试重新打开文件以将其与我在一个唯一文档中生成的其他一些文件合并时,我收到此错误:

2015-11-23 09:46:54,651||ERROR|UrbeWeb|System.IO.IOException: The process cannot access …
Run Code Online (Sandbox Code Playgroud)

c# itextsharp

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

由Adobe Reader丢失的Response.Stream输出(PDF)

在ASP.NET应用程序中,我使用iTextSharp(主要是PdfStamper)来填充PDF上的一些内容并将其发送给用户.以下代码位于OnClick事件中:

PdfReader r = new PdfReader(
  new RandomAccessFileOrArray(Request.MapPath(compatiblePdf)), null
);

ps = new PdfStamper(r, Response.OutputStream);
AcroFields af = ps.AcroFields;

af.SetField("ContactInfo[0]", o.mallName);
af.SetField("ClientName", string.Format("{0} {1}", c.firstName, c.lastName));
af.SetField("ClientEmail", c.emailAddress);
ps.FormFlattening = true;
Response.ContentType = "application/pdf";
Response.AddHeader("Content-Disposition", "attachment; filename=Form.pdf");
ps.Close();
Response.End();
Run Code Online (Sandbox Code Playgroud)

因此,基本上,PdfReader获取文件,PdfStamper将PdfReader作为参数,并将其完成的PDF推送到Response.OutputStream.

问题是,使用IE和Adobe Reader,如果从文件对话框中选择"打开",Adobe Reader会抛出错误提示"无法找到文件".用户可以"保存"文件,甚至可以再次开始下载(在被问到时再次单击"打开")似乎可以正常工作.但是在一台永远不会下载文件的新机器上,Adobe Reader似乎错误地将文件放在临时文件或IE之间.

我现在只能想象一件事:Response.End()或许,应该,或许,Response.Close()或许整个事情应该Response.Flush()在它之前.但我不确定这会不会使问题变得更糟,而且我很难测试(因为,一旦你下载了一次文件,就不会再次抛出错误).

可能解决问题吗?我在标题中有什么问题吗?或者我还应该对Response/PdfStamper对象做些什么呢?

c# outputstream response itextsharp

0
推荐指数
1
解决办法
1994
查看次数

ITextSharp,在单元格中为List分配字体?

有没有办法将字体分配给添加到ITextsharp中的表格单元格的列表.我敢肯定它一定是直截了当但我却想念它.

Dim tblSignature As New PdfPTable(1)
        tblSignature.WidthPercentage = 90.0F

        Dim _baseFont As BaseFont = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.WINANSI, BaseFont.NOT_EMBEDDED)

        Dim _bFont As New Font(_baseFont, 4, Font.ITALIC, Color.RED)

        Dim cell As New PdfPCell(New Phrase(TheItem.Value, _bFont))

        TheParagraph.Font = _bFont


        Dim list As New List(list.UNORDERED, 25.0F)
        list.SetListSymbol("[  ]")


        If ListItems.Count > 0 Then
            For Each ListItem In .ListItems
                //I have tried adding as chunk/phrase and applying font but no joy
                //Item not added to cell
                //list.Add(New Chunk(ListItem, _bFont))

                list.Add(ListItem)
            Next

            list.IndentationLeft = 5.0F

            cell.AddElement(list)
        End …
Run Code Online (Sandbox Code Playgroud)

itextsharp

0
推荐指数
1
解决办法
5844
查看次数

用于将HTML转换为PDF的iTextSharp的替代方案

我想使用iTextSharp将HTML文件转换为PDF .

我用过这段代码.

然后我做了以下将其转换为pdf:

HTMLWorker htmlWorker = new HTMLWorker(document);
htmlWorker.Parse(new StringReader(results));
document.Close();
Run Code Online (Sandbox Code Playgroud)

但是,没有解析CSS.任何替代品?

html c# pdf itextsharp

0
推荐指数
1
解决办法
9051
查看次数