#!/bin/bash

DEST=${1:-'/tmp/fred-pdf-examples'}

echo Create folder $DEST
mkdir $DEST


echo create file $DEST/advance_invoice_cs.pdf
xsltproc --stringparam lang cs templates/advance_invoice.xsl examples/advance_invoice.xml | ./fred-doc2pdf > $DEST/advance_invoice_cs.pdf

echo create file $DEST/advance_invoice_en.pdf
xsltproc --stringparam lang en templates/advance_invoice.xsl examples/advance_invoice.xml | ./fred-doc2pdf > $DEST/advance_invoice_en.pdf

echo create file $DEST/auth_info_cs.pdf
xsltproc --stringparam lang cs templates/auth_info.xsl examples/auth_info.xml | ./fred-doc2pdf > $DEST/auth_info_cs.pdf

echo create file $DEST/auth_info_en.pdf
xsltproc --stringparam lang en templates/auth_info.xsl examples/auth_info.xml | ./fred-doc2pdf > $DEST/auth_info_en.pdf

echo create file $DEST/contact_verification_auth_owner.pdf
xsltproc templates/contact_verification_auth_owner.xsl examples/contact_verification_auth_owner.xml | ./fred-doc2pdf > $DEST/contact_verification_auth_owner.pdf

echo create file $DEST/defunct_contacts.txt
xsltproc templates/defunct_contacts.xsl examples/warning_letter1.xml | sed 1d > $DEST/defunct_contacts.txt

echo create file $DEST/helios.xml
xsltproc templates/helios.xsl examples/helios.xml | iconv -f cp1250 | sed 's|windows-1250|utf-8|' | xmllint --format - > $DEST/helios.xml

echo create file $DEST/invoice.pdf
xsltproc templates/invoice.xsl examples/invoice.xml | ./fred-doc2pdf > $DEST/invoice.pdf

echo create file $DEST/mojeid_auth_user.pdf
xsltproc templates/mojeid_auth_owner.xsl examples/mojeid_auth_user.xml | ./fred-doc2pdf > $DEST/mojeid_auth_user.pdf

echo create file $DEST/mojeid_auth.pdf
xsltproc templates/mojeid_auth_user.xsl examples/mojeid_auth_user.xml | ./fred-doc2pdf > $DEST/mojeid_auth.pdf

echo create file $DEST/mojeid_validate.pdf
xsltproc templates/mojeid_validate.xsl examples/mojeid_validate.xml | ./fred-doc2pdf > $DEST/mojeid_validate.pdf

echo create file $DEST/public_request_block_en.pdf
xsltproc templates/public_request.xsl examples/public_request_block.xml | ./fred-doc2pdf > $DEST/public_request_block_en.pdf

echo create file $DEST/public_request_block_cs.pdf
xsltproc --stringparam lang cs templates/public_request.xsl examples/public_request_block.xml | ./fred-doc2pdf > $DEST/public_request_block_cs.pdf

echo create file $DEST/public_request_unblock_en.pdf
xsltproc templates/public_request.xsl examples/public_request_unblock.xml | ./fred-doc2pdf > $DEST/public_request_unblock_en.pdf

echo create file $DEST/public_request_unblock_cs.pdf
xsltproc --stringparam lang cs templates/public_request.xsl examples/public_request_unblock.xml | ./fred-doc2pdf > $DEST/public_request_unblock_cs.pdf

echo create file $DEST/public_request_authinfo_en.pdf
xsltproc templates/public_request.xsl examples/public_request_authinfo.xml | ./fred-doc2pdf > $DEST/public_request_authinfo_en.pdf

echo create file $DEST/public_request_authinfo_cs.pdf
xsltproc --stringparam lang cs templates/public_request.xsl examples/public_request_authinfo.xml | ./fred-doc2pdf > $DEST/public_request_authinfo_cs.pdf

echo create file $DEST/warning_letter1.pdf
xsltproc templates/warning_letter.xsl examples/warning_letter1.xml | ./fred-doc2pdf > $DEST/warning_letter1.pdf

echo create file $DEST/warning_letter2.pdf
xsltproc templates/warning_letter.xsl examples/warning_letter2.xml | ./fred-doc2pdf > $DEST/warning_letter2.pdf

echo create file $DEST/notice_to_correct_data.pdf
xsltproc templates/notice_to_correct_data.xsl examples/notice_to_correct_data.xml | ./fred-doc2pdf > $DEST/notice_to_correct_data.pdf

echo create file $DEST/confirm_correction.pdf
xsltproc templates/confirm_correction.xsl examples/notice_to_correct_data.xml | ./fred-doc2pdf > $DEST/confirm_correction.pdf

echo create file $DEST/notice_to_correct_data_long_address.pdf
xsltproc templates/notice_to_correct_data.xsl examples/notice_to_correct_data_long_address.xml | ./fred-doc2pdf > $DEST/notice_to_correct_data_long_address.pdf

echo create file $DEST/confirm_correction_long_address.pdf
xsltproc templates/confirm_correction.xsl examples/notice_to_correct_data_long_address.xml | ./fred-doc2pdf > $DEST/confirm_correction_long_address.pdf
