Site Feedback Thread

2 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

iTextSharp RAM (memory) overflow

Back to Forum: Site Feedback
  • User profile image

    I'm generating a PDF document based on template. The document has multiple pages. The document can have about 5000 pages. When creating the 500-th page I get an overflow RAM (memory). Any idea?

    Thanks in advance.

    public static void CreateBankBlank2012Year(string pdfTemplatePath, string directoryOutPdf, string nameOutPdf, AnnualReportsFilterParameters filterParametrs, string serverPath)
    // Get details salary
    IEnumerable<SalayDetailsForPdf> dataSalaryDetails = (IEnumerable<SalayDetailsForPdf>) GetSalaryData(filterParametrs); 
    String fontPath = Path.Combine(serverPath + "\\Fonts", "STSONG.ttf");
    Font font = FontFactory.GetFont(fontPath, BaseFont.IDENTITY_H, 8);
    using (Document document = new Document())
    using (PdfSmartCopy copy = new PdfSmartCopy(
    document, new FileStream(directoryOutPdf + nameOutPdf, FileMode.Create))
    foreach (var data in dataSalaryDetails) 
    PdfReader reader = new PdfReader(pdfTemplatePath + @"\EmptyTemplateBankBlank_2012.pdf");
    using (var ms = new MemoryStream())
    using (PdfStamper stamper = new PdfStamper(reader, ms))
    AcroFields form = stamper.AcroFields;
    form.SetField("t1_address1", data.Address1);
    form.SetField("t1_name", data.NameHieroglyphic);
    // Other field ...
    stamper.FormFlattening = true;
    reader = new PdfReader(ms.ToArray());
    copy.AddPage(copy.GetImportedPage(reader, 1));

  • User profile image

    @KapMaximus: You'd probably get better responses if you posted this on a page associated with iTextSharp.

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.