Skip to content

Commit fd3509b

Browse files
author
Open Lowcode SAS
committed
Close #45
Note that Class to perform rich text print in page band has changed. This is still treated as bug as the old class (PDFPageBandRichTextSection never worked)
1 parent 346fccc commit fd3509b

File tree

3 files changed

+79
-132
lines changed

3 files changed

+79
-132
lines changed

src/org/openlowcode/OLcVersionGenerator.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
*
2727
*/
2828
public class OLcVersionGenerator {
29-
public final static String version = "1.2.0";
30-
public final static String clientversion = "1.2.0";
31-
public final static boolean stable = false;
29+
public final static String version = "1.1.1";
30+
public final static String clientversion = "1.1.1";
31+
public final static boolean stable = true;
3232

3333
public static void main(String[] args) {
3434
try {

src/org/openlowcode/tools/richtext/PDFPageBandRichTextSection.java

Lines changed: 0 additions & 129 deletions
This file was deleted.
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/********************************************************************************
2+
* Copyright (c) 2020 [Open Lowcode SAS](https://openlowcode.com/)
3+
*
4+
* This program and the accompanying materials are made available under the
5+
* terms of the Eclipse Public License 2.0 which is available at
6+
* http://www.eclipse.org/legal/epl-2.0 .
7+
*
8+
* SPDX-License-Identifier: EPL-2.0
9+
********************************************************************************/
10+
11+
package org.openlowcode.tools.richtext;
12+
13+
import java.io.IOException;
14+
import java.util.ArrayList;
15+
16+
import org.openlowcode.tools.pdf.BulletText;
17+
import org.openlowcode.tools.pdf.PDFPageBand;
18+
import org.openlowcode.tools.pdf.PDFPageBandSection;
19+
import org.openlowcode.tools.pdf.ParagraphHeader;
20+
import org.openlowcode.tools.pdf.SectionText;
21+
22+
/**
23+
* An utility to print in a page band a rich text content
24+
*
25+
* @author <a href="https://openlowcode.com/" rel="nofollow">Open Lowcode
26+
* SAS</a>
27+
*
28+
*/
29+
public class PDFPageBandRichTextUtility {
30+
31+
/**
32+
* Inserts in the page band the rich text content
33+
*
34+
* @param pageband page band to print into
35+
* @param sourcetext source text formatted as rich text
36+
* @throws IOException
37+
*/
38+
public static void insertRichTextInPageBand(PDFPageBand pageband,String sourcetext) throws IOException {
39+
PDFPageBandSection[] sectionsforrichtext = PDFPageBandRichTextUtility.generateSectionFromRichText(sourcetext);
40+
if (sectionsforrichtext!=null) for (int i=0;i<sectionsforrichtext.length;i++)
41+
pageband.printNewSection(sectionsforrichtext[i]);
42+
}
43+
44+
/**
45+
* Parses the rich text and generates section for printing
46+
* @param sourcetext source text formatted in rich text
47+
* @return list of page band sections
48+
*/
49+
public static PDFPageBandSection[] generateSectionFromRichText(String sourcetext) {
50+
ArrayList<RichTextSection> structuredtext = RichTextParser.simplifyforblack(RichTextParser.parseText(sourcetext));
51+
return parseSections(structuredtext).toArray(new PDFPageBandSection[0]);
52+
}
53+
54+
55+
private static ArrayList<PDFPageBandSection> parseSections(ArrayList<RichTextSection> structuredtext) {
56+
ArrayList<PDFPageBandSection> sections = new ArrayList<PDFPageBandSection>();
57+
for (int i = 0; i < structuredtext.size(); i++) {
58+
RichTextSection thistextsection = structuredtext.get(i);
59+
if (thistextsection.isNormalText()) {
60+
SectionText thissectiontext = new SectionText(thistextsection.getText());
61+
sections.add(thissectiontext);
62+
}
63+
if (thistextsection.isBullet()) {
64+
BulletText thisbullettext = new BulletText(thistextsection.getText(), 1);
65+
sections.add(thisbullettext);
66+
}
67+
if (thistextsection.isSectiontitle()) {
68+
ParagraphHeader header = new ParagraphHeader(thistextsection.getText());
69+
sections.add(header);
70+
}
71+
72+
}
73+
return sections;
74+
}
75+
}
76+

0 commit comments

Comments
 (0)