ITextSharp errror only in Production

Viewed 145

I have a very weird situation. In my local host and test environment everything working as expected. This is the code

using (PdfCopy copy = new PdfCopy(document, new 
        FileStream(combinedDocumentPath, FileMode.Create)))
{ 
    document.Open();
    PdfReader reader;
    combinedDocument.Name = fileName;
    combinedDocument.CreatedDate = System.DateTime.Now;

    SplittedItem splittedItem = new SplittedItem();
    for (int i = 0; i < source_files.Length; i++)
    {
        reader = new PdfReader(source_files[i]);

        int page = 1;
        copy.AddPage(copy.GetImportedPage(reader, page));

        splittedItem = _unitOfWork.SplittedItemRepository.Get(list.ElementAt(i).SplittedItemId);
        splittedItem.Status = (int)Status.Combined;
        splittedItem.UpdatedDate = System.DateTime.Now;
        _unitOfWork.SplittedItemRepository.Update(splittedItem);
        reader.Close();
    }
}

if (!isPdf)
{
    PdfHelper.PdfToTiffSpire(combinedDocumentPath);
    System.IO.File.Delete(combinedDocumentPath);
    combinedDocument.Name = fileName.Replace(".pdf", ".tiff");
}

But this is not working as expected in production environment SOMETIMES ONLY SOMETIMES I GOT ERROR LIKE THIS

Ex message is:

The document has no pages. ex stack trace is :

iTextSharp.text.pdf.PdfPages.WritePageTree()
iTextSharp.text.pdf.PdfWriter.Close()
iTextSharp.text.pdf.PdfCopy.Close()
iTextSharp.text.pdf.PdfCopy.Close()
0 Answers
Related