Menu

#8 Very long response time

open
nobody
None
5
2005-04-01
2005-04-01
Anonymous
No

Hello

I try to use Apache nFop using C# and I have some
problem of response time.

The final document have 257 pages with 2 columns. These
information are provided by an SQL request (10'') and
after an XML document is created manually (3Mo). Then
XSLO stylesheet is apply in order to create PDF document.

XSL FO document takes around 15 to 20 minutes. It's a
very long time for my application. Is it possible to
decrease it ?

C# code :

Logger.Debug ("Chargement du XSL : " + nomEtat +
".xsl");
string cheminEtat = Config.getRepertoireEtats();
string repTemp =
Environment.GetEnvironmentVariable("TEMP");
XslTransform docXSL = new XslTransform();
string ficXSL = nomEtat + ".xsl";
string ficPDF = repTemp + @"\" + nomEtat + "_" +
System.DateTime.Now.Ticks.ToString() + ".pdf";

try
{
docXSL.Load(cheminEtat + ficXSL);
}
catch (Exception ex)
{
Logger.Error("Erreur lors du chargement du doc
XSL", ex);
throw new Exception(MSG_IMPRESSION);
}

StringWriter docFO = new StringWriter();

Logger.Debug ("Création du docFO");
// on cree le FO ŕ partir de XML et XSL
try
{
docXSL.Transform(docXML.CreateNavigator() , null,
docFO, null);
}
catch (Exception exFO)
{
Logger.Error("Erreur lors de la transformation
XSLT", exFO);
throw new Exception(MSG_IMPRESSION);
}

Logger.Debug ("Création du PDF");
// on crée le PDF ŕ partir du FO avec la librairie
ApacheFop.Net.dll
Engine engin = new Engine();
try
{
Logger.Debug ("Exécution de la transformation");
sbyte[] sPDF = engin.Run(docFO.ToString());

Logger.Debug ("CRéation du document PDF");
int size = sPDF.Length;
byte [] pdf = new byte[size];

for (int i=0;i<size;i++)
pdf[i] = (byte) sPDF[i];

Logger.Debug ("Enregistrement du PDF");
//on crée le fichier PDF de sortie
FileStream fs = new FileStream(ficPDF,FileMode.Create);
BinaryWriter sw = new BinaryWriter(fs);
sw.Write(pdf);
sw.Close();
fs.Close();
}
catch (Exception fope)
{
Logger.Error("Erreur lors de la génération du PDF",
fope);
throw new Exception(MSG_IMPRESSION);
}

Logger.Debug ("Ouverture d'Acrobat");
//ouverture du fichier PDF dans Acrobat Reader
try
{
LanceAcrobat(ficPDF);
}
catch (Exception ex)
{
Logger.Error("Erreur lors de l'ouverture du fichier
PDF", ex);
throw new Exception(MSG_IMPRESSION);
}

Discussion


Log in to post a comment.

MongoDB Logo MongoDB