首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Aspose.PDF如何将PDF页面上的文本替换为所有大写

Aspose.PDF如何将PDF页面上的文本替换为所有大写
EN

Stack Overflow用户
提问于 2016-03-25 21:16:40
回答 1查看 1.7K关注 0票数 1

我试图使用Aspose.PDF for .Net将特定页面上的文本替换为大写。如果有人能提供任何帮助,那就太好了。谢谢。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-03-29 04:50:32

我的名字是蒂拉尔·艾哈迈德,我是阿斯坡公司的一名开发人员。

您可以使用文档链接搜索和替换PDF文档的特定页面上的文本。您应该按照文档底部的建议,调用特定页面索引的Accept方法。此外,要用大写字母替换文本,可以使用String对象的ToUpper()方法,如下所示。

代码语言:javascript
复制
....
textFragment.Text = textFragment.Text.ToUpper();
....

编辑:在特定PDF页面上更改文本大小写的示例代码

代码语言:javascript
复制
//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");
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/36228174

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档