Árvore de páginas

Versões comparadas

Chave

  • Esta linha foi adicionada.
  • Esta linha foi removida.
  • A formatação mudou.

Índice

Índice
outlinetrue
exclude.*ndice
stylenone


Document View

By definition, the internal view 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.

Necessary Knowledge

In order to build a converter, it is necessary to have the following skills:

  • Java ™ EE Technology
  • JavaScript Language

Construction of a Converter

The conversion plugin is made of two parts:

  1. A Message-Driven EJB component to receive the conversion request;
  2. Application/program that will convert it;
  3. Indicate that the document uses the internal viewer

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
titleImportante

Please download the following codes:

ECMExternalConvertion-project.zip



Deck of Cards
effectDuration0.5
historyfalse
idsamples
effectTypefade
Card
defaulttrue
id1
labelStep 1


Part 1: Building the Message-Driven EJB

Create a Message-Driven that listens to the topic/wdkDocument topic: Find example source below:


Bloco de código
languagejava
themeEclipse
firstline1
titleTxtMessageBean.java
linenumberstrue
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
id2
labelStep 2


Part 2: Message-Driven for the creation of long-term documents

The 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:


Bloco de código
languagejava
themeEclipse
firstline1
linenumberstrue
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
id3
labelStep 3

Part 3: Registering the converter at TOTVS Fluig Platform

In Fluig Studio, right-click the events folder, select the New option and then the Fluig Global Event option:


Image Added


The New Event wizard is opened. Select the addDocumentConvertionExt event and then click on the Finish button.

Image Added

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
languagejavascript
themeEclipse
firstline1
titleaddDocumentConvertionExt.js
linenumberstrue
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
id4
labelStep 4


Part 4: Add the listener to the Fluig server

Pack the JMS listener and add it to <SERVER FLUIG>/jboss/apps/.

Image Added 





Card
id5
labelStep 5


Part 5: Indicate that the document uses internal viewer

Now that the .txt extension was recorded as having a customized converter, mark the option "Use Internal Viewer?" in the document publication:

Image Added




