Commit bc865e91 authored by bperraud's avatar bperraud

Update hdoc_to_pdf.ant which now includes basic FS PDF generator

parent b708820a
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project name="hdoc_to_pdf" basedir="." default="convert"> <project name="hdoc_to_pdf" basedir="." default="main">
<!--<taskdef resource="net/sf/antcontrib/antcontrib.properties"> <!-- OS properties -->
<classpath> <condition property="isMac">
<pathelement location="lib/ant-contrib.jar" /> <os family="mac"/>
</classpath> </condition>
</taskdef>--> <condition property="isWindows">
<os family="windows"/>
<!-- Arguments properties --> </condition>
<property name="InputPath" location="input" /> <condition property="isUnix">
<property name="OutputPath" location="output" /> <os family="unix"/>
<property name="tmp" location="${basedir}/tmp"/> </condition>
<property name="OutputPdfPath" location="${OutputPath}/result.pdf" />
<!-- Arguments properties -->
<target name="convert"> <property name="InputPath" location="input"/>
<property name="OutputPath" location="output"/>
<echo message="The value of property of InputPath is ${InputPath}" /> <property name="tmp" location="${basedir}/tmp"/>
<echo message="The value of property of OutputPath is ${OutputPath}" /> <property name="OutputPdfPath" location="${OutputPath}/result.pdf"/>
<echo message="The value of property of tmp is ${tmp}" />
<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}"/>
<!-- Creation of temp dir --> <!-- Creation of temp dir -->
<delete dir="${tmp}" failonerror="false"/> <delete dir="${tmp}" failonerror="false"/>
<sleep seconds="1"/> <sleep seconds="1"/>
<mkdir dir="${tmp}"/> <mkdir dir="${tmp}"/>
<!-- Get input hdoc file path --> <!-- Get input hdoc file path -->
<fileset id="fileset_hdoc" dir="${InputPath}" casesensitive="yes"> <fileset id="fileset_hdoc" dir="${InputPath}" casesensitive="yes">
<include name="*.hdoc"/> <include name="*.hdoc"/>
</fileset> </fileset>
<pathconvert property="HdocFile" pathsep="" refid="fileset_hdoc" /> <pathconvert property="HdocFile" pathsep="" refid="fileset_hdoc"/>
<echo message="Executing conversion..." /> <echo message="Executing conversion..."/>
<!-- Unzips the hdoc to be converted--> <!-- Unzips the hdoc to be converted-->
<unzip dest="${tmp}" src ="${HdocFile}"/> <unzip dest="${tmp}" src="${HdocFile}"/>
<!-- Gives all rights to avoid bugs--> <!-- Gives all rights to avoid bugs-->
<chmod dir="${tmp}" perm="777"/> <chmod dir="${tmp}" perm="777"/>
<!--launches the XSLT find_content to retrieve the content path--> <!--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"> <xslt in="${tmp}/META-INF/container.xml" out="prepare_hdoc.ant" style="xsl/find_content.xsl">
<param name="TempRepository" expression="${tmp}"/> <param name="TempRepository" expression="${tmp}"/>
...@@ -45,17 +52,117 @@ ...@@ -45,17 +52,117 @@
<chmod file="prepare_hdoc.ant" perm="777"/> <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 --> <!--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"/> <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..."/>
<!--launches the ANT xxx to execute the FS/Java script and get a converted PDF file in the output directory--> <!-- Unzips the hdoc to be converted-->
<!--TODO--> <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"/>
<!--temporary files and folders are deleted--> <!--launches the FS/Java script and get a converted PDF file in the output directory-->
<!--<delete dir="${tmp}"/>--> <exec executable="java">
<!--<delete file="prepare_hdoc.ant"/>--> <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>
</target>
</project> </project>
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:h="urn:utc.fr:ics:hdoc:container"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
name="hdoc_to_pdf"
default="main">
<target name="main">
<xslt in="/home/raphael/Documents/Travail/NF29/projet/hdoc/hdoc_to_pdf/tmp/content.xml"
out="/home/raphael/Documents/Travail/NF29/projet/hdoc/hdoc_to_pdf/tmp/hdoc_nsless.xhtml"
style="xsl/ns_remover.xsl"/>
<xslt in="/home/raphael/Documents/Travail/NF29/projet/hdoc/hdoc_to_pdf/tmp/hdoc_nsless.xhtml"
out="/home/raphael/Documents/Travail/NF29/projet/hdoc/hdoc_to_pdf/tmp/flat_hdoc.xhtml"
style="xsl/hdoc_flattenizer.xsl"/>
</target>
</project>
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet <xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xs="http://www.w3.org/2001/XMLSchema"
xpath-default-namespace="http://www.w3.org/1999/xhtml"> xpath-default-namespace="http://www.w3.org/1999/xhtml">
<xsl:output method="text" indent="yes"/> <xsl:output method="xml" indent="yes"/>
<xsl:template match="html">
Hello world ! <xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template> </xsl:template>
</xsl:stylesheet> </xsl:stylesheet>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment