hdoc_to_pdf.ant 6.5 KB
Newer Older
Baptiste Perraud's avatar
Baptiste Perraud committed
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
21
22
23
24
25
26
27
<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"/>

    <target name="main" depends="convertMac, convertWindows, convertUnix"/>

    <!-- Mac target -->
    <target name="convertMac" if="isMac">
        <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}"/>
Baptiste Perraud's avatar
Baptiste Perraud committed
28
29
30
31
32
33

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

34
35
36
37
38
39
40
41
42
43
44
45
46
47
        <!-- 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"/>

48
49
50
51
52
        <!--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"/>
Baptiste Perraud's avatar
Baptiste Perraud committed
53

54
        <!--launches the ANT prepare_hdoc.ant resulting from the previous XSLT in order to get a clean xhtml ready for the pdf conversion -->
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
        <ant antfile="prepare_hdoc.ant"/>

        <!--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}/flat_hdoc.xhtml"/>
            <arg value="${OutputPath}/result.pdf"/>
        </exec>

        <!--temporary files and folders are deleted-->
        <delete dir="${tmp}"/>
        <delete file="prepare_hdoc.ant"/>
    </target>

    <!-- Windows target -->
    <target name="convertWindows" if="isWindows">
        <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..."/>
89

90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
        <!-- 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"/>

        <!--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}/flat_hdoc.xhtml"/>
            <arg value="${OutputPath}/result.pdf"/>
        </exec>

        <!--temporary files and folders are deleted-->
				<delete dir="${tmp}"/>
        <delete file="prepare_hdoc.ant"/>
    </target>

    <!-- Linux target -->
    <target name="convertUnix" if="isUnix">
        <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"/>
Baptiste Perraud's avatar
Baptiste Perraud committed
152

153
154
155
156
157
158
159
160
        <!--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}/flat_hdoc.xhtml"/>
            <arg value="${OutputPath}/result.pdf"/>
        </exec>
Baptiste Perraud's avatar
Baptiste Perraud committed
161

162
163
164
165
        <!--temporary files and folders are deleted-->
				<delete dir="${tmp}"/>
        <delete file="prepare_hdoc.ant"/>
    </target>
Baptiste Perraud's avatar
Baptiste Perraud committed
166
167
168


</project>