Índice
Índice |
---|
outline | true |
---|
style | none |
---|
exclude | .*ndice |
---|
|
Document View
By definition, the internal view at at TOTVS Fluig Platform supports the formats for documents, images, texts and PDF extension. However, there are cases where it is necessary that the Viewer be supported for other document formats, such as spreadsheets, DWG files, etc.
In order to ease the integration with different formats, TOTVS Fluig Platform has customization points that allows any file format to be supported in the internal viewer as long as there is any tool available to perform the conversion of the desired format to the PDF format.
The documents must have a copy in the PDF 1.4 format to be internally viewed in TOTVS Fluig Platform, whose specification is in http://www.adobe.com/devnet/pdf/pdf_reference_archive.html
TOTVS Fluig Platform makes the automatic conversion to PDF with text documents supported by Microsoft® Word or OpenOffice.org™. For other types, if one wishes to use them in the internal viewer, a conversion plugin for PDF must be built.
...
This chapter will present an example of a converter for text (.txt) files to PDF, in order to use the internal viewer on TOTVS Fluig Platform.
Informações |
---|
|
Please download the following codes: ECMExternalConvertion-project.zip |
...
Deck of Cards |
---|
effectDuration | 0.5 |
---|
history | false |
---|
id | samples | history |
---|
false | effectType | fade |
---|
|
Card |
---|
default | true |
---|
id | 1 |
---|
label | Step 1 |
---|
| |
Part 1: Building the Message-Driven EJBCreate a Message-Driven that listens to the topic/wdkDocument topic: Find example source below:
| codejava | theme | Eclipse |
---|
languagefirstline | java1 |
---|
title | TxtMessageBean.java | firstline | 1 |
---|
linenumbers | true |
---|
| package com.fluig.conv;
import javax.ejb.ActivationConfigProperty;
import javax.ejb.MessageDriven;
import javax.jms.Message;
import javax.jms.MessageListener;
@MessageDriven(name = "test/TxtConverter", activationConfig = {
@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Topic"),
@ActivationConfigProperty(propertyName = "destination", propertyValue = "topic/wdkDocument")
})
public class TxtMessageBean implements MessageListener {
@Override
public void onMessage(Message message) {
try {
String event = message.getStringProperty("event");
if (event != null && event.equals("EXTERNALCONVERTION")) {
String doc = message.getStringProperty("documentpath");
if (doc != null && doc.endsWith(".txt")) {
ProcessBuilder pb = new ProcessBuilder("txt2pdf.exe", doc, doc + ".pdf", "-lpp40");
pb.start();
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
} |
The Message-Driven above configures the destinationType property for "javax.jms.Topic" to indicate that it will listen to a JMS topic, and the destination property to"topic/wdkDocument" to indicate which topic will be listened to. The "topic/wdkDocument" topic is where the document publishing events are sent to. Upon receiving a message, the type of published event must be checked through the StringProperty "event"; if the value of this property is "EXTERNALCONVERTION", it means that TOTVS Fluig Platform is indicating that this is the time for the customized conversion to take place. In order to obtain the document path, check the StringProperty "documentpath". After this, the file extension must be checked to validate if this is the correct converter, because there may be more than one converter for different extensions. Once the parameters are validated, the converter program can be called; in the example, the txt2pdf http://www.verypdf.com/txt2pdf/ freeware was used. The target document must have the same name plus the .pdf extension, and it should be in the same directory. Ex: doc.txt converted: doc.txt.pdf It is important to remember that the source document may not be modified, with the penalty of TOTVS Fluig Platform indicating that it has been externally changed (CRC validation). This Message-Driven must be packed and deployed on the application server according to Java™ EE specifications.
|
Card |
---|
| |
Part 2: Message-Driven for the creation of long-term documentsThe Message-Driven presented in the previous item can be used in the creation of long-term documents, with a few changes being necessary. In order to know if the Message-Driven is being used for the creation of a long-term file, there is a new parameter called "isLongTerm", this parameter is a String, and if it is "true", the document it wants to generate is a PDF/A, considered a long-term file. TOTVS Fluig Platform considers only the PDF/A format as the one possible to generate long-term documents via Message-Driven. In order to identify the creation of a long-term file, the physical name of the document should be changed, including the string "PDFA" at the end of the file name. For example, if the file name is manual.txt, the name of this file after conversion will be manual.txtPDFA.pdf. See the example below showing the changes needed in Message-Driven to create the long-term document:
| codejava | theme | Eclipse | language | java |
---|
firstline | 1 |
---|
linenumbers | true |
---|
| String longTerm = message.getStringProperty("isLongTerm");
if (doc != null && doc.endsWith(".txt")) {
if (longTerm != null && longTerm.equals("true")) {
String documentName = doc + "PDFA.pdf";
//Call the conversion method for PDF/A
}
} |
On the first line, the parameter value "isLongTerm" is recovered to know if the creation of a long-term file is being requested. After checking the document extension, the longTerm variable value is checked. If it is not null and is "true", then the creation can be performed by calling the document conversion method using for such the file name with the "PDFA.pdf" string.
|
Card |
---|
| In Fluig Studio, right-click the events folder, select the New option and then the Fluig Global Event option:
Image Modified
The New Event wizard is opened. Select the addDocumentConvertionExt event and then click on the Finish button. ![evento-studio2.png](/plugins/servlet/confluence/placeholder/unknown-attachment?locale=pt_BR&version=2)
The event is added to the project in the events folder and opened for editing. The objective of this global event is to add the extensions with a custom converter. In this example, it is necessary to add the txt extension, as seen in the source below: Bloco de código |
---|
language | javascript |
---|
theme | Eclipse |
---|
languagefirstline | javascript1 |
---|
title | addDocumentConvertionExt.js | firstline | 1 |
---|
linenumbers | true |
---|
| function addDocumentConvertionExt(ext) {
ext.add("txt");
} |
Nota |
---|
Attention: For printing published documents with the option "Update Controlled Copy Properties?" the external converter will NOT be used. Since it is necessary to apply the controlled copy properties to the original document and perform a new conversion, this process can only be performed at the execution time with the product standard converter. Therefore, in the printing of documents, format can be lost depending on the visual resources applied in its content (borders, colors, images, etc).. |
|
Card |
---|
| |
Part 4: Add the listener to the Fluig serverPack the JMS listener and add it to <SERVER FLUIG>/jboss/apps/.
|
Card |
---|
|
Part 5: Indicate that the document uses internal viewerNow that the .txt extension was recorded as having a customized converter, mark the option "Use Internal Viewer?" in the document publication: Image Modified
|
Card |
---|
| Notes: - In the example provided, integration examples are provided for the previously created Office (Word, Excel and PowerPoint) products.
- In the example provided, an integration example for converting DWG formats using the dwg2pdf tool from the AutoDWG company.
- The conversion codes are only examples, their development and configuration are the responsibility of the developer.
- A packed plugin can be used made available in the attachment. The settings detailed in the guide Java® execution environment, allowing communication between the Fluig server and Office components are necessary for the integration with Microsoft products.
|
|