我试图使用Aspose.PDF for .Net将特定页面上的文本替换为大写。如果有人能提供任何帮助,那就太好了。谢谢。
发布于 2016-03-29 04:50:32
我的名字是蒂拉尔·艾哈迈德,我是阿斯坡公司的一名开发人员。
您可以使用文档链接搜索和替换PDF文档的特定页面上的文本。您应该按照文档底部的建议,调用特定页面索引的Accept方法。此外,要用大写字母替换文本,可以使用String对象的ToUpper()方法,如下所示。
....
textFragment.Text = textFragment.Text.ToUpper();
....编辑:在特定PDF页面上更改文本大小写的示例代码
//open document
Document pdfDocument = new Document(myDir + "testAspose.pdf");
//create TextAbsorber object to find all instances of the input search phrase
TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber("");
//accept the absorber for all the pages
pdfDocument.Pages[2].Accept(textFragmentAbsorber);
//get the extracted text fragments
TextFragmentCollection textFragmentCollection = textFragmentAbsorber.TextFragments;
//loop through the fragments
foreach (TextFragment textFragment in textFragmentCollection)
{
//update text and other properties
textFragment.Text = textFragment.Text.ToUpper();
}
pdfDocument.Save(myDir+"replacetext_output.pdf");https://stackoverflow.com/questions/36228174
复制相似问题