[COCOON + JFOR] Convert FO to RTF Format Documentation

xiaoxiao2021-03-06  83

[COCOON JFOR] Convert FO to RTF Format Documentation

Before you continue to read, we assume that you are familiar with the following knowledge, or you can refer to the appendices later in this article:

N Cocoon (one of the eight sub-projects in the XML project of Apache)

N xsl formatting objects (xsl-fo)

n FOP (Formatting Objects Processor)

n jf (Open-Source Java XSL-FO TO RTF Converter)

Key words:

Cocoon, JFOR, XML, XSL-FO

Summary:

For how to convert the PDF format document to a Word document, our idea is that you can: pdfàfoàrtf.

First, let's see how to convert FO to the RTF format. We can make Cocoon JFOR do this.

Overview

We already know that using WH2FO and FOP can successfully convert Word2000 documents to PDF format documents.

The first step is converted to XSL-FO, and the specific OpenSource can be found at http://www-uk.hpl.hp.com/people/fabgia/wh2fo/wh2fo.html.

In the second step, according to http://www-900.ibm.com/developerworks/cn/xml/x-xslfo2app/index.shtml

Guide, convert XSL-FO to PDF.

Simple command example:

> java org.apache.fop.Apps.fop everything.fo everyhes.pdf

Or after the FOP (http://apache.linux process/dist/xml/fop/) is installed, run:

FOP.CMD Sample.fo Sample.pdf

You can output the PDF file.

So how do we do it in turn? Convert PDF files to Word files.

There is no direct way to Microsoft KB, and their suggestion is that you open the PDF file with Acrobat Reader 5.0, paste the required content to Word with the copy text or Copy Image command. Some people claim that you can use Acrobat Reader 5.0 as an RTF format.

How To: Convert Adobe Acrobat Reader (* .pdf) Files in Word 2002 (290927)

- This Article Explains How To Convert A Portable Document Format (PDF) Document from Adobe Acrobat Reader to Microsoft Word.

Pdfàfoàrtf

Our idea is that it can be like this: pdfàfoàrtf.

First, let's see how to convert FO to the RTF format. We can make Cocoon JFor to do this:

Install COCOON:

Install Cocoon is relatively simple. Divide several steps:

The first step, install JDK:

Make sure your JDK version is high enough, mine is J2SDK1.4.2_02; then set java_home as the JDK directory, or run commands:

Set java_home = f: /j2sdk1.4.2_02

Step 2, install COCOON:

Download Cocoon 2.1.3:

The Latest Source Distribution (Cocoon 2.1.3):

· TAR / GZIP FORMAT (UNIX Platforms): Cocoon-Latest-src.tar.gz · Zip Format (Windows Platforms): Cocoon-laTest-src.zip

After decompression, run the build.bat under COCOON-2.1.3, to compile Cocoon:

E: /COCOON-2.1.3> Build

USING JAVA from f: /j2sdk1.4.2_02/

Buildfile: build.xml

Prepare:

----------------------------------- ----------

Apache Cocoon 2.1.3 [1999-2003]

----------------------------------- ----------

Building with apache ant version 1.5.4 Compiled on August 12 2003

...

...

Validate-jars:

Copying 1 File to E: /COCOON-2.1.3/build/cocoon-2.1.3/temp

VALIDATE-Config:

Validating Configuration FILES

Validating Cocoon.xconf Using a Very Basic Relax Ng Grammar ...

Build Successful

Total Time: 2 minutes 30 seconds

After the compilation is successful, we can try Cocoon's effect.

Step 3, start COCOON:

Essentially, Cocoon is still a servlet. Run Cocoon.bat under Cocoon-2.1.3, to start COCOON:

E: /COCOON-2.1.3> Cocoon servlet

Cocoon.bat: using ./build/webapp as the WebApp Directory

So, there was a Cocoon's run window:

Let's try the effect: Open IE, type

Http: // localhost: 8888

You can see:

Okay, everything is normal.

Now, we have to try the conversion of foàrtf. The premise is that the JFOR package must be placed under Cocoon.

Step 4, install JFOR to COCOON:

Official website from JFOR

http://www.jfor.org/

Download the JFOR binary package. address is:

http://prdownloads.sourceforge.net/jfor/jfor-0.7.2rc1.jar?download

Download JFOR-0.7.2rc1.jar and put it in

Cocoon-2.1.3 / lib / opt

Subfolder.

Then re-build Cocoon, step in the second step.

Start Cocoon Servlet again.

The fifth step, an example of XMLàrtf:

in

Cocoon-2.1.3 / build / webapp /

Enclose a folder in the directory, such as the name is called "RTFDemo".

Establish such documents:

SiteMap.xmap

SiteMap.xmap is a current site configuration, it is very important. "Map: Match" node indicates how to convert it.

Create a new subfolder Fo, where you are putting such a file:

Hello.xml

BPA! </ title></p> <p><Content></p> <p><PARA> US local time November 12, Microsoft released the development support tool of SQL Server 2000 "Best Practices Analyzer (BPA)". BPA is a tool for SQL Server applications that are designed to be facilitated to manage. Not only can I prevent the import of SQL Server from being forgotten, but also for the management of the database. Microsoft started the beta version of the tool from the same day through the company's Web site. ! </ para></p> <p></ content></p> <p></ page></p> <p>with</p> <p>Page2fo.xsl</p> <p><? XML Version = "1.0"?></p> <p><! - CVS $ ID: Page2fo.xsl, V 1.2 2003/05/07 04:57:13 Vgritsenko EXP $ -></p> <p><XSL: Stylesheet Version = "1.0"</p> <p>XMLns: XSL = "http://www.w3.org/1999/xsl/transform"</p> <p>XMLns: fo = "http://www.w3.org/1999/xsl/format"></p> <p><XSL: Template Match = "/"></p> <p><fo: root xmlns: fo = "http://www.w3.org/1999/xsl/format"></p> <p><fo: layout-master-set></p> <p><fo: Simple-page-master master-name = "page"</p> <p>Page-heiGHT = "29.7cm"</p> <p>Page-width = "21cm"</p> <p>Margin-top = "1cm"</p> <p>Margin-bottom = "2cm"</p> <p>Margin-left = "2.5cm"</p> <p>Margin-right = "2.5cm"></p> <p><fo: region-before extent = "3cm" /></p> <p><fo: region-body margin-top = "3cm" /></p> <p><fo: region-after eXtent = "1.5cm" /></p> <p></ fo: Simple-page-master> <fo: page-sequence-master master-name = "all"></p> <p><fo: repeatable-page-master-alternatives></p> <p><fo: conditional-page-master-reference master-reference = "page" page-position = "first" /></p> <p></ fo: REPEATABLE-Page-Master-Alternatives></p> <p></ fo: Page-Sequence-Master></p> <p></ fo: layout-master-set></p> <p><fo: page-sequence master-reference = "all"></p> <p><fo: static-content flow-name = "xsl-region -After"></p> <p><fo: block text-align = "center"</p> <p>Font-size = "10pt"</p> <p>Font-family = "serif"</p> <p>Line-height = "14pt"> Page <fo: page-number /> </ fo: block></p> <p></ fo: static-content></p> <p><fo: flow flow-name = "xsl-region-body"></p> <p><XSL: Apply-Templates /></p> <p></ fo: flow></p> <p></ fo: Page-Sequence></p> <p></ fo: root></p> <p></ xsl: template></p> <p><XSL: Template Match = "Title"></p> <p><fo: block font-size = "36pt" space-before.optimum = "24pt" text-align = "center"> <xsl: apply-templates /> </ fo: block></p> <p></ xsl: template></p> <p><XSL: Template Match = "Para"></p> <p><fo: block font-size = "12pt" Space-before.optimum = "12pt" text-align = "center"> <xsl: apply-templates /> </ fo: block></p> <p></ xsl: template></p> <p></ xsl: stylesheet></p> <p>Ok, everything is ready.</p> <p>Browse</p> <p>Http: // localhost: 8888 / RTFDemo / Hello.rtf</p> <p>You can see the output of the RTF version, you can save it as hello.rtf:</p> <p>At the same time, Cocoon's window also outputs this process:</p> <p>12: 39: 40.852 Event Started SocketListener on 0.0.0.0:8888</p> <p>12: 39: 40.852 Event Started Org.MortBay.jetty.server@1037c71</p> <p>JFOR.INFO: JFOR V0.7.1 - Setting Up Conversion ...</p> <p>JFOR.INFO: PARSING XSL: FO Document ...</p> <p>JFOR.INFO: Writing Out RTF ... JFOR.INFO: DONE CONVERTING XSL: FO TO RTF.</p> <p>JFOR.DEBUG: Conversion Took 80 MilliseConds.</p> <p>JFOR.INFO: JFOR V0.7.1 - Setting Up Conversion ...</p> <p>JFOR.INFO: PARSING XSL: FO Document ...</p> <p>Ok, XMLàrtf is implemented using Cocoon Jfor. However, this is the first step in the Long March.</p> <p>to be continued.</p> <p>Abbreviated language list:</p> <p>COCOON:</p> <p>CoCoon is one of the eight submersible in the XML project of the Apache, and CoCoon is an XML release framework according to the official definition of Apache. It allows you to define the conversion of XML documents and documents, and eventually generate the form of the form you choose, such as HTML, PDF, SVG, VRML, and more. In addition, Cocoon enables you to add processing logic in the XML file, thus a dynamic characteristic of the XML pipe.</p> <p>Official Homepage:</p> <p>http://cocoon.apache.org/</p> <p>XSL-fo:</p> <p>The XSL formatted object specification is formal recommendations for W3C, commonly referred to as XSL-FO, XSL-FO defines many XML tags, which describes how to display content.</p> <p>XSL-FO documents define a few things that are very important when making high quality printable documents:</p> <p>· Information about the actual size of the page (stationery and A4, etc.)</p> <p>· Information about page margins (top, left, bottom, and right), header and footer and other features of the page</p> <p>· Information about text, font size, color, and other features</p> <p>· The actual text to be printed, by the description paragraph, highlight, the elements of analogs, etc.</p> <p>Study the XSL-FO specification on the W3C site (W3.org/tr/xsl) (400 pages in total).</p> <p>For more general information about XSL-FO, please visit the W3C Style page located at the w3.org/style/xsl/.</p> <p>XSL-FO Detailed tutorial:</p> <p>http://www-900.ibm.com/developerWorks/cn/cnedu.nsf/xml-onlinecourse-bytitle/3b308072632f949fc8256d320006ca3f?opendocument</p> <p>FOP</p> <p>FOP (Formatting Objects Processor) is the first XSL: FO-based print format processor and the first format processor that is unrelated to the output. It is a Java program that can read in the object tree and generate rendered pages to output to the specified stream. The currently supported output format has PDF, PCL, PS, SVG, XML (represented by tree structure), printer, AWT, MIF, and TXT. The main output refers to PDF.</p> <p>James Tauber - the original author of FOP. He developed the original version of the tool, and opened the code very generously, and then handed it to Apache XML Project.</p> <p>Download the Apache XML project's FOP package from XML.Apache.org/dist/fop.</p> <p>FO tool</p> <p>JFOR (Java XSL-FO TO RTF Converter) Converts XML documents in accordance with XSL-FO to RTF (Rich-TEXT FORMAT), which is intended to convert XSL-FO (usually using XSLT generation) documents to PDF ( Similar to FOP or other similar tools).</p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-104805.html</div><div class="plugin d-flex justify-content-center mt-3"></div><hr><div class="row"><div class="col-lg-12 text-muted mt-2"><i class="icon-tags mr-2"></i><span class="badge border border-secondary mr-2"><h2 class="h6 mb-0 small"><a class="text-secondary" href="tag-2.html">9cbs</a></h2></span></div></div></div></div><div class="card card-postlist border-white shadow"><div class="card-body"><div class="card-title"><div class="d-flex justify-content-between"><div><b>New Post</b>(<span class="posts">0</span>) </div><div></div></div></div><ul class="postlist list-unstyled"> </ul></div></div><div class="d-none threadlist"><input type="checkbox" name="modtid" value="104805" checked /></div></div></div></div></div><footer class="text-muted small bg-dark py-4 mt-3" id="footer"><div class="container"><div class="row"><div class="col">CopyRight © 2020 All Rights Reserved </div><div class="col text-right">Processed: <b>0.041</b>, SQL: <b>9</b></div></div></div></footer><script src="./lang/en-us/lang.js?2.2.0"></script><script src="view/js/jquery.min.js?2.2.0"></script><script src="view/js/popper.min.js?2.2.0"></script><script src="view/js/bootstrap.min.js?2.2.0"></script><script src="view/js/xiuno.js?2.2.0"></script><script src="view/js/bootstrap-plugin.js?2.2.0"></script><script src="view/js/async.min.js?2.2.0"></script><script src="view/js/form.js?2.2.0"></script><script> var debug = DEBUG = 0; var url_rewrite_on = 1; var url_path = './'; var forumarr = {"1":"Tech"}; var fid = 1; var uid = 0; var gid = 0; xn.options.water_image_url = 'view/img/water-small.png'; </script><script src="view/js/wellcms.js?2.2.0"></script><a class="scroll-to-top rounded" href="javascript:void(0);"><i class="icon-angle-up"></i></a><a class="scroll-to-bottom rounded" href="javascript:void(0);" style="display: inline;"><i class="icon-angle-down"></i></a></body></html><script> var forum_url = 'list-1.html'; var safe_token = '7pW2QIO17O0WFxmjd2NxQmVE2EeXRPMor8DPjcZV0i8jOtXG9p6lJejJLMNvCHQVZimXnbQ83kykGfNXpFIJew_3D_3D'; var body = $('body'); body.on('submit', '#form', function() { var jthis = $(this); var jsubmit = jthis.find('#submit'); jthis.reset(); jsubmit.button('loading'); var postdata = jthis.serializeObject(); $.xpost(jthis.attr('action'), postdata, function(code, message) { if(code == 0) { location.reload(); } else { $.alert(message); jsubmit.button('reset'); } }); return false; }); function resize_image() { var jmessagelist = $('div.message'); var first_width = jmessagelist.width(); jmessagelist.each(function() { var jdiv = $(this); var maxwidth = jdiv.attr('isfirst') ? first_width : jdiv.width(); var jmessage_width = Math.min(jdiv.width(), maxwidth); jdiv.find('img, embed, iframe, video').each(function() { var jimg = $(this); var img_width = this.org_width; var img_height = this.org_height; if(!img_width) { var img_width = jimg.attr('width'); var img_height = jimg.attr('height'); this.org_width = img_width; this.org_height = img_height; } if(img_width > jmessage_width) { if(this.tagName == 'IMG') { jimg.width(jmessage_width); jimg.css('height', 'auto'); jimg.css('cursor', 'pointer'); jimg.on('click', function() { }); } else { jimg.width(jmessage_width); var height = (img_height / img_width) * jimg.width(); jimg.height(height); } } }); }); } function resize_table() { $('div.message').each(function() { var jdiv = $(this); jdiv.find('table').addClass('table').wrap('<div class="table-responsive"></div>'); }); } $(function() { resize_image(); resize_table(); $(window).on('resize', resize_image); }); var jmessage = $('#message'); jmessage.on('focus', function() {if(jmessage.t) { clearTimeout(jmessage.t); jmessage.t = null; } jmessage.css('height', '6rem'); }); jmessage.on('blur', function() {jmessage.t = setTimeout(function() { jmessage.css('height', '2.5rem');}, 1000); }); $('#nav li[data-active="fid-1"]').addClass('active'); </script>