Histórico da Página
Índice
Índice | ||||||
---|---|---|---|---|---|---|
|
Document View
By definition, the internal view at Fluig 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, Fluig 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 Fluig, whose specification is in http://www.adobe.com/devnet/pdf/pdf_reference_archive.html
Fluig 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:
- A Message-Driven EJB component to receive the conversion request;
- Application/program that will convert it;
- 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 Fluig.
Informações | ||
---|---|---|
| ||
Please download the following codes: |
Deck of Cards | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
HTML | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
<div id="main-content" class="wiki-content group">
<h1 id="ConversoresdeDocumentos-Índice">Contents</h1>
<p> </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'>Viewing
Documents</a></li>
<li><span class='TOCOutline'>2</span> <a
href='#ConversoresdeDocumentos-ConhecimentosNecessários'>Necessary
Knowledge</a></li>
<li><span class='TOCOutline'>3</span> <a
href='#ConversoresdeDocumentos-ConstruçãodeumConversor'>Construction
of a Converter</a>
<ul class='toc-indentation'>
<li><span class='TOCOutline'>3.1</span> <a
href='#ConversoresdeDocumentos-Parte1:ConstruindooEJBMessage-Driven'>Part
1: Building the Message-Driven EJB</a></li>
<li><span class='TOCOutline'>3.2</span> <a
href='#ConversoresdeDocumentos-Parte2:Message-Drivenparacriaçãodedocumentosdelongoprazo'>Part
2: Message-Driven for the creation of long-term documents</a></li>
<li><span class='TOCOutline'>3.3</span> <a
href='#ConversoresdeDocumentos-Parte3:RegistrandooconversornoFluig'>Part
3: Registering the converter at Fluig</a></li>
<li><span class='TOCOutline'>3.4</span> <a
href='#ConversoresdeDocumentos-Parte4:AdicionarolisteneraoservidorFluig'>Part
4: Add the listener to the Fluig server</a></li>
<li><span class='TOCOutline'>3.5</span> <a
href='#ConversoresdeDocumentos-Parte5:Indicarqueodocumentoutilizaovisualizadorinterno'>Part
5: Indicate that the document uses the internal viewer</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">Document
View</h1>
<p>By definition, the internal view at Fluig 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.</p>
<p>In order to ease the integration with different formats, Fluig
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.</p>
<p>
The documents must have a copy in the PDF 1.4 format to be internally
viewed in Fluig, whose specification is in <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 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.</p>
<h1 id="ConversoresdeDocumentos-ConhecimentosNecessários">Necessary
Knowledge</h1>
<p>In order to build a converter, it is necessary to have the
following skills:</p>
<ul>
<li><span
style="font-size: 10.0pt; font-family: Arial, sans-serif;">Java
™ EE</span> Technology</li>
<li><span
style="font-size: 10.0pt; font-family: Arial, sans-serif;">JavaScript
Language</span></li>
</ul>
<h1 id="ConversoresdeDocumentos-ConstruçãodeumConversor">Construction
of a Converter</h1>
<p>
<span style="font-size: 10.0pt; line-height: 13.0pt;">The
conversion plugin is made of two parts:</span>
</p>
<ol>
<li>A Message-Driven EJB component to receive the conversion
request;</li>
<li>Application/program that will convert it;</li>
<li>Indicate that the document uses the internal viewer</li>
</ol>
<p>This chapter will present an example of a converter for text
(.txt) files to PDF, in order to use the internal viewer on Fluig.</p>
<p> </p>
<div class="aui-message hint shadowed information-macro">
<p class="title">Important</p>
<span class="aui-icon icon-hint">Icon</span>
<div class="message-content">
<p>Please download the following codes:</p>
<p>
<a href="attachments/73082704/126158185.zip">ECMExternalConvertion-project.zip</a>
</p>
</div>
</div>
<p> </p>
<p> </p>
<h3 id="ConversoresdeDocumentos-Parte1:ConstruindooEJBMessage-Driven">Part
1: Building the Message-Driven EJB</h3>
<p class="MsoNormal" style="text-align: justify;">
Create a Message-Driven that listens to the <strong>topic/wdkDocument</strong>
topic: Find example source below:
</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;">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();
}
}
}</pre>
</div>
</div>
<p class="MsoNormal" style="text-align: justify;">
The Message-Driven above configures the destinationType property
for <strong>"javax.jms.Topic"</strong> to indicate that it will
listen to a JMS topic, and the destination property to <strong>"topic/wdkDocument"</strong>
to indicate which topic will be listened to. The "topic/wdkDocument"
topic is where the document publishing events are sent to.
</p>
<p class="MsoNormal" style="text-align: justify;">
Upon receiving a message, the type of published event must be checked
through the StringProperty "<strong>event</strong>"; if the value of
this property is <strong>"EXTERNALCONVERTION"</strong>, it means that
Fluig is indicating that this is the time for the customized
conversion to take place.
</p>
<p class="MsoNormal" style="text-align: justify;">
In order to obtain the document path, check the StringProperty <strong>"documentpath"</strong>.
</p>
<p class="MsoNormal" style="text-align: justify;">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.</p>
<p class="MsoNormal" style="text-align: justify;">Once the
parameters are validated, the converter program can be called; in the
example, the txt2pdf http://www.verypdf.com/txt2pdf/ freeware was
used.</p>
<p class="MsoNormal" style="text-align: justify;">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</p>
<p class="MsoNormal" style="text-align: justify;">It is important
to remember that the source document may not be modified, with the
penalty of Fluig indicating that it has been externally changed (CRC
validation).</p>
<p class="MsoNormal" style="text-align: justify;">
<span style="font-size: 10.0pt; line-height: 13.0pt;">This
Message-Driven must be packed and deployed on the application server
according to Java™ EE specifications.</span>
</p>
<p class="MsoNormal" style="text-align: justify;"> </p>
<h3
id="ConversoresdeDocumentos-Parte2:Message-Drivenparacriaçãodedocumentosdelongoprazo">Part
2: Message-Driven for the creation of long-term documents</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;">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.</span>
</p>
<p class="MsoNormal" style="text-align: justify;">
<span style="font-size: 10.0pt; line-height: 13.0pt;">Fluig
considers only the PDF/A format as the one possible to generate
long-term documents via </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;"> </span><span
style="font-size: 10.0pt; line-height: 13.0pt;">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 </span>Message-Driven<span
style="font-size: 10.0pt; line-height: 13.0pt;"> to
create the long-term document:</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 && doc.endsWith(".txt")) {
if (longTerm != null && longTerm.equals("true")) {
String documentName = doc + "PDFA.pdf";
//Call the conversion method for PDF/A
}
}</pre>
</div>
</div>
<p class="MsoNormal" style="text-align: justify;">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.</p>
<p class="MsoNormal" style="text-align: justify;"> </p>
<h3 id="ConversoresdeDocumentos-Parte3:RegistrandooconversornoFluig">Part
3: Registering the converter at Fluig</h3>
<p>In Fluig Studio, right-click the events folder, select the New
option and then the Fluig Global Event option:</p>
<p>
<img class="confluence-embedded-image confluence-content-image-border"
height="329" width="655" src="attachments/73082704/73407626.png"
data-image-src="attachments/73082704/73407626.png">
</p>
<p>
The New Event wizard is opened. Select the <strong>addDocumentConvertionExt </strong>event
and then click on the Finish button.
</p>
<p>
<img class="confluence-embedded-image"
src="attachments/73082704/73407627.png"
data-image-src="attachments/73082704/73407627.png">
</p>
<p>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:</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>Attention: </strong>For printing published documents with
the option "Update Controlled Copy Properties?" the external
converter will <strong>NOT</strong> 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).
</p>
</div>
</div>
<p class="MsoNormal" style="text-align: justify;"> </p>
<h3
id="ConversoresdeDocumentos-Parte4:AdicionarolisteneraoservidorFluig">Part
4: Add the listener to the Fluig server</h3>
<p>
<span
style="color: rgb(51, 51, 51); font-size: 10.0pt; font-weight: normal; line-height: 13.0pt;">Pack
the JMS </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;">
and add it to <SERVER FLUIG>/jboss/apps/.</span>
</p>
<p style="text-align: center;">
<img class="confluence-embedded-image image-left"
src="attachments/73082704/126158181.png"
data-image-src="attachments/73082704/126158181.png"> 
</p>
<p style="text-align: center;"> </p>
<p style="text-align: center;"> </p>
<p> </p>
<h3
id="ConversoresdeDocumentos-Parte5:Indicarqueodocumentoutilizaovisualizadorinterno">Part
5: Indicate that the document uses internal viewer</h3>
<p>Now that the .txt extension was recorded as having a customized
converter, mark the option "Use Internal Viewer?" in the document
publication:</p>
<p>
<img class="confluence-embedded-image" width="500"
src="attachments/73082704/73407620.png"
data-image-src="attachments/73082704/73407620.png">
</p>
<p> </p>
<p>
<strong>Notes:</strong>
</p>
<ul>
<li>In the example provided, integration examples are provided
for the previously created <em>Office (Word, Excel and
PowerPoint)</em> products.
</li>
<li>In the example provided, an integration example for
converting <em>DWG</em> formats using the <em>dwg2pdf </em>tool from
the <em>AutoDWG</em> company.
</li>
<li>The conversion codes are only examples, their development and
configuration are the responsibility of the developer.</li>
<li>A packed <em>plugin<strong> </strong></em> can be used made
available in the attachment. The settings detailed in the guide <a
href="75271469.html">Java® execution environment</a>, allowing
communication between the Fluig server and <em>Office</em> components
are necessary for the integration with Microsoft products.
</li>
</ul>
<h1 id="ConversoresdeDocumentos-ThirdPartyTrademarks">Third-Party
Trademarks</h1>
<p>Microsoft, Word are either registered trademarks or trademarks
of Microsoft Corporation in the United States and/or other countries.</p>
<p>JavaScript is a trademark of Oracle Corporation.</p>
<p>Java and OpenOffice.org are registered trademarks of Oracle
and/or its affiliates. Other names may be trademarks of their
respective owners.</p>
</div>
|