XMLWorkerHelper not transfer all text to the PDF document - java

i have a problem with converting html output from creditor to my pdf.
I use the XMLWorkerHelper.parseToElementList method to read out the database field with the html code of the ckeditor, but not all of the content are rendered in the pdf document.
I figure out that its only affects elements of type 10 (CHUNK, if i'm right) and the content of this chunk is empty, if i print it to the console.
I reconfigure ckeditor to use <br/> instead of <p>-tags
Here an example of an html code from ckeditor:
MS Office (Word, Excel, PowerPoint)<br/>SAP<br/>Adobe Photoshop<br/>IBM SPSS Statistics<br/>EFS Survey<br/>CMS<br/>
or
Kernfach: Sozialwissenschaft<br />
Note: <u><strong>1,7</strong></u><br />
<br />
Nebenfach: Rechtswissenschaft<br />
Note: <u><strong>2,3</strong></u><br />
<br />
<br />
Abschluss: <strong>Bachelor of Arts</strong><br />
<br />
Abschlussnote: <strong><u>1,9</u></strong>
Only the text between the tags are rendered, the other/normal text are ignored
Is this a problem of misconfiguration or do i have modify the content before pass it to the XMLWorkerHelper?
i'm thankful for tips to solve my problem.
regards
Rizzi

Related

How to get the corresponding value of a key from excel sheet in xslt

I have an xml having the image tag
I need to get the image name first which is s00122.png here . Then there is one excel sheet where we have href corresponding to src's image. then we need to extract the href and replace the src with href attribute.
Input :
<content type="text/html" title="begin"><body>
<p>
<strong>begin</strong>—Display the command output beginning with the line that contains the specified string. The string is case-sensitive.</p>
<div mt-section-origin="Product_Documentation/Command_Reference/Command_Filters_for_CLI_Operational_Commands/begin" class="mt-section" id="section_1"><span id="Command_Syntax"></span>
<h2 class="editable">Command Syntax</h2>
<img alt="s00122.png" class="internal default" src="https://sdwan-docs.cisco.com/#api/deki/files/1455/s00122.png?revision=6"/>
<p><strong>begin</strong> <em>string</em></p> </div>
</body>
</content>
Output will be :
<content type="text/html" title="begin"><body>
<p>
<strong>begin</strong>—Display the command output beginning with the line that contains the specified string. The string is case-sensitive.</p>
<div mt-section-origin="Product_Documentation/Command_Reference/Command_Filters_for_CLI_Operational_Commands/begin" class="mt-section" id="section_1"><span id="Command_Syntax"></span>
<h2 class="editable">Command Syntax</h2>
<image href="ashttp://rtp-aspw-ccms1.cisco.com/astoria/_id_0000001aWIA40058D40GYZ_368137.jpg"/>
<p><strong>begin</strong> <em>string</em></p> </div>
</body>
</content>
What would be the best way to achieve this.
Please suggest.
Getting the attribute value from XML:
You can use XPath for getting value of a specific attribute in XML. Refer to the SO Post How to get attribute value using XPath in Java? for details on how to do this.
Reading the excel sheet:
There are many Java libraries that allow you to read the excel files. I would suggest using Apache POI HSSF. Refer to one more SO post How to read and write excel file for details on how to read a excel sheet. I would advise to read the excel sheet when the application is initialized and cache the values for better performance.
Hope this helps.

Thymeleaf #strings.replace with regex and th:fragment

I have persisted entity with field text. Inside text I have part to replace. myEntity.text:
some text
twoImages[12_v13.PNG, 10_v6.PNG]
text text text
twoImages[12_v13.PNG, 10_v6.PNG]
<h1>And HTML</h1>
So in view I want to use something like th:utext. But with replaced images blocks with th:fragment (~15 lines per fragment).
Output should be like this:
some text
<img .. 12_v13.PNG />
<br />
<img .. 12_v13.PNG />
<additional html />
text text text
<img .. 12_v13.PNG />
<br />
<img .. 12_v13.PNG />
<additional html />
<h1>And HTML</h1>
How to realize this with Thymeleaf?
If the entire text of the field is a single string, you will have to parse it using regex matcher or some generated parser. Say [12_v13.PNG, 10_v6.PNG] has to be parsed e.g. with
\\[([^,]),\\s([^\\]]*)]
The first group will give 12_v13.PNG, the second one - 10_v6.PNG.
You need to provide the path to each of the images in src property of img tag.
You can achieve the result this way:
<img th:src="#{/images/test.png}" />
It is implied, that /images folder is within webapp folder of your project.
<img th:src="#{/resources/images/Picture.png}" />
Output as:
<img src="/resources/image/Picture.png" />
When you hit http://localhost:8080/myapp/resources/images/Picture.png in you browser then you should be able to access the image for the above syntax to work.
This link is useful: Standard URL Syntax
Please have a look at my thymeleaf demo project: demo project (the folder with templates will get opened) You'll find data on project structure and examples of thymeleaf templates.

