hdoc_to_pdf.ant 2.45 KB
Newer Older
1
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2 3 4 5 6 7
<project name="hdoc_to_pdf" basedir="." default="main">

    <!-- Arguments properties -->
    <property name="InputPath" location="input"/>
    <property name="OutputPath" location="output"/>
    <property name="tmp" location="${basedir}/tmp"/>
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
    <property name="OutputFileName" location="${OutputPath}/result.pdf"/>

    <target name="main" depends="hdocPreparation">

      <exec executable="java">
          <arg value="-jar"/>
          <arg value="lib/MyPDFGenerator.jar"/>
          <arg value="${dirpath}/final.xhtml"/>
          <arg value="${OutputFileName}"/>
      </exec>

        <!-- Temporary files and folders are deleted -->
        <!--
        <delete dir="${tmp}"/>
        <delete file="prepare_hdoc.ant"/>
        <delete file="my.properties"/>
        -->
25 26 27 28
    </target>


    <target name="hdocPreparation">
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
        <echo message="The value of property of InputPath is ${InputPath}"/>
        <echo message="The value of property of OutputPath is ${OutputPath}"/>
        <echo message="The value of property of tmp is ${tmp}"/>

        <!-- Creation of temp dir -->
        <delete dir="${tmp}" failonerror="false"/>
        <sleep seconds="1"/>
        <mkdir dir="${tmp}"/>

        <!-- Get input hdoc file path -->
        <fileset id="fileset_hdoc" dir="${InputPath}" casesensitive="yes">
            <include name="*.hdoc"/>
        </fileset>
        <pathconvert property="HdocFile" pathsep="" refid="fileset_hdoc"/>

        <echo message="Executing conversion..."/>

        <!-- Unzips the hdoc to be converted-->
        <unzip dest="${tmp}" src="${HdocFile}"/>

        <!-- Gives all rights to avoid bugs-->
        <chmod dir="${tmp}" perm="777"/>

52
        <!-- Launches the XSLT find_content to retrieve the content path -->
53 54 55
        <xslt in="${tmp}/META-INF/container.xml" out="prepare_hdoc.ant" classpath="./lib/saxon9he.jar" style="xsl/find_content.xsl">
            <param name="BaseDirectory" expression="${basedir}"/>
            <param name="TempDirectory" expression="${tmp}"/>
56 57 58
        </xslt>
        <chmod file="prepare_hdoc.ant" perm="777"/>

59
        <!-- Launches the ANT prepare_hdoc.ant resulting from the previous XSLT in order to get a clean xhtml ready for the pdf conversion -->
60
        <ant antfile="prepare_hdoc.ant"/>
61 62 63

        <!-- Recover of the dirpath property extracted through find_content.xsl execution -->
        <property file="${basedir}/my.properties"/>
64
    </target>
65 66

</project>