有可能使用itext 5,在段落末尾对齐剩余的空间是用脚本填充的吗? [英] It is possible with itext 5 which at the end of a paragraph justified the remaining space is filled with scripts?

查看:207
本文介绍了有可能使用itext 5,在段落末尾对齐剩余的空间是用脚本填充的吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在android studio上制作应用程序并使用itext pdf 5,我希望每次你完成一个段落时,缺少的空间都会填充脚本,即:

I am making an application on android studio and use itext pdf 5, I want every time you finish a paragraph the missing space is filled with scripts, ie :

第1段:

text text text text end .-------------------

第2段:

text text text text end .-------------------

等。

有可能吗?

推荐答案

虽然你的问题还远未明确(当你写缺少的空间时,你的意思是什么是脚本?什么是脚本?),我将假设你想要这样的东西:

Although your question is far from clear (what do you mean when you write the missing space is filled with scripts? what are scripts?), I'm going to assume that you want something like this:

那里在官方网站上有很多涉及分隔符的例子。请参阅标题为分隔符示例的部分。

There are plenty of examples on the official web site that involve separators. See the section entitled Separator examples.

屏幕截图中的PDF创建如下:

The PDF in the screen shot was created like this:

Document document = new Document();
PdfWriter.getInstance(document, new FileOutputStream(dest));
document.open();
DottedLineSeparator separator = new DottedLineSeparator();
Chunk c = new Chunk(separator);
Paragraph p = new Paragraph("Ends with dots ");
p.add(c);
document.add(p);
p = new Paragraph("This is a much longer paragraph that spans "
    + "several lines. The String used to create this paragraph "
    + "will be split automatically at the end of the line. The "
    + "final line of this paragraph will end in a dotted line. ");
p.add(c);
document.add(p);
document.close();

如果单词 scripts 表示其他内容,例如,如果您打算说破折号,你应该使用另一种类型的分隔符。例如,请参阅问题的答案如何创建自定义虚线行分隔符?在该示例中创建的自定义 LineSeparator 也可以包装在和那个块中可用于将段落扩展到行尾。您可以通过调整 y 坐标来上下移动该行。

If the word scripts means something else, for instance if you meant to say dashes, you should use another type of separator. See for instance the answer to the question How to create a custom dashed line separator? The custom LineSeparator created in that example can also be wrapped in a Chunk and that chunk can be used to extend the paragraph until the end of the line. You can move that line up and down by tweaking the y coordinate.

这篇关于有可能使用itext 5,在段落末尾对齐剩余的空间是用脚本填充的吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