Language.properties file in Liferay

I want to support multiple languages for my portlet application. So I:
Created content package in src folder.
Created Language.properties file with string Book-Name=Book Name
Paste this line
<supported-locale>es</supported-locale>
<resource-bundle>content/Language</resource-bundle>
in portlet.xml file.
So could you please tell me why I still have Book-Name here?!
<liferay-ui:search-container>
<liferay-ui:search-container-results results="${bookListArray}" />
<liferay-ui:search-container-row className="com.softwerke.model.Book" modelVar="aBook">
<liferay-ui:search-container-column-text property="bookName" name="Book-Name"/>
<liferay-ui:search-container-column-text property="bookDescription" name="Description"/>
<liferay-ui:search-container-column-jsp path="/html/action.jsp" align="right" />
</liferay-ui:search-container-row>
<liferay-ui:search-iterator />
</liferay-ui:search-container>
UPDATE
This:
<liferay-ui:search-container-column-text property="bookName" name="${bookName}" />
....
<c:set var="bookName"> <liferay-ui:message key="book-Name" /> </c:set>
does NOT work too
You are not using it at all.
The name="Book-Name" in this line
<liferay-ui:search-container-column-text property="bookName" name="Book-Name"/>
adds name property to this html component with valye defined inside the quotation marks to make this value the one defined in the properties file you have to use <liferay-ui:message /> tag in your case it would be:
:
<liferay-ui:search-container-column-text property="bookName" name="<liferay-ui:message key="Book-Name" />"/>
Also it is not relevant but a dev practice that the language key is all lower case.

importing content into jsf h:inputTextarea

We are currently converting a Spring mvc/jsp app into a jsf app.
Previously we could import the content of a JSP segment file into a text area like this
<textarea id="sectionSixPointOne" name="sectionSixPointOne">
<jsp:include page="sect_six_point_one.jspf"/>
</textarea>
Magically the content of the jsp appeared into the content of the text area.
We are trying to do the same with JSF, but I am about ready to shoot myself in the face.
We've tried
<h:inputTextarea id="sectionSixPointOne">
<ui:include src="section_six_sect_one.xhtml"/>
</h:inputTextarea>
But it includes the content after the textarea not inside it.
I have tried to include the content of as the value parameter of h:inputTextarea but the compiler gets it's knickers in a knot about the syntax/quotes/anglebrackets etc.
<h:inputTextarea id="sectionSixPointOne" value=<ui:include src="section_six_sect_one.xhtml"/>
</h:inputTextarea>
I would much rather include the content directly in the jsf pages rather than mucking about loading it into a backing bean.
Anyone got any ideas can what I want to do be done with jsf (apologies for any idiocy I am a total JSF newb?
Just put the <h:inputTextarea id="sectionSixPointOne"> with it's value to include in the file you want to include.
That way you don't need to insert it in some component, you just extracted the whole thing into its own file.
So you code looks like:
<ui:include src="section_six_sect_one.xhtml"/>
and in section_six_sect_one.xhtml":
<ui:composition xmlns=... >
<h:inputTextarea id="sectionSixPointOne" value="yourIncludedText"/>
...

Change br margin-bottom in xml like in css

<string name="text">
• Text <br />
• Text2 <br />
• Text3 <br />
</string>
I use this in strings.xml. It works fine, but I want to have more space between text and text2. In css I would just use margin-bottom. Can I do something similar here? I've tried <p></p>, but it has too much space then.
XML is not a language to be displayed just a way of recording data. You could have the data recorded in XML fed into another medium and style it there.

Categories