itext java_使用Java和Itext编辑PDF文本

本文探讨了PDF作为显示格式而非编辑格式的特点,解释了为何PDF不适合直接编辑,并通过对比Word文档说明了PDF中字符位置的固定性。作者指出,若要修改PDF,最佳做法是修改源文件并重新生成PDF。此外,文章介绍了如何使用iText库以技能ful的方式操纵PDF页面,将PDF视为数字纸张进行操作。
摘要由CSDN通过智能技术生成

When I wrote the first book about iText, the publisher didn’t like the

subtitle “Creating and Manipulating PDF.” He didn’t like the word

manipulating because of some of its pejorative meanings. If you consult the dictionary on Yahoo! education, you’ll find the

following definitions: To influence or manage shrewdly or deviously To tamper with or falsify for personal gain

Obviously, that’s not what the book is about. The publisher suggested

“Creating and Editing PDF” as a better subtitle. I explained that

PDF isn’t a document format well suited for editing. PDF is an end

product. It’s a display format. It’s not a word processing

format.

In a word processing format, the content is distributed over different

pages when you open the document in an application, not earlier. This

has some disadvantages: if you open the same document in different

applications, you can end up with a different page count. The same

text snippet can be on page X when looked at in Microsoft Word, and

on page Y when viewed in Open Office. That’s exactly the kind of

problem you want to avoid by choosing PDF.

In a PDF document, every character or glyph on a PDF page has its

fixed position, regardless of the application that’s used to view the

document. This is an advantage, but it also comes with a disadvantage.

Suppose you want to replace the word “edit” with the word “manipulate”

in a sentence, you’d have to reflow the text. You’d have to reposition

all the characters that follow that word. Maybe you’d even have to

move a portion of the text to the next page. That’s not trivial, if

not impossible.

If you want to “edit” a PDF, it’s advised that you change the original

source of the document and remake the PDF. If the original document

was written using Microsoft Word, change the Word document, and make

the PDF from the new version of the Word document. Don’t expect any

tool to be able to edit a PDF file the same way you’d edit a Word

document.

This being said, the verb “to manipulate” also means To move, arrange, operate, or control by the hands or by mechanical means, especially in a skillful manner

That’s exactly what you’re going to do in this chapter. Using iText,

you’re going to manipulate the pages of a PDF file in a skillful

manner. You’re going to treat a PDF document as if it were made of

digital paper.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值