Automate document processing with low-cost Server Processes

Source: Internet
Author: User
Article Title: automate document processing with low-cost server processes. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
   The first is the simplest
First, for fast readability and rough word count statistics, scanning. DOC documents with strings is usually enough. Image
  
Strings something.doc | wc-w
  
The number of words returned by such a command is usually less than 10%.
  
It is very difficult to improve such a rough method. The core of the problem is that. DOC, as a format, has been greatly changed over the years. Difficult to track.
  
Related. RTF has several advantages: it is encoded in ASCII, almost human readable, and is unlikely to be infected by viruses. Moreover, it has become much more stable over the years. In 1997, most readers can understand. RTF compiled this year, and vice versa. On some networks I manage, I impose traffic restrictions: I exclude. DOC, and I agree to use. RTF to prevent malicious code. In principle, this denies users the right to use certain word processing features, which can only be obtained from. DOC. In reality, I have never met a user like this: he or she actually uses an effect that is not achieved by using. RTF.
  
The following reference section lists several lightweight Word readers: wvWare and catdoc. These can be installed and used quickly and easily. Most UNIX Desktop Users now know that OpenOffice on UNIX can be used to replace common use of Windows Word, and it is very good at reading and writing. DOC documents. OpenOffice exposes scripting interfaces, which allow you to program the document content using Java, C ++, Python, OpenOffice.org Basic, StarScript, CORBA, or OLE Automation. OpenOffice also integrates macro recording using this technology. The same is true for StarOffice (TM), a product that requires a commercial license.
  
In fact, although StarOffice is different in form from OpenOffice, this column focuses entirely on describing the latter, because according to the latter's website, "the future version of StarOffice software, starting from 6.0, OpenOffice.org source code, API (Application Programming Interface), file format, and reference implementation will be used for building "(see references ). In the future OpenOffice implementation, "UNO (Universal Network Object) is an interface-based component model ".
  
However, OpenOffice is a rather cumbersome way to process Word documents. It requires at least graphical user interface (GUI) services, and usually requires a very detailed installation and multiple programming processes. XML-oriented "formatting object" (FO) is very similar to it: although it is powerful, it requires a lot of work before it starts to work. If you do not want to perform these simple operations I often encounter-generate a fixed format. you should study such issues as RTF invoices, weekly reports on "Erased" income conditions, custom Web downloads with reader-specific information, and so on. the direct language binding of the RTF library. The best of them is Robert Rothenburg's Perl API.
  
RTF: Document
For the simplest. RTF generation process, simply cutting the paste is enough. You can use a shell script to generate a table like figure 1.
  
Listing 1. invoice. sh source code (partial)
#! /Bin/sh
  
AMOUNT = "1234.56"
DATE = "06 October 2002"
NUMBER = "9999/3333"
PO = "6543"
  
FORM = "{\ rtf1 \ ansi \ deff0 \ deftab720 {\ fonttbl...
\ Par \ pard \ plain \ f3 \ fs20
\ Par \ pard \ qr \ plain \ f2 \ fs24 \ cf0 $ DATE
\ Par \ pard \ plain \ f2 \ fs24 \ cf0 Phaseit, Inc.
\ Par # $ NUMBER
\ Par
\ Par Please pay \ $ AMOUNT
...
   Figure 1. Capture of simple Word documents generated on the Linux Server
  
To make programming more structured, scalable, and maintainable, use the Perl RTF module. These modules make it possible to write code as shown in Listing 2.
  
Listing 2. Source Code of invoice. pl (partial)
Use RTF: Document;
  
$ Rtf = new RTF: Document ({
Doc_page_width => '8. 5in ',
Doc_page_height => '11in'
});
$ FCourier = $ rtf-> add_font ("Courier ",
{Family => monospace, pitch => fixed,
Alternates => ["Courier New", "American Typewriter"]
}
);
$ FTime s = $ rtf-> add_font ("Times New Roman ",
{Default => 1
}
);
  
$ Rtf-> add_text ($ rtf-> root (), "Invoice ",...
   
Of course, with this method, I immediately have all the features and production of Perl, and can "access" external data sources and convert contents.
  
   Conclusion
Don't expect the problem to be solved by yourself. As a server developer, part of the responsibility is to check the conflicts in operations. If reports are frequently lost or encoded incorrectly, you can advise employees to work longer or more carefully. Sometimes this works. However, you can use automated tools to systematically design effective processes.
  
Automation not only reduces errors. When you automate content generation or processing, there are new possibilities in terms of customized and better quality services. Select the content that best fits your needs from the following references, use them to address problems that have consumed a lot of time in your organization, and continue to accept more interesting and beneficial challenges.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.