Hello,
I’ve upgrated my project from aspose pdf kit 6.1.0.0 to aspose pdf 7.1.0.0 and I’ve noticed that concatenating streams takes really a lot of time… if before (for around 1000 pdf files it was taking 3 minutes now we’re arount 15mins)
Are you experiencing this? i’ve noticed as posted in your release note a minor memory usage but times grew up a lot!
Here’s the code i was using (and I use, I’ve just changed the “using”))
MemoryStream[] msArray = new MemoryStream[lotto.Items.Count];
for (int i = 0; i < lotto.Items.Count; i++)
{
LottoItem li = lotto.Items[i];
strMsg = string.Format("Richiedendo documento {0}", li.Protocollo);
NLog.LogManager.GetLogger("normal").Info(strMsg);
IDEA.Web.DO.GeneratoreReportistica.Documento doc = null;
using (DataAccess dataAccess = new DataAccess())
{
DataSet ds = dataAccess.GetDocumento(li.Protocollo);
if (ds != null && ds.Tables != null && ds.Tables[0].Rows.Count > 0)
{
DataRow dr = ds.Tables[0].Rows[0];
byte[] bytes = (byte[])dr["CONTENUTO"];
doc = new IDEA.Web.DO.GeneratoreReportistica.Documento();
doc.BytesDocumento = bytes;
doc.FormatoDocumento = GetCheckedString(dr["ESTENSIONE"]);
doc.Filename = GetCheckedString(dr["NOME_FILE"]);
}
}
if (doc != null)
{
byte[] bytes = doc.BytesDocumento;
MemoryStream ms = new MemoryStream(bytes, 0, bytes.Length);
msArray[i] = ms;
// lstPdf.Add(doc.BytesDocumento);
strMsg = string.Format("Salvato in memoria documento {0}", li.Protocollo);
NLog.LogManager.GetLogger("normal").Info(strMsg);
}
}
sw.Stop();
string str = string.Format("Tempo impiegato per leggere i dati del lotto {0} : {1} ms", lotto.IDLotto, sw.ElapsedMilliseconds);
NLog.LogManager.GetLogger("normal").Info(str);
try
{
PdfFileEditor editor = new PdfFileEditor();
editor.Concatenate(msArray, fileStream);
fileStream.Close();
PdfFileInfo fileInfo = new PdfFileInfo(fileOutPut);
count = fileInfo.NumberOfPages;
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
return 0;
}
finally
{
foreach (var ms in msArray)
{
ms.Close();
//ms = null;
}
}
What can I verify?
Thanks
I've attached a simple project... it was pointing to c:\temp\test.pdf, I've copied the file I used and renamed and it's yours...
on my machine with pdf and my real file takes
2min 35sec with KIT
24 min with PDF
with your file (7 file per page, mine was 16) takes
0:27 with KIT
2min 05 with PDF (7.1)
Can you please investigate?
Thanks