Changeset 32895 for documentation

13.03.2019 19:05:57 (17 months ago)

Removing the Icecite section as it's made obsolete with the introduction of PDFv2Plugin with GS3.09. These instructions are available at the wiki, as they still work.

1 modified


  • documentation/trunk/tutorials/xml-source/tutorial_en.xml

    r32894 r32895  
    48614861<NumberedItem><Text id="ucp-45">Having designed your collection to handle DjVu documents, you can now add any other documents, including more DjVu documents. Greenstone should now be able to index the text content of DjVu documents in the collection to make them searchable, in all instances where text can be successfully extracted from them by <Format>djvutext</Format>.</Text> 
    4863 <Heading> 
    4864 <Text id="ucp-46">Using Icecite's commandline tool to convert from PDF to text</Text> 
    4865 </Heading> 
    4866 <Comment><Text id="ucp-47"><Link url="">Icecite</Link> (now known as <Link url="">PdfAct</Link>) is an open-source tool that can do many PDF related tasks, including extracting text from a PDF. In this part of the tutorial, we're going to learn how to run Icecite's PDF to text conversion utility from the command line. Based on that command, we'll configure the UnknownConverterPlugin to launch Icecite from GLI, to do the conversion on a PDF document in a Greenstone collection. This ends up being a useful exercise in instances where certain PDFs aren't recognised by Greenstone's PDFv1Plugin or old PDFPlugin, even when the <Format>pdfbox_conversion</Format> option (which uses the PDFBox tool for the conversion) is switched on. In such cases, you can use what you learn here. The PDFv2Plugin introduced since Greenstone 3.09 should however be able to handle more PDF documents out of the box, so try that first before using the UnknownConverterPlugin with Icecite.</Text></Comment> 
    4867 <Comment> 
    4868 <Text id="ucp-48">As Icecite needs Java 8, you need to have either a JDK8 or a JRE8 installed in order to proceed with this portion of the tutorial.</Text> 
    4869 </Comment> 
    4870 <NumberedItem> 
    4871 <Text id="ucp-49">Grab the pre-compiled Icecite zip file from <Link></Link> (or from <Link></Link>, if you prefer a tarball) and decompress it into your Greenstone installation's <Format>ext</Format> subfolder.</Text> 
    4872 <Text id="ucp-50">Now you're ready to test Icecite's PDF to text conversion abilities manually, by running Icecite from the command line.</Text> 
    4873 </NumberedItem> 
    4874 <NumberedItem> 
    4875 <Text id="ucp-60">Set up your environment for Java 8:</Text> 
    4876 <Format>export JAVA_HOME=/PATH/TO/YOUR-JAVA-8-HOME 
    4877 export PATH=$JAVA_HOME/bin:$PATH 
    4878 </Format> 
    4879 </NumberedItem> 
    4880 <NumberedItem> 
    4881 <Text id="ucp-61">You would need to run Icecite from the terminal wherein you set up the Java 8 environment. Run it on a PDF as follows, after first replacing the <Format>&lt;PLACEHOLDERS&gt;</Format> below.</Text> 
    4882 <BulletList> 
    4883 <Bullet> 
    4884 <Text id="ucp-61a">The command will look as follows on Windows, note the use of <i>double quotes</i> around the <Format>classpath</Format> value and the use of semi-colon as the path separator on Windows:</Text> 
    4885 <Format>java -classpath "&lt;DRIVE:\PATH-TO-GS-INSTALLATION&gt;\ext\icecite\gs-installed-jars\*;&lt;DRIVE:\PATH-TO-GS-INSTALLATION&gt;\ext\icecite\pdf-cli\target\pdf-cli-0.0.1-SNAPSHOT-jar-with-dependencies.jar" cli.PdfParserCommandLine --format txt --feature paragraphs &lt;DRIVE:\FULL\PATH\TO\YOUR.pdf&gt; &lt;DRIVE:\FULL\PATH\TO\CONVERTED.txt&gt;</Format> 
    4886 </Bullet> 
    4887 <Bullet> 
    4888 <Text id="ucp-61b">On Unix systems, the command will be of the following form, where single quotes are acceptable around the value for <Format>classpath</Format> and where colon is the path separator:</Text> 
    4889 <Format>java -classpath '/&lt;PATH-TO-GS-INSTALLATION&gt;/ext/icecite/gs-installed-jars/*:/&lt;PATH-TO-GS-INSTALLATION&gt;/ext/icecite/pdf-cli/target/pdf-cli-0.0.1-SNAPSHOT-jar-with-dependencies.jar' cli.PdfParserCommandLine --format txt --feature paragraphs &lt;/PATH/TO/YOUR.pdf&gt; &lt;/PATH/TO/CONVERTED.txt&gt;</Format> 
    4890 </Bullet> 
    4891 </BulletList> 
    4892 <Text id="ucp-62">It can take a while for the PDF to get converted, but once it has finished, you can inspect the text file produced, denoted by the placeholder string <Format>&lt;/PATH/TO/CONVERTED.txt&gt;</Format></Text> 
    4893 <Comment><Text id="ucp-63">You can experiment with using <Format>--feature words</Format> or <Format>--feature lines</Format> above, in place of <Format>--feature paragraphs</Format>, to find out the effect of such a change on the output file, particularly if <Format>--feature paragraphs</Format> does not produce the desired results for your PDFs.</Text></Comment> 
    4894 </NumberedItem> 
    4895 <Heading> 
    4896 <Text id="ucp-64">Using the UnknownConverterPlugin to launch Icecite from GLI to do the PDF to text conversion</Text> 
    4897 </Heading> 
    4898 <Comment><Text id="ucp-65">We're now ready to use the <AutoText text="UnknownConverterPlugin"/> to launch Icecite as the external tool to do the conversion, producing output that Greenstone's building scripts can ingest into Greenstone and index for searching.</Text></Comment> 
    4899 <NumberedItem><Text id="ucp-66">Run GLI.</Text></NumberedItem> 
    4900 <NumberedItem><Text id="ucp-67">Create a new collection called Icecite. In the <AutoText key="glidict::GUI.Gather"/> pane, drop in the sample PDF file into your collection.</Text></NumberedItem> 
    4901 <NumberedItem><Text id="ucp-68">In the <AutoText key="glidict::GUI.Design"/> pane and select <AutoText key="glidict::CDM.GUI.Plugins"/> from the list on the left. Add the <AutoText text="UnknownConverterPlugin"/>. Having tried out the Icecite conversion command manually in the previous part of this tutorial, we're now ready to use it when configuring the <AutoText text="UnknownConverterPlugin"/>. Click <AutoText key="glidict::CDM.PlugInManager.Configure" type="button"/> and set up the plugin with the following settings:</Text> 
    4902 <BulletList> 
    4903 <Bullet><Text id="ucp-69">set <Format>convert_to</Format> to the <Format>text</Format> option, this is the output format upon conversion</Text></Bullet> 
    4904 <Bullet><Text id="ucp-70">set <Format>mime_type</Format> to <Format>application/pdf</Format></Text></Bullet> 
    4905 <Bullet><Text id="ucp-71">set <Format>srcicon</Format> to the <Format>iconpdf</Format>, since Greenstone already knows about this macro and already has an icon for PDFs and knows to associate the two</Text></Bullet> 
    4906 <Bullet><Text id="ucp-72">set <Format>process_extension</Format> to <Format>pdf</Format>, this is the input format of the files that this instance of the <AutoText text="UnknownConverterPlugin"/> will process</Text></Bullet> 
    4907 <Bullet><Text id="ucp-73">set the <Format>exec_cmd</Format> field as follows, depending on your operating system:</Text> 
    4908 <BulletList> 
    4909 <Bullet> 
    4910 <Text id="ucp-73a">on Windows:</Text> 
    4911 <Format>DRIVE:\PATH\TO\YOUR-JAVA-8-HOME\bin\java -classpath "<MajorVersion number="2">%%GSDLHOME</MajorVersion><MajorVersion number="3">%%GSDL3SRCHOME</MajorVersion>\ext\icecite\gs-installed-jars\*:<MajorVersion number="2">%%GSDLHOME</MajorVersion><MajorVersion number="3">%%GSDL3SRCHOME</MajorVersion>\ext\icecite\pdf-cli\target\pdf-cli-0.0.1-SNAPSHOT-jar-with-dependencies.jar" cli.PdfParserCommandLine --format txt --feature paragraphs %%INPUT_FILE %%OUTPUT</Format> 
    4912 </Bullet> 
    4913 <Bullet> 
    4914 <Text id="ucp-73b">on Unix systems:</Text> 
    4915 <Format>/PATH/TO/YOUR-JAVA-8-HOME/bin/java -classpath '<MajorVersion number="2">%%GSDLHOME</MajorVersion><MajorVersion number="3">%%GSDL3SRCHOME</MajorVersion>/ext/icecite/gs-installed-jars/*:<MajorVersion number="2">%%GSDLHOME</MajorVersion><MajorVersion number="3">%%GSDL3SRCHOME</MajorVersion>/ext/icecite/pdf-cli/target/pdf-cli-0.0.1-SNAPSHOT-jar-with-dependencies.jar' cli.PdfParserCommandLine --format txt --feature paragraphs %%INPUT_FILE %%OUTPUT</Format> 
    4916 </Bullet> 
    4917 </BulletList> 
    4918 </Bullet> 
    4919 </BulletList> 
    4920 <Text id="ucp-74">Note: When filling in the <Format>exec_cmd</Format> field, leave the words with <Format>%%</Format> signs in front of them intact. They are placeholders for Greenstone to replace.</Text> 
    4921 <Text id="ucp-75">You will however need to adjust the above value for <Format>exec_cmd</Format> by finding out where your Java 8 is installed and replacing <Format>/PATH/TO/YOUR-JAVA-8-HOME</Format> with it. The reason you need to provide the full path to the Java 8 executable is because, at present, GLI binaries ship with Java 7, which is incompatible with the precompiled Icecite. And if you're running Greenstone from a source, you may have a different version of Java set up in your environment too. However, by providing the full path to the Java 8 executable above, you force Icecite's PDF conversion program to run with Java 8.</Text> 
    4922 <Comment><Text id="ucp-76">On Windows, if there are spaces in any filepaths in the command, <i>other than</i> in the parameter value to <Format>-classpath</Format>, remember to bookend those filepaths within double quotes escaped with a backslash, <Format>\"</Format>.</Text></Comment> 
    4923 <Comment><Text id="ucp-77">The above command will use the java executable to run the java Icecite program that does the actual PDF to text conversion. Greenstone will run the command given after first filling in the <Format><MajorVersion number="2">%%GSDLHOME</MajorVersion><MajorVersion number="3">%%GSDL3SRCHOME</MajorVersion></Format>, <Format>%%INPUT_FILE</Format> and <Format>%%OUTPUT</Format> appropriately. <Format><MajorVersion number="2">%%GSDLHOME</MajorVersion><MajorVersion number="3">%%GSDL3SRCHOME</MajorVersion></Format> works out to be the Greenstone <MajorVersion number="2">2</MajorVersion><MajorVersion number="3">3</MajorVersion> installation directory, whereas <Format>%%INPUT_FILE</Format> is whichever matching PDF it's processing and <Format>%%OUTPUT</Format> is likewise the file (or folder of files) produced by the conversion process. In this case, the output type is txt, as that's what Icecite produces. Once the conversion to text has finished, Greenstone will be able to process it as usual, such as indexing the extracted contents to make the document searchable.</Text> 
    4924 </Comment> 
    4925 </NumberedItem> 
    4926 <NumberedItem><Text id="ucp-78">Having sufficiently configured the <AutoText text="UnknownConverterPlugin"/>, click the <AutoText key="glidict::General.OK" type="button"/> button to close its configuration dialog.</Text></NumberedItem> 
    4927 <NumberedItem><Text id="ucp-79">Select the <AutoText text="UnknownConverterPlugin"/> in the list of plugins and keep pressing the <AutoText key="glidict::CDM.Move.Move_Up" type="button"/> button to shift it upwards, until it appears in the plugin pipeline above the existing <AutoText text="PDFPlugin"/>, so that this instance of <AutoText text="UnknownConverterPlugin"/>, configured as it has now been to handle PDF files, will take precedence in processing such files.</Text></NumberedItem> 
    4928 <NumberedItem><Text id="ucp-80">Move to the <AutoText key="glidict::GUI.Create"/> pane and build the collection. Once more, when Icecite conversion utility is called by Greenstone's building process, the conversion will take some time processing. But after a minute or so, the building will be done and you can Preview the collection. Search for some terms.</Text></NumberedItem>