Commit ba84cdd2 authored by Neveux Anais's avatar Neveux Anais
Browse files

Merge branch 'master' of

parents a5204d15 31ec411a
......@@ -53,7 +53,6 @@
<target name="insertion" if="wantToInsert">
<antcall target="installModules"/>
<exec executable="node" dir="./node">
<arg line="insert.js"/>
......@@ -65,19 +64,4 @@
<target name="checkModules">
<condition property="modNotInstalled">
<available file="node_modules" type="dir"/>
<target name="installModules" depends="checkModules" if="modNotInstalled">
<echo>"modules non installés"</echo>
<exec executable="npm" dir=".">
<arg line="install"/>
\ No newline at end of file
......@@ -2,7 +2,7 @@
set ant=hdoc_to_neo4j.ant
set antparam=-Dnode true;
IF NOT EXIST ./node_modules call npm install
ant -buildfile %ant% %antparam%
......@@ -31,5 +31,9 @@ fi
#Lancer la commande
#test si les packages ont été installés
if [ ! -d "$node_modules" ]; then
npm install
$vJavaCmd -classpath "$scJarList:" -Xmx150m -buildfile $ant $antparam
......@@ -28,7 +28,36 @@ This project can be used alone if you only want to convert a hdoc file into a PD
User documentation
There are two different ways to use the converter hdoc_to_pdf: by running a script run.bat/ or by command line using a terminal (allows the user to specify some parameters).
#### Running the script run.bat/
Use this method if you do not want to use a terminal.
1. Download and unzip it.
2. Add your source file into the input folder. It must be a .hdoc file.
3. Place _only one file_ in that folder.
4. On Linux or Mac, run the script On Windows, run the script run.bat.
5. Your file has been converted, the result is in the output folder.
#### Terminal:
By using the terminal you can specify some parameters to the conversion at the moment: the source file.
1. Download and unzip it.
2. Open your terminal and go into the folder hdoc_to_pdf.
3. Run the following command:
"ant -buildfile hdoc_to_pdf.ant"
You can specify the source file by adding parameters.
Use -DInputFile to specify the source file.
"ant -buildfile hdoc_to_optim.ant -DInputFile=sample.hdoc"
This parameter is optional. Your file has been converted, the result is in the output folder.
Known bugs
......@@ -51,6 +80,7 @@ Generic Todo
Technical notes
* This converter works with _only one_ hdoc file in the input folder, please ensure to clean the folder before proceeding with the hdoc you want to convert to PDF.
User Story
......@@ -64,5 +94,3 @@ User Story
......@@ -37,9 +37,32 @@
@page {
size: A4 portrait;
margin: 2cm;
margin-left: 44mm;
margin-right: 44mm;
margin-top: 20mm;
margin-bottom: 40mm;
@bottom-center { content: counter(page) }
* {
font-family: "CMU Serif";
p {
text-align: justify;
text-indent: 2em;
hyphens: auto;
body {counter-reset: h2}
h2 {counter-reset: h3}
h3 {counter-reset: h4}
h4 {counter-reset: h5}
h5 {counter-reset: h6}
h2:before {counter-increment: h2; content: counter(h2) ".\0000a0\0000a0"}
h3:before {counter-increment: h3; content: counter(h2) "." counter(h3) ".\0000a0\0000a0"}
h4:before {counter-increment: h4; content: counter(h2) "." counter(h3) "." counter(h4) ".\0000a0\0000a0"}
h5:before {counter-increment: h5; content: counter(h2) "." counter(h3) "." counter(h4) "." counter(h5) ".\0000a0\0000a0"}
h6:before {counter-increment: h6; content: counter(h2) "." counter(h3) "." counter(h4) "." counter(h5) "." counter(h6) ".\0000a0\0000a0"}
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project name="hdoc_to_pdf" basedir="." default="main">
<taskdef resource="net/sf/antcontrib/antlib.xml">
<pathelement location="lib/ant-contrib.jar"/>
<!-- Arguments properties -->
<property name="InputPath" location="input"/>
<property name="OutputPath" location="output"/>
<property name="tmp" location="${basedir}/tmp"/>
<property name="tmpdir" location="${basedir}/tmp"/>
<property name="OutputFileName" location="${OutputPath}/result.pdf"/>
<target name="main" depends="hdocPreparation">
......@@ -16,51 +22,57 @@
<arg value="${OutputFileName}"/>
<!-- Temporary files and folders are deleted -->
<delete dir="${tmp}"/>
<delete file="prepare_hdoc.ant"/>
<delete file=""/>
<target name="hdocPreparation">
<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}"/>
<!-- Clean the folders before proceeding -->
<fileset dir="${OutputPath}" excludes=".gitkeep"/>
<fileset dir="${tmpdir}" excludes=".gitkeep"/>
<echo message="Getting input hdoc file..."/>
<condition property="InputFile.set" else="false">
<isset property="InputFile"/>
<equals arg1="${InputFile.set}" arg2="false" />
<!-- There is no input, check the input folder -->
<echo message="Checking the input folder..."/>
<!-- Get input hdoc file path -->
<fileset id="fileset_hdoc" dir="${InputPath}" casesensitive="yes">
<include name="*.hdoc"/>
<pathconvert property="HdocFile" pathsep="" refid="fileset_hdoc"/>
<pathconvert property="InputFile" pathsep="" refid="fileset_hdoc"/>
<echo message="Executing conversion..."/>
<!-- Unzips the hdoc to be converted-->
<unzip dest="${tmp}" src="${HdocFile}"/>
<unzip dest="${tmpdir}" src="${InputFile}"/>
<!-- Gives all rights to avoid bugs-->
<chmod dir="${tmp}" perm="777"/>
<chmod dir="${tmpdir}" perm="777"/>
<!-- Launches the XSLT find_content to retrieve the content path -->
<xslt in="${tmp}/META-INF/container.xml" out="prepare_hdoc.ant" classpath="./lib/saxon9he.jar" style="xsl/find_content.xsl">
<xslt in="${tmpdir}/META-INF/container.xml" out="${tmpdir}/prepare_hdoc.ant" classpath="./lib/saxon9he.jar" style="xsl/find_content.xsl">
<param name="BaseDirectory" expression="${basedir}"/>
<param name="TempDirectory" expression="${tmp}"/>
<param name="TempDirectory" expression="${tmpdir}"/>
<chmod file="prepare_hdoc.ant" perm="777"/>
<chmod file="${tmpdir}/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"/>
<ant antfile="${tmpdir}/prepare_hdoc.ant"/>
<!-- Recover of the dirpath property extracted through find_content.xsl execution -->
<property file="${basedir}/"/>
<property file="${tmpdir}/"/>
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<!--find_content.xsl creates a ANT file prepare_hdoc.ant-->
xmlns:xsl="" version="2.0"
......@@ -51,7 +51,7 @@
<xslt in="{$dirpath}/hdoc_nsless.xhtml" out="{$dirpath}/flat_hdoc.xhtml" style="xsl/hdoc_flattenizer.xsl" classpath="./lib/saxon9he.jar"/>
<xslt in="{$dirpath}/flat_hdoc.xhtml" out="{$dirpath}/final.xhtml" style="xsl/last_transformer.xsl" classpath="./lib/saxon9he.jar"/>
<propertyfile file="{$BaseDirectory}/">
<propertyfile file="{$TempDirectory}/">
<entry key="dirpath" value="{$dirpath}"/>
......@@ -17,7 +17,7 @@
<xsl:template match="html">
<html lang="fr">
......@@ -35,7 +35,7 @@
<xsl:template match="section">
<xsl:variable name="level" select="count(ancestor::section) + 1"/>
<xsl:variable name="level" select="count(ancestor::section) + 2"/>
<xsl:element name="h{$level}">
<xsl:value-of select="header/h1"/>
......@@ -48,7 +48,7 @@
<xsl:template match="h6">
<xsl:variable name="level" select="count(ancestor::section) + 1"/>
<xsl:variable name="level" select="count(ancestor::section) + 2"/>
<xsl:element name="h{$level}">
<xsl:value-of select="."/>
Supports Markdown
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