Well I've been working with PDFBox I still don't understand it at all, but I've read the Documentation, working with fonts, and some other places, but I've found how to get the text from the PDF and it's style, but I'm creating it, not reading it.
I am trying to make something
Like: this (Having bold and normal text on the same line).
I've been using streams:
Not sure if this is all the code needed to help me, 'cause I just joined this project but it had started when I joined.
I would thank you all if you could help me implementing this code or maybe helping me with an idea or source where I could read the solution.
I leave my code here:
public void rCovernoteFooter(PDPageContentStream stream , float x, float y) throws IOException {
y = y-20;
String currentDate = df1.format(new Date());
String[] issues = constants.issued().split("/");
String issued = issues[0] + currentDate + issues[1];
y = rText(stream, x, y, 90, 0, 10, issued, null);
stream.setFont(PDType1Font.TIMES_ROMAN, 8);
y = rText(stream, x, y - 50, 117, 0, 10, constants.terms(), null);
}
public float rText(PDPageContentStream cStream, float x, float y, int col1, int col2, int spc, String data1, String data2) throws IOException {
float y1 = 0f;
float y2 = 0f;
if (data2 == null) {
y = iterate(data1, col1, x, y, spc, cStream);
} else {
y1 = iterate(data1, col1, x, y, spc, cStream);
y2 = iterate(data2, col2, x + 125, y, spc, cStream);
if (y1 >= y2) {
return y2;
} else {
return y1;
}
}
return y;
}
private float iterate(String text, int len, float x, float y, int space, PDPageContentStream stream) throws IOException {
int rowHeight = 0;
List<String> wordList = Lists.newArrayList();
wordList = wordLines(text, len);
stream.setFont(PDType1Font.TIMES_BOLD, 10);
for (String word : wordList) {
stream.beginText();
stream.moveTextPositionByAmount(x, y - rowHeight);
stream.drawString(word);
stream.endText();
if (wordList.size() != 1)
rowHeight = rowHeight + 10;
}
if (rowHeight >= space) {
y = y - (rowHeight + 10);
} else {
y = y - space;
}
return y;
}
Thanks in advice