【问题标题】:Trying to add a ItextSharp List (not the list like list box, but the bulleted list) to a PDF尝试将 ItextSharp 列表(不是列表框之类的列表,而是项目符号列表)添加到 PDF
【发布时间】:2013-02-12 19:57:59
【问题描述】:

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

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

我知道那里有很多关于 ItextSharp 的文章和主题,但没有找到任何东西。

谢谢!

【问题讨论】:

    标签: .net silverlight pdf itextsharp


    【解决方案1】:

    所以我找到了我的问题的答案。我所做的是:

            //Used to add Bulleted list to PDF
            PdfContentByte cb = stamper.GetOverContent(1);
            ColumnText ct = new ColumnText(cb);
    
            //Get the coordinates of a text field(PUTLISTHERE) to put the List into
            System.Collections.Generic.IList<AcroFields.FieldPosition> fieldsList = fields.GetFieldPositions("PutListHere");
            AcroFields.FieldPosition fieldPosition = fieldsList[0];
    
            //Set the coordinates for the list
            ct.SetSimpleColumn(fieldPosition.position.Left, 
                               fieldPosition.position.Bottom, 
                               fieldPosition.position.Right, 
                               fieldPosition.position.Top, 15, Element.ALIGN_LEFT);
    
            //create a new list
            it.List list = new it.List(it.List.UNORDERED, 8f);
            list.SetListSymbol("\u2022");
            list.IndentationLeft = 45f;
    
            //add the terms to the list
            foreach (Terms_Proposals tp in csaProposal.Terms_Proposals)
            {
                list.Add(new it.ListItem(tp.Term.TermDesc, FontFactory.GetFont("TIMES_ROMAN", 8)));
            }
    
            //add the list
            ct.AddElement(list);
            ct.Go();
    

    希望这可以帮助别人!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多