基于呈现的文本大小文本分页 [英] Paginate text based on rendered text size
问题描述
背景:我要呈现的文本成PDF,使用的 PDFDocument 框架。这个框架需要你手动分页。该文本将在长度多页,所以我需要一旦超出页面大小来分割文本
问题:的每一页是540x720px **的大小。所以基本上,我需要弄清楚如何在每个点分割的长字符串,它会填满一个540x720px 的TextView
。
潜在哈克:的重写的TextView的onMeasure方法,并使用循环直到超过720像素的长度不断添加文字和重新测量
有没有更好的解决这个?
结果搜索结果
** 540x720px基于8.5x11纸0.5的利润,72dpi的
解决方案
A PageSplitter
可以作为一个解决这个问题的
<一个href=\"http://stackoverflow.com/questions/20204348/how-to-break-styled-text-into-pages-in-android\">How打破样式文本到Android的页面?
Background: I want to render text into a PDF, using the PDFDocument framework. This framework requires you to do pagination manually. The text will be multiple pages in length, so I need to split the text once it exceeds the page size
Problem: Each page is 540x720px** in size. So basically, I need to figure out how to split a long string at each point that it would fill a 540x720px TextView
.
Potential Hack: Overriding the onMeasure method of the TextView, and using a loop to continuously add text and re-measure until it exceeds 720px length
Is there a better solution to this?
**540x720px based on 8.5x11" paper, 0.5" margins, 72dpi
A PageSplitter
can be used as a solution to this problem. The class can be found in the answer found below
How to break styled text into pages in Android?
这篇关于基于呈现的文本大小文本分页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!