标签: itextsharp

如何使用 VB.net 在 iTextSharp 中使用系统字体

我正在使用 Itextsharp 使用 VB.net 将文本文件动态转换为 PDF 文档。但是,我需要使用不属于 iTextSharp 库的系统字体。我看过一些使用 C# 的代码示例。但是,我是编程新手,我的经验都在 Visual Basic 中。有人可以帮我编写代码以使用系统字体吗?

vb.net fonts itextsharp

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

使用 ItextSharp C# 标记 PDF 的各个页面

我目前正在使用 ITEXTSHARP 5.5.6.0

我的目标是为每个页面添加一个密钥,并在我使用另一个应用程序再次阅读文档时保留这些密钥。我希望能够单独跟踪每个页面(密钥是唯一的,并且来自另一个来源)。

这是我的导入/写入代码:

 using (PdfReader reader = new PdfReader(sourcePdfPath))
 {

        using (Document document = new Document(reader.GetPageSizeWithRotation(pageNumber)))
        {

            PdfCopy pdfCopyProvider = new PdfCopy(document, new System.IO.FileStream(outputPdfPath, System.IO.FileMode.Create));
            pdfCopyProvider.SetTagged();
            pdfCopyProvider.PdfVersion = PdfWriter.VERSION_1_7;

            PdfImportedPage importedPage = pdfCopyProvider.GetImportedPage(reader, pageNumber, true);
            importedPage.SetAccessibleAttribute(PdfName.ALT, new PdfString("MYKEY"));
            pdfCopyProvider.AddPage(importedPage);               
        }
 }
Run Code Online (Sandbox Code Playgroud)

这是我的阅读代码:

using (MemoryStream ms = new MemoryStream())
        {
            Document document = new Document();
            PdfCopy copy = new PdfCopy(document, ms);
            copy.SetTagged();
            document.Open();
            for (int i = 0; i < pdfs.Count; ++i)
            {
                var pdf = File.ReadAllBytes(pdfs[i]);
                PdfReader reader …
Run Code Online (Sandbox Code Playgroud)

.net c# pdf tagging itextsharp

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

如何在 iTextSharp 中引入上标?

我想要像 2015 年 5 月 14 日这样的输出格式日期。14 天它应该带有 sup 标签,但 sup 标签没有在此处访问。我在 ph102 变量中得到的输出。Getsuffix(csq.EventDate.Value.Day) 在这个只有我得到 th st 和 rd 的日期后缀

我的代码:

PdfPTable table9 = new PdfPTable(4);
table9.WidthPercentage = 99;
table9.DefaultCell.Border = 0;
table9.DefaultCell.VerticalAlignment = Element.ALIGN_MIDDLE;
Phrase ph101 = new Phrase("Event Date & Time", textFont2);
PdfPCell cellt1 = new PdfPCell(ph101);
cellt1.Border = PdfPCell.BOTTOM_BORDER + PdfPCell.LEFT_BORDER + PdfPCell.RIGHT_BORDER;
cellt1.PaddingTop = 0F;
cellt1.VerticalAlignment = Element.ALIGN_MIDDLE;
cellt1.HorizontalAlignment = Element.ALIGN_LEFT;
DateTime eventTime = DateTime.Today;
if (!string.IsNullOrEmpty(Convert.ToString(csq.EventTime)))
    eventTime = DateTime.Today.Add(csq.EventTime.Value);
Phrase ph102;
if (!string.IsNullOrEmpty(csq.EventDate.ToString())) …
Run Code Online (Sandbox Code Playgroud)

html c# pdf itextsharp

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

使用 iTextSharp 将图像转换为 PDF 保留剪切路径

我们希望以编程方式将图像批量转换为 PDF。到目前为止,我们似乎将使用 iTextSharp,但我们在处理带有剪切路径的 JPG 图像时遇到了问题。我们在测试中使用以下代码:

using (FileStream fs = new FileStream(output, FileMode.Create, FileAccess.Write, FileShare.None))
{
    using (Document doc = new Document())
    {
        using (PdfWriter writer = PdfWriter.GetInstance(doc, fs))
        {
            doc.Open();
            iTextSharp.text.Image image = iTextSharp.text.Image.GetInstance(source);

            image.SetAbsolutePosition(0, 0);
            doc.SetPageSize(new iTextSharp.text.Rectangle(0, 0, image.Width, image.Height, 0));
            doc.NewPage();

            writer.DirectContent.AddImage(image,false); 

            doc.Close();
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

JPG 图像中的剪切路径似乎只是被丢弃了。有没有办法保留剪切路径?此外,在调用 AddImage 时,有一个 InlineImage 选项,有人知道这是做什么的吗?

c# jpeg clipping itext itextsharp

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

iTextSharp许可

我们想在我们的一个项目中使用iTextSharp DLL来提取PDF文本,但我有第二个想法将它发布到生产中,因为我读到某个地方我们需要为我们购买商业许可才能使用iTexttSharp.这是真的?我们只会消耗DLL,我们不会改变任何东西,我们还需要购买许可吗?

提前致谢!

licensing itext itextsharp

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

iTextSharp。如何从 AcroFields 获取特定类型?像 PushButtonField、RadioCheckField 等

我正在尝试转换AcroFields为特定类型,以便我可以为它们设置属性。

当我打电话时,AcroFields.GetField(string name);我得到的只是一个字符串。

当我打电话时,AcroFields.GetFieldItem(string name);我得到一个对象,但无法将其转换为特定类型。

我也试过:

AcroFields.SetFieldProperty("myfield", "CheckType", RadioCheckField.TYPE_STAR, null);

每次都返回false。

为了更好地解释我的场景:

我有一个现有的 PDF(我没有生成这个文件)。

里面有一个复选框。我想像这样更改“CheckType”:myRadioCheckField.CheckType = RadioCheckField.TYPE_STAR

但是由于我无法将 AcroField 转换为特定类型,因此我无法访问该属性“CheckType”。

有没有办法实现这一目标?

如果可能,请提供工作样本。

谢谢你。

c# pdf-generation itextsharp

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

在VB.NET中使用iTextSharp添加标题

我想知道如何将标题放入我的PDF文件中,因为我已经尝试过这里的教程:

http://itextsharp.sourceforge.net/tutorial/ch04.html

它没有奏效.

我这样做了:

Dim head As New HeaderFooter(New Phrase("This is page: "), False)
head.Border = Rectangle.NO_BORDER
document.Header = head
Run Code Online (Sandbox Code Playgroud)

但是VS2008说HeaderFooter没有定义(第1行),而且Footer it's not a member of "iTextSharp.text.document" (line 3).

我已经在我的代码开头包含了导入,而且我没有任何其他问题与iTextsharps(我的意思是它解决了标题问题):

Imports iTextSharp.text
Imports iTextSharp.text.pdf
Imports System.Data.SQLite
Imports System.IO
Run Code Online (Sandbox Code Playgroud)

所以,请有人向我解释如何为我的页面设置标题?

问候

vb.net pdf header itextsharp

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

使用itextsharp检查签名字段是否已签名

我有一个PDF文件,我需要用ITextSharp(版本5.1.1)阅读.我需要遍历签名字段并验证签名字段是否已签名.

我已经可以遍历签名字段,但我无法弄清楚如何检查签名字段是否已签名.我不想验证签名字段,因为我只对该字段是否已签名感兴趣,而不是其有效性.

有人可以指点我在正确的方向吗?

我可以查看Siganturefields的房产吗?

TIA

c# itextsharp

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

使用PdfWriter和iTextSharp以及SetFontAndSize函数的斜体文本

我正在使用iTextSharp创建一些pdf文件.这些文档有几个页面,除了最后一个页面之外,我们需要有一个用斜体字体书写的文本.

这是我的代码使用PdfTemplate,它的工作原理,但我无法设置字符串Italic:

public override void OnCloseDocument(PdfWriter writer, Document document)
{
    base.OnCloseDocument(writer, document);

    template.BeginText();
    template.SetFontAndSize(arial, 11);
    template.SetTextMatrix(0, 0);
    template.ShowText("" + (writer.PageNumber - 1));
    template.EndText();

    int index = 0;
    foreach (PdfTemplate temp in templates)
    {
        if ((++index) < (writer.PageNumber-1))
        {
            temp.BeginText();
            temp.SetFontAndSize(arial, 11);
            temp.SetTextRenderingMode(0);
            temp.SetTextMatrix(0, 0);
            temp.ShowText("- Continued -");
            temp.EndText();
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

你能不能帮我找到一种方法让我的字符串显示为Italic?

c# pdf itextsharp

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

如何使用itextsharp在表行之后创建空格?

我有一个非常简单的itextsharp表,如下所示:

PdfPTable table = new PdfPTable(3);
PdfPCell cell = new PdfPCell(new Phrase("Header spanning 3 columns"));
cell.Colspan = 3;
cell.HorizontalAlignment = 1;
table.AddCell(cell);
table.AddCell("Col 1 Row 1");
table.AddCell("Col 2 Row 1");
table.AddCell("Col 3 Row 1");

// Create spacing after row here only.

table.AddCell("Col 1 Row 2");
table.AddCell("Col 2 Row 2");
table.AddCell("Col 3 Row 2");
doc.Add(table);
Run Code Online (Sandbox Code Playgroud)

如何仅在第1行和第2行之间创建空格?

谢谢.

c# itextsharp

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

标签 统计

itextsharp ×10

c# ×7

pdf ×4

itext ×2

vb.net ×2

.net ×1

clipping ×1

fonts ×1

header ×1

html ×1

jpeg ×1

licensing ×1

pdf-generation ×1

tagging ×1