标签: itextsharp

是否可以修改PDF表单字段名称?

这是情况.我有一个带有自动生成的pdf表单字段名称的PDF.问题是这些名称不是非常用户友好.它们看起来像:topmostSubform [0] .Page1 [0] .Website_Address [0]

我希望能够更改它们,使它们像WebsiteAddress.我可以访问ABCPDF并且我有使用iTextSharp的经验,但我尝试使用这些API来执行此操作(访问表单字段并尝试重命名),但似乎不可能.

有没有人尝试通过某种API(最好是开源)尝试这样做.代码也是.Net.

.net pdf abcpdf itextsharp

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

如何使用itextsharp删除pdf文档的默认上边距?

我试图让我的pdf文档从(0,0)开始,但是看起来文档对象有一个默认的上边距,我不能设置为0.有没有办法做到这一点?

我的代码如下所示

        using (MemoryStream memoria = new MemoryStream())
        {
            Document pdf = new Document(new Rectangle(288, 144));

            try
            {
                PdfWriter writer = PdfWriter.GetInstance(pdf, memoria);

                pdf.Open();
                pdf.SetMargins(0, 0, 0, 0);

                PdfPTable tPrincipal = new PdfPTable(2);            
                tPrincipal .WidthPercentage = 100;           
                tPrincipal .DefaultCell.Border = 0;
                tPrincipal .TotalWidth = 288f;
                tPrincipal .LockedWidth = true;
Run Code Online (Sandbox Code Playgroud)

....

我无法将上边距设置为0.它只是不关心我的设置为(0,0,0,0)并留下上边距(约50f).

margin itextsharp

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

使用itextsharp(或任何c#pdf库),如何打开PDF,替换一些文本,然后再次保存?

使用itextsharp(或任何c#pdf库),我需要打开一个PDF,用实际值替换一些占位符文本,并将其作为byte []返回.

有人可以建议怎么做吗?我已经看了一下itext文档,无法弄清楚从哪里开始.到目前为止,我仍然坚持如何将源PDF文件从PDFReader获取到Document对象,我认为我可能以错误的方式接近它.

非常感谢

c# pdf acrobat itextsharp

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

如何使用iTextSharp为页面添加边框?

是否可以使用iTextSharp?为PDF文档中的页面添加边框?我从头开始生成PDF文件,因此我不需要为现有文档添加边框.

这是我的代码示例:

Document pdfDocument = new Document(PageSize.LETTER);
Font headerFont = new Font(baseFont, 13);
Font font = new Font(baseFont, 10);
PdfWriter writer = PdfWriter.GetInstance(pdfDocument, 
                                         new FileStream(fileName, FileMode.Create));
pdfDocument.Open();

//I add IElements here.

pdfDocument.Close();
Run Code Online (Sandbox Code Playgroud)

c# pdf border itextsharp winforms

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

在itextsharp中从模板创建pdf并输出为内容处置.

我想打开一个现有的pdf,添加一些文本然后使用itext sharp作为内容处理输出.我有以下代码.它落下的地方是我想输出内存流但需要filestream来打开原始文件.

这就是我所拥有的.显然,定义PdfWriter两次是行不通的.

   public static void Create(string path)
    {
        var Response = HttpContext.Current.Response;
        Response.Clear();
        Response.ContentType = "application/pdf";
        System.IO.MemoryStream m = new System.IO.MemoryStream();
        Document document = new Document();
        PdfWriter wri = PdfWriter.GetInstance(document, new FileStream(path, FileMode.Create));
        PdfWriter.GetInstance(document, m);
        document.Open();
        document.Add(new Paragraph(DateTime.Now.ToString()));
        document.NewPage();
        document.Add(new Paragraph("Hello World"));
        document.Close();
        Response.OutputStream.Write(m.GetBuffer(), 0, m.GetBuffer().Length);
        Response.OutputStream.Flush();
        Response.OutputStream.Close();
        Response.End();
    } 
Run Code Online (Sandbox Code Playgroud)

itextsharp

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

如何在pdf文件中找到空白页面

我无法在pdf文件中检测到空白页面.我已经搜索了互联网,但找不到一个好的解决方案.

使用Itextsharp我尝试了页面大小,Xobjects.但他们没有给出确切的结果.

我试过了

if(xobjects==null || textcontent==null || size <20 bytes )
  then "blank"
else
 not blank
Run Code Online (Sandbox Code Playgroud)

但是它返回错误答案的最长时间.我用过Itextsharp

代码如下......我正在使用Itextsharp Librabry

对于xobjects

PdfDictionary xobjects = resourceDic.GetAsDict(PdfName.XOBJECT);
//here resourceDic is PdfDictionary type
//I know that if Xobjects is null then page is blank. But sometimes blank page gives xobjects which is not null.
Run Code Online (Sandbox Code Playgroud)

对于contentstream

 RandomAccessFileOrArray f = reader.SafeFile;
 //here reader = new PdfReader(filename);

 byte[] contentBytes = reader.GetPageContent(pageNum, f);
 //I have measured the size of contentbytes but sometimes it gives more than …
Run Code Online (Sandbox Code Playgroud)

.net c# pdf itextsharp pdf-parsing

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

如何在PdfPTable中更改字体大小?

我正在使用itextsharp动态写入pdf.我在pdf文档中创建一个表,其中包含数据库中的值.有人可以告诉如何修改表中值的字体大小.

c# asp.net itextsharp

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

如何在iTextSharp中显示水平线

我正在创建一个pdf,需要在页面中放置一条水平线.任何人都可以告诉你该怎么做?

我有一个xml文件,其中包含我的html标签(<table>....</table>).并且xml文件的整个内容被解析string为用于创建的文件pdf.现在不支持某些标签.其中之一是<hr>.那么我可以在xml文件中使用任何其他标记,以便line在使用xml数据创建pdf时绘制 .

下面是xml xontent的示例

<table>
   <tr>
     <td>
       <span>
           This is working properly.
       </span>
     </td>
   <tr>
</table>

<table>
   <tr>
     <td>
       <span>
           <hr>
           This is not working properly.
       </span>
     </td>
   <tr>
</table>
Run Code Online (Sandbox Code Playgroud)

如果需要更多信息,请告诉我.

提前致谢.

.net asp.net pdf-generation itextsharp

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

CSS样式未使用iTextSharp应用于PDF

我试图使用iTextSharp将我的网页的一部分转换为pdf,虽然pdf生成工作正常,但没有应用任何css样式.我尝试过一次一个地应用这些样式,但这似乎不起作用.这是我到目前为止所提出的:

//Get the portion of the page to convert.
StringBuilder sb = new StringBuilder();
print_div.RenderControl(new HtmlTextWriter(new StringWriter(sb)));
string html = sb.ToString();

//Generate a random filename to use for the pdf
Guid random_guid;
random_guid = Guid.NewGuid();
string fileName = random_guid.ToString() + ".pdf";
string filename_with_folder = @"pdf\sl_" + fileName;
string fullFilePath = System.IO.Path.Combine(Request.PhysicalApplicationPath, filename_with_folder);

using (Document doc = new Document())
{
    // Create the pdf
    PdfWriter writer = PdfWriter.GetInstance(doc, new FileStream(fullFilePath, FileMode.Create));
    doc.Open();
    try
    {
        //Set the font size for all elements …
Run Code Online (Sandbox Code Playgroud)

c# pdf-generation itextsharp

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

如何在iTextSharp中设置PdfPTable的高度

我下载了iTextSharp dll的最新版本.我生成了一个PdfPTable对象,我必须设置它的高度.尽管设置了PdfPTable的宽度,但我无法设置它的高度.一些作者建议使用'setFixedHeight'方法.但是最后一个版本的iTextSharp.dll没有'setFixedHeight'方法.它的版本是5.5.2.我该怎么做?

height itextsharp pdfptable

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