我正在使用itextsharp生成PDF,但我需要动态更改一些文本.我知道如果有任何AcroField可以改变,但我的PDF doen有任何一个.它只有一些纯文本,我需要改变其中的一些.
有谁知道怎么做?
有没有办法确定PDF文件的类型:如果现有PDF文件是扫描图像,或者是否使用iTextSharp和C#从数据文件创建?
我正在使用iTextSharp(C#iText端口)从text/html创建pdf.我的大部分文字都是希伯来语,一种从右到左的语言.
我的问题是PDF反向显示RTL语言,所以我需要以一种只能反转RTL文本的方式来反转我的字符串而不用英语反转任何数字或文本.据我所知,fribidi允许在linux上执行此操作,但我无法找到针对此问题的任何解决方案.
我欢迎任何建议,包括自动执行此操作的iTextSharp的替代方案(如果存在).
我正在尝试从HTML页面中创建PDF.我正在使用的CMS是EPiServer.
到目前为止这是我的代码:
protected void Button1_Click(object sender, EventArgs e)
{
naaflib.pdfDocument(CurrentPage);
}
public static void pdfDocument(PageData pd)
{
//Extract data from Page (pd).
string intro = pd["MainIntro"].ToString(); // Attribute
string mainBody = pd["MainBody"].ToString(); // Attribute
// makae ready HttpContext
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.ContentType = "application/pdf";
// Create PDF document
Document pdfDocument = new Document(PageSize.A4, 80, 50, 30, 65);
//PdfWriter pw = PdfWriter.GetInstance(pdfDocument, HttpContext.Current.Response.OutputStream);
PdfWriter.GetInstance(pdfDocument, HttpContext.Current.Response.OutputStream);
pdfDocument.Open();
pdfDocument.Add(new Paragraph(pd.PageName));
pdfDocument.Add(new Paragraph(intro));
pdfDocument.Add(new Paragraph(mainBody));
pdfDocument.Close();
HttpContext.Current.Response.End();
}
Run Code Online (Sandbox Code Playgroud)
这将输出文章名称,简介和主体的内容.但它没有解析文章文本中的HTML,也没有布局.
我试过看看http://itextsharp.sourceforge.net/tutorial/index.html,而不是更聪明.
任何指向正确方向的指针都非常感谢:)
我将简单地提出这个问题.
我有这个pdf:
_____
|abcd |
| |
| |
|_____|
Run Code Online (Sandbox Code Playgroud)
还有这个:
_____
|1234 |
|4567 |
| |
|_____|
Run Code Online (Sandbox Code Playgroud)
我想将它们合并以获得:
_____
|abcd |
|1234 |
|4567 |
|_____|
Run Code Online (Sandbox Code Playgroud)
可以使用iTextSharp或任何其他免费工具吗?
提前致谢
我有一个像这样的iTextSharp页脚模板方法:
public PdfTemplate footerTemplate(){
PdfTemplate footer = cb.CreateTemplate(500, 50);
footer.BeginText();
BaseFont bf2 = BaseFont.CreateFont(BaseFont.TIMES_ITALIC, "windows-1254", BaseFont.NOT_EMBEDDED);
footer.SetFontAndSize(bf2, 11);
footer.SetColorStroke(BaseColor.DARK_GRAY);
footer.SetColorFill(BaseColor.GRAY);
int al = -200;
int v = 45 - 15;
float widthoftext = 500.0f - bf2.GetWidthPoint(footerOneLine[0], 11);
footer.ShowTextAligned(al, footerOneLine[0], widthoftext, v, 0);
footer.EndText();
return footer;
}
Run Code Online (Sandbox Code Playgroud)
footerTemplate()正在获取这样的字符串:
footerOneLine.Add("<b>All this line is bold, and <u>this is bold and underlined</u></b>");
Run Code Online (Sandbox Code Playgroud)
我有一个其他方法使字符串HTML.方法是:
private Paragraph CreateSimpleHtmlParagraph(String text) {
//Our return object
Paragraph p = new Paragraph();
//ParseToList requires a StreamReader instead of just text …Run Code Online (Sandbox Code Playgroud) 我已经创建了一个包含图形的pdf文件,现在我正在尝试在这些图形下添加一个表.我的问题是表格是在图形上,我如何指定我希望我的表格放在pdf文档上的位置/位置?
这是我的代码
docl.Open();
docl.Add(new Paragraph("My first PDF file"));
PdfContentByte cb = writer.DirectContent;
//employee
// position y,position x,length,height, unknown
cb.RoundRectangle( 20f, 745f, 200f, 35f, 10f);
//title
cb.RoundRectangle(235f, 745f, 35f, 35f, 10f);
//identity number
cb.RoundRectangle(280f, 745f, 105f, 35f, 10f);
//date of birth
cb.RoundRectangle(390f, 745f, 105f, 35f, 10f);
//employee number
cb.RoundRectangle(500f, 745f, 105f, 35f, 10f);
//address
cb.RoundRectangle(20f, 660f, 200f, 80f, 10f);
//pay method
cb.RoundRectangle(235f, 700f, 35f, 35f, 10f);
//brantch code
cb.RoundRectangle(235f, 660f, 35f, 35f, 10f);
//bank
cb.RoundRectangle(280f, 700f, 215f, 35f, 10f);
//account type …Run Code Online (Sandbox Code Playgroud) 是否有可能使用iTextSharp获取pdf文档指定区域中包含的所有文本?

谢谢.
我必须创建一个带有两个表的pdf文件。并且这两张桌子应该水平放置在文档中。我已经尝试过这样,
var doc1 = new Document(PageSize.A4);
PdfWriter.GetInstance(doc1, new FileStream(path + "/" + pdf_name + "", FileMode.Create));
doc1.Open();
var table1 = new PdfPTable(1); //table1
table1.HorizontalAlignment = Element.ALIGN_LEFT;
table1.SpacingBefore = 50;
table1.DefaultCell.Border = 1;
table1.WidthPercentage = 40;
PdfPCell cell = new PdfPCell(new Phrase(student_name, boldTableFont));
// cell.Border = 1;
// cell.HorizontalAlignment = 1; //0=Left, 1=Centre, 2=Right
cell.HorizontalAlignment = Element.ALIGN_CENTER;
table1.AddCell(cell);
doc1.Add(table1);
var table2= new PdfPTable(1); //table2
table2.DefaultCell.Border = 1;
table2.HorizontalAlignment = 2;
table2.SpacingBefore = 50;
table2.WidthPercentage = 40;
PdfPCell cell21 = new PdfPCell(new …Run Code Online (Sandbox Code Playgroud) 我有这个代码:
private static byte[] ConvertPdfDocument(Document document, PdfPTable headerTable, PdfPTable affidavitsTable)
{
byte[] b;
using (MemoryStream ms = new MemoryStream())
{
PdfWriter writer = PdfWriter.GetInstance(document, ms);
if (document.IsOpen() == false)
{
document.Open();
}
document.Add(headerTable);
document.Add(affidavitsTable);
document.Close();
writer.Close();
b = ms.ToArray();
}
return b;
}
Run Code Online (Sandbox Code Playgroud)
打开"document"对象(document.Open()在此方法之外使用,然后传入.
条件document.IsOpen()评估为True.通过查看调试器中"document"对象的私有属性,我进一步确认文档实际上是打开的; 它表明"开放"是"真实的".
因此,执行移动到该document.Add(headerTable)行.
并且在那时抛出异常:"文档未打开." 虽然调试器已停止(由于抛出异常),但使用上述相同的两种方法,我仍然可以看到文档是打开的.
怎么会这样?
我已经谷歌搜索了一段时间但找不到任何东西,除了这里发布的相同问题没有答案...
任何帮助将不胜感激.
非常感谢,Eliezer