问题
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 :
paragraph 1:
text text text text end .-------------------
paragraph 2:
text text text text end .-------------------
etc.
Is it possible?
回答1:
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.
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();
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.
来源:https://stackoverflow.com/questions/38236515/it-is-possible-with-itext-5-which-at-the-end-of-a-paragraph-justified-the-remain