0

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?

Draken
  • 3,134
  • 13
  • 34
  • 54
Marky B
  • 29
  • 7
  • Just curious, why do you want to obtain this? Is it because you want the last line of the paragraph to **_not_** be justified to the right margin? – Lars Kristensen Jul 07 '16 at 06:37
  • I can't think of a single program that I've ever used that does this. Word, InDesign, HTML in general, nothing. The closest I've seen is when someone wants to make a TOC and fill the remaining parts of each line with a character until the page number, but those are lines, not paragraphs. That said, you should be able to measure strings and calculate things probably. – Chris Haas Jul 07 '16 at 14:19
  • thanks for comment, I want it because this format is required by an institution and reports have always done well and yes, the last line of each paragraph must be filled with a solid line or scripts filling justified alignment , greetings . – Marky B Jul 07 '16 at 17:46

1 Answers1

0

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:

enter image description here

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.

Bruno Lowagie
  • 75,994
  • 9
  • 109
  • 165