Card
id6
labelObservation

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.
HTML
<div id="main-content" class="wiki-content group"> <h1 id="ConversoresdeDocumentos-Índice">Índice</h1> <p>&#160;</p> <p> <style type='text/css'>/*<![CDATA[*/ div.rbtoc1412695505262 { padding: 0px; } div.rbtoc1412695505262 ul { list-style: none; margin-left: 0px; } div.rbtoc1412695505262 li { margin-left: 0px; padding-left: 0px; } /*]]>*/ </style> <div class='toc-macro rbtoc1412695505262'> <ul class='toc-indentation'> <li><span class='TOCOutline'>1</span> <a href='#ConversoresdeDocumentos-VisualizaçãodeDocumentos'>Visualización de documentos.</a></li> <li><span class='TOCOutline'>2</span> <a href='#ConversoresdeDocumentos-ConhecimentosNecessários'>Conocimientos necesarios</a></li> <li><span class='TOCOutline'>3</span> <a href='#ConversoresdeDocumentos-ConstruçãodeumConversor'>Construcción de un convertidor </a> <ul class='toc-indentation'> <li><span class='TOCOutline'>3.1</span> <a href='#ConversoresdeDocumentos-Parte1:ConstruindooEJBMessage-Driven'>Parte 1: Construyendo el EJB Message-Driven</a></li> <li><span class='TOCOutline'>3.2</span> <a href='#ConversoresdeDocumentos-Parte2:Message-Drivenparacriaçãodedocumentosdelongoprazo'>parte 2: Message-Driven para la creación de documentos a largo plazo</a></li> <li><span class='TOCOutline'>3.3</span> <a href='#ConversoresdeDocumentos-Parte3:RegistrandooconversornoFluig'>parte 3: Registrando el convertidor en Fluig</a></li> <li><span class='TOCOutline'>3.4</span> <a href='#ConversoresdeDocumentos-Parte4:AdicionarolisteneraoservidorFluig'>Parte 4: Añadir el listener al servidor Fluig</a></li> <li><span class='TOCOutline'>3.5</span> <a href='#ConversoresdeDocumentos-Parte5:Indicarqueodocumentoutilizaovisualizadorinterno'>parte 5: Indicar qué documento utiliza el visor interno</a></li> </ul></li> <li><span class='TOCOutline'>4</span> <a href='#ConversoresdeDocumentos-ThirdPartyTrademarks'>Third Party Trademarks</a></li> </ul> </div> </p> <h1 id="ConversoresdeDocumentos-VisualizaçãodeDocumentos">Visualización de documentos.</h1> <p>De forma predeterminada, el visor interno de Fluig soporta los formatos de documentos de imágenes, textos y documentos de extensión PDF. Sin embargo, hay casos en los cuales es necesario que el visualizador sea soportado en otros formatos de documentos como planillas DWG, etc.</p> <p>Con el fin de facilitar la integración con distintos formatos, Fluig cuenta con puntos de personalización que permiten que cualquier formato de archivo sea soportado por el visualizador interno, ya que existe una herramienta que realiza la conversión de formato deseado a formato PDF.</p> <p> Los documentos deben tener una copia en formato PDF 1.4 para visualizar internamente en Fluig, cuya especificación está en&#160;<a href="http://www.adobe.com/devnet/pdf/pdf_reference_archive.html" style="font-size: 10.0pt; line-height: 13.0pt;" class="external-link" rel="nofollow">http://www.adobe.com/devnet/pdf/pdf_reference_archive.html</a> </p> <p>Fluig hace la conversión automática a PDF con los documentos de texto que soporta Microsoft ® Word u OpenOffice.org ™. Para otros tipos, si se desea utilizar el visualizador interno, se debe armar un plugin para la conversión a PDF.</p> <h1 id="ConversoresdeDocumentos-ConhecimentosNecessários">Conocimientos Necesarios</h1> <p>Para construir un convertidor es necesario poseer los siguientes conocimientos:</p> <ul> <li>Tecnología&#160;<span style="font-size: 10.0pt; font-family: Arial, sans-serif;">™ Java EE</span></li> <li><span style="font-size: 10.0pt; font-family: Arial, sans-serif;">Lenguaje JavaScript</span></li> </ul> <h1 id="ConversoresdeDocumentos-ConstruçãodeumConversor">Construcción de un convertidor</h1> <p> <span style="font-size: 10.0pt; line-height: 13.0pt;">El plugin de conversión se compone de dos partes:</span> </p> <ol> <li>Un componente EJB Message-Driven, para recibir la solicitud de conversión;</li> <li>Aplicación/programa que hará la conversión;</li> <li>Indicar que el documento utiliza el visor interno.</li> </ol> <p>Este capítulo presentará un ejemplo de un convertidor de archivos de texto (txt) a formato PDF, para que usted pueda utilizarlo en el visualizador interno de Fluig.</p> <p>&#160;</p> <div class="aui-message hint shadowed information-macro"> <p class="title">Importante</p> <span class="aui-icon icon-hint">Icon</span> <div class="message-content"> <p>Para ayudarlo, descargue los siguientes códigos:</p> <p> <a href="attachments/73082704/126158185.zip">ECMExternalConvertion-project.zip</a> </p> </div> </div> <p>&#160;</p> <p>&#160;</p> <h3 id="ConversoresdeDocumentos-Parte1:ConstruindooEJBMessage-Driven">Parte 1: Construyendo el EJB Message-Driven</h3> <p class="MsoNormal" style="text-align: justify;"> Crear un Message-Driven que escuche el tema <strong>topic/wdkDocument</strong>: Le mostramos una fuente de ejemplo: </p> <div class="code panel pdl" style="border-width: 1px;"> <div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"> <b>TxtMessageBean.java</b> </div> <div class="codeContent panelContent pdl"> <pre class="first-line: 1; theme: Eclipse; brush: java; gutter: true" style="font-size: 12px;">paquete com.fluig.conv; Import javax.ejb.ActivationConfigProperty; Import javax.ejb.MessageDriven; Import javax.ejb.MessageDriven; Import javax.ejb.MessageDriven; @MessageDriven (nombre = "prueba/TxtConverter', activationConfig = {} @ActivationConfigProperty (propertyName = "destinationType", propertyValue = "javax.jms.Topic"), @ActivationConfigProperty (propertyName = "destinationType", propertyValue = "javax.jms.Topic"), }) public class TxtMessageBean implements MessageListener {} @Override public void onMessage(Message message) { try { String event = message.getStringProperty("event"); if (event != null &amp;&amp; event.equals("EXTERNALCONVERTION")) { String doc = message.getStringProperty("documentpath"); if (doc != null &amp;&amp; doc.endsWith(".txt")) { ProcessBuilder pb = new ProcessBuilder("txt2pdf.exe", doc, doc + ".pdf", "-lpp40"); pb.start(); } } } catch (Exception e) { e. printStackTrace (); } } }</pre> </div> </div> <p class="MsoNormal" style="text-align: justify;"> El Message-Driven anterior configura la propiedad destinationType para <strong>"javax.jms.Topic"</strong>&#160;para indicar que usted escuchará un tema JMS, y la propiedad de destino para <strong>"topic/wdkDocument"</strong> para indicar a qué tema se escuchará. El tema "topic/wdkDocument" es donde se envían los eventos de publicación de documentos. </p> <p class="MsoNormal" style="text-align: justify;"> Al recibir un mensaje, deberá comprobar el tipo de evento publicado por medio de StringProperty "<strong>evento</strong>", si el valor de esta propiedad es <strong>"EXTERNALCONVERTION"</strong>, significa que Fluig indica que es el momento de ejecutar la conversión personalizada. </p> <p class="MsoNormal" style="text-align: justify;"> Para obtener la ruta del documento, Compruebe la StringProperty <strong>"documentpath"</strong>. </p> <p class="MsoNormal" style="text-align: justify;">Después de esto, se comprueba la extensión del para validar si este es el convertidor correcto, porque puede haber más de uno para diferentes extensiones.</p> <p class="MsoNormal" style="text-align: justify;">Cuando se haya validado los parámetros, se puede llamar entonces al programa de conversión, que en el caso del ejemplo, fue utilizado el txt2pdf freeware http://www.verypdf.com/txt2pdf/</p> <p class="MsoNormal" style="text-align: justify;">El documento de destino debe tener el mismo nombre más la extensión .pdf y este deberá quedar en el mismo directorio. Ej: doc.txt convertido: doc.txt.pdf</p> <p class="MsoNormal" style="text-align: justify;">Le recordamos que el documento de origen no podrá ser modificado, con la sanción de que Fluig indique que se ha cambiado externamente (validación de CRC).</p> <p class="MsoNormal" style="text-align: justify;"> <span style="font-size: 10.0pt; line-height: 13.0pt;">Message-Driven deberá empaquetarse e implantarse en el servidor de aplicaciones conforme las especificaciones de Java ™ EE.</span> </p> <p class="MsoNormal" style="text-align: justify;">&#160;</p> <h3 id="ConversoresdeDocumentos-Parte2:Message-Drivenparacriaçãodedocumentosdelongoprazo">Parte 2: Message-Driven para la creación de documentos a largo plazo</h3> <p class="MsoNormal" style="text-align: justify;"> <span style="color: rgb(51, 51, 51); font-size: 10.0pt; font-weight: normal; line-height: 13.0pt;">Se puede utilizar el Mesage-Driven presentado en el punto anterior para la creación de documentos a largo plazo, siendo necesario hacer algunos cambios. Para saber si MEssage-Driven está siendo utilizado para la creación del archivo a largo plazo, hay un nuevo parámetro llamado "isLongTerm", este parámetro es una String, y si es igual a "true" es porque el documento que se desea generar es un PDF/A, considerado como el archivo a largo plazo.</span> </p> <p class="MsoNormal" style="text-align: justify;"> <span style="font-size: 10.0pt; line-height: 13.0pt;">Fluig considera sólo el formato PDF/A como formato posible para generar documentos a largo plazo a través de&#160;</span>Message-Driven<span style="font-size: 10.0pt; line-height: 13.0pt;">.</span> </p> <p class="MsoNormal" style="text-align: justify;"> <span style="font-size: 10.0pt; line-height: 13.0pt;">&#160;</span><span style="font-size: 10.0pt; line-height: 13.0pt;">Para identificar la creación de un archivo a largo plazo, se debe modificar el nombre físico del documento, incluyendo la string "PDFĂ" al final del nombre del archivo. Por ejemplo, si el nombre del archivo es manual.txt, el nombre de este archivo después de la conversión será manual.txtPDFA.pdf. Vea el ejemplo a continuación que ilustra los cambios necesarios en el&#160;</span>Message-Driven<span style="font-size: 10.0pt; line-height: 13.0pt;">&#160;para crear el documento a largo plazo:</span> </p> <div class="code panel pdl" style="border-width: 1px;"> <div class="codeContent panelContent pdl"> <pre class="first-line: 1; theme: Eclipse; brush: java; gutter: true" style="font-size: 12px;">String longTerm = message.getStringProperty("isLongTerm"); if (doc != null &amp;&amp; doc.endsWith(".txt")) { if (longTerm != null &amp;&amp; longTerm.equals("true")) { String documentName = doc + "PDFA.pdf"; //llamar al método de conversión para PDF/A } }</pre> </div> </div> <p class="MsoNormal" style="text-align: justify;">En la primera línea se recupera el valor del parámetro "isLongTerm" para saber si se necesita la creación de un archivo a largo plazo. Después de haber comprobado la extensión del documento, se comprueba el valor de la variable longTerm, si esta no es nula y es igual a "true", entonces creamos mediante el llamado del método de conversión de documentos utilizando el nombre del archivo con string "PDFA.pdf".</p> <p class="MsoNormal" style="text-align: justify;">&#160;</p> <h3 id="ConversoresdeDocumentos-Parte3:RegistrandooconversornoFluig">Parte 3: Registrando el convertidor en Fluig</h3> <p>En Fluig Studio, haga clic con el botón derecho del mousse en la carpeta eventos, seleccionar la opción New, y luego la opción Evento Global Fluig:</p> <p> <img class="confluence-embedded-image confluence-content-image-border" height="329" width="655" src="http://tdn.totvs.com/plugins/servlet/confluence/placeholder/unknown-attachment?locale=pt_BR&version=2" data-image-src="http://tdn.totvs.com/plugins/servlet/confluence/placeholder/unknown-attachment?locale=pt_BR&version=2"> </p> <p> El asistente Evento Nuevo se abre. Selecione el evento&#160;<strong>addDocumentConvertionExt&#160;</strong>y luego haga clic en el botón Finish. </p> <p> <img class="confluence-embedded-image" src="http://tdn.totvs.com/plugins/servlet/confluence/placeholder/unknown-attachment?locale=pt_BR&version=2" data-image-src="http://tdn.totvs.com/plugins/servlet/confluence/placeholder/unknown-attachment?locale=pt_BR&version=2"> </p> <p>El evento se agregará al proyecto en copiar eventos y se abrirá para la edición.&#160;El objetivo de este evento global es agregar las extensiones que tienen un convertidor personalizado. En este ejemplo es necesario añadir la extensión txt, conforme la fuente a continuación:</p> <div class="code panel pdl" style="border-width: 1px;"> <div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"> <b>addDocumentConvertionExt.js</b> </div> <div class="codeContent panelContent pdl"> <pre class="first-line: 1; theme: Eclipse; brush: javascript; gutter: true" style="font-size: 12px;">function addDocumentConvertionExt(ext) { ext.Add ("txt"); }</pre> </div> </div> <div class="aui-message warning shadowed information-macro"> <span class="aui-icon icon-warning">Icon</span> <div class="message-content"> <p> <strong>Atención: </strong>Para la impresión de los documentos publicados con la opción "Actualizar Propiedades de la Copia Controlada?" <strong>NO</strong> se utilizará el convertidor externo. Como es necesario aplicar las propiedades de la copia controlada del documento original y realizar una nueva conversión, este proceso se puede realizar en tiempo de ejecución con el convertidor estándar de producto. Por lo tanto, en la impresión del documento, puede experimentar la pérdida de formateo dependiendo de recursos visuales aplicados en su contenido (bordes, colores, imágenes, etc.). </p> </div> </div> <p class="MsoNormal" style="text-align: justify;">&#160;</p> <h3 id="ConversoresdeDocumentos-Parte4:AdicionarolisteneraoservidorFluig">Parte 4: Añadir el listener en al servidor Fluig</h3> <p> <span style="color: rgb(51, 51, 51); font-size: 10.0pt; font-weight: normal; line-height: 13.0pt;">Paquete del </span><em style="color: rgb(51, 51, 51); font-size: 10.0pt; font-weight: normal; line-height: 13.0pt;">listener </em><span style="color: rgb(51, 51, 51); font-size: 10.0pt; font-weight: normal; line-height: 13.0pt;">JMS y el agregado en &lt; > SERVER FLUIG/jboss/apps /.</span> </p> <p style="text-align: center;"> <img class="confluence-embedded-image image-left" src="http://tdn.totvs.com/plugins/servlet/confluence/placeholder/unknown-attachment?locale=pt_BR&version=2" data-image-src="http://tdn.totvs.com/plugins/servlet/confluence/placeholder/unknown-attachment?locale=pt_BR&version=2">&#160; </p> <p style="text-align: center;">&#160;</p> <p style="text-align: center;">&#160;</p> <p>&#160;</p> <h3 id="ConversoresdeDocumentos-Parte5:Indicarqueodocumentoutilizaovisualizadorinterno">Parte 5: Indicar qué documento utiliza el visor interno</h3> <p>Ahora que la extensión .txt se registró como poseedora de un convertidor personalizado, simplemente marque la opción "¿Utiliza visualizador interno?" en la publicación del documento:</p> <p> <img class="confluence-embedded-image" width="500" src="http://tdn.totvs.com/plugins/servlet/confluence/placeholder/unknown-attachment?locale=pt_BR&version=2" data-image-src="http://tdn.totvs.com/plugins/servlet/confluence/placeholder/unknown-attachment?locale=pt_BR&version=2"> </p> <p>&#160;</p> <p>OBSERVACIONES</p> <ul> <li>En el ejemplo proporcionado, se presentan ejemplos de integraciones con los productos <em>Office (Word, Excel y PowerPoint)</em> creados anteriormente. </li> <li>En el ejemplo proporcionado, se presenta un ejemplo de integración de conversión de formatos <em>DWG</em> utilizando la herramienta <em>dwg2pdf </em> de la empresa <em>AutoDWG</em>. </li> <li>Los códigos de conversión son sólo ejemplos, su desarrollo y configuración es responsabilidad del desarrollador.</li> <li>Puede utilizar el <em>plugin<strong> </strong></em>empaquetado disponible en el anexo. Para la integración con productos de Microsoft se requiere de ajustes detallados en el <a href="75271469.html">ambiente de ejecución de Java ®</a>, permitiendo la comunicación entre el servidor Fluig y los componentes de <em>Office</em>. </li> </ul> </div>