hdoc_to_pdf.ant 3.72 KB
Newer Older
1
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
<project name="hdoc_to_pdf" basedir="." default="main">

    <!-- OS properties -->
    <condition property="isMac">
        <os family="mac"/>
    </condition>
    <condition property="isWindows">
        <os family="windows"/>
    </condition>
    <condition property="isUnix">
        <os family="unix"/>
    </condition>

    <!-- Arguments properties -->
    <property name="InputPath" location="input"/>
    <property name="OutputPath" location="output"/>
    <property name="tmp" location="${basedir}/tmp"/>
    <property name="OutputPdfPath" location="${OutputPath}/result.pdf"/>

21 22 23 24 25
    <target name="main" depends="convertMac, convertWindows, convertUnix">
        <!--temporary files and folders are deleted-->
        <delete dir="${tmp}"/>
        <delete file="prepare_hdoc.ant"/>
    </target>
26 27

    <!-- Mac target -->
28
    <target name="convertMac" if="isMac" depends="hdocPreparation">
29 30 31 32 33
        <!--launches the FS/Java script and get a converted PDF file in the output directory-->
        <exec executable="java">
            <arg value="-cp"/>
            <arg value="lib/core-renderer.jar:lib/iText-2.0.8.jar"/>
            <arg value="org.xhtmlrenderer.simple.PDFRenderer"/>
34
            <arg value="${tmp}/final.xhtml"/>
35 36 37 38 39
            <arg value="${OutputPath}/result.pdf"/>
        </exec>
    </target>

    <!-- Windows target -->
40
    <target name="convertWindows" if="isWindows" depends="hdocPreparation">
41 42 43 44 45 46

        <!--launches the FS/Java script and get a converted PDF file in the output directory-->
        <exec executable="java">
            <arg value="-cp"/>
            <arg value="lib/core-renderer.jar;lib/iText-2.0.8.jar"/>
            <arg value="org.xhtmlrenderer.simple.PDFRenderer"/>
47
            <arg value="${tmp}/final.xhtml"/>
48 49 50 51 52 53
            <arg value="${OutputPath}/result.pdf"/>
        </exec>
    </target>

    <!-- Linux target -->
    <target name="convertUnix" if="isUnix">
54 55 56 57 58 59 60 61 62 63 64 65 66

        <!--launches the FS/Java script and get a converted PDF file in the output directory-->
        <exec executable="java">
            <arg value="-cp"/>
            <arg value="lib/core-renderer.jar:lib/iText-2.0.8.jar"/>
            <arg value="org.xhtmlrenderer.simple.PDFRenderer"/>
            <arg value="${tmp}/final.xhtml"/>
            <arg value="${OutputPath}/result.pdf"/>
        </exec>
    </target>


    <target name="hdocPreparation">
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
        <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"/>

        <!--launches the XSLT find_content to retrieve the content path-->
        <xslt in="${tmp}/META-INF/container.xml" out="prepare_hdoc.ant" style="xsl/find_content.xsl">
            <param name="TempRepository" expression="${tmp}"/>
        </xslt>
        <chmod file="prepare_hdoc.ant" perm="777"/>

        <!--launches the ANT prepare_hdoc.ant resulting from the previous XSLT in order to get a clean xhtml ready for the pdf conversion -->
        <ant antfile="prepare_hdoc.ant"/>
    </target>
99 100

</project>