private void print_Form(JCF_Submission submission) { string filename = string.Empty; Document document = new Document(); Section section; JCF_Submission_Facade submission_Facade = new JCF_Submission_Facade(); Flow_Rec_Facade flow_Rec_Facade = new Flow_Rec_Facade(); Flow_Rec parent_Flow; List <Abstract_Iter_able> form_List = new List <Abstract_Iter_able>(); List <Abstract_Iter_able> flow_List = flow_Rec_Facade.GetByIdWhere(submission.SubmissionID, "Submission_ID"); if (flow_List.Count > 0) { parent_Flow = (Flow_Rec)flow_Rec_Facade.GetByIdWhere(submission.SubmissionID, "Submission_ID")[0]; List <Abstract_Iter_able> flow_objs = flow_Rec_Facade.GetByIdWhere(parent_Flow.ID, "Parrent_Flow"); List <Abstract_Iter_able> submissions; form_List.Add(submission); foreach (Flow_Rec flow_obj in flow_objs) { submissions = submission_Facade.GetByIdWhere(flow_obj.Submission_ID, "SubmissionID"); if (submissions.Count > 0) { form_List.Add(submissions[0]); } } } else { form_List.Add(submission); } Paragraph answer_Paragraph = new Paragraph(); Paragraph question_Pragraph = new Paragraph(); Paragraph header_Paragaraph = new Paragraph(); List <Color> color_List = new List <Color>() { Colors.Red, Colors.Orange, Colors.Yellow, Colors.Green, Colors.Blue, Colors.Indigo, Colors.Violet }; int i = 0; foreach (JCF_Submission submissionForm in form_List) { section = document.AddSection(); header_Paragaraph = section.AddParagraph(GetFormHeader(submissionForm)); header_Paragaraph.Format.Alignment = ParagraphAlignment.Left; header_Paragaraph.Format.Font.Name = "Times New Roman"; header_Paragaraph.Format.Font.Color = Colors.Black; header_Paragaraph.Format.Borders.Distance = "5pt"; header_Paragaraph.Format.Borders.Color = color_List[i % 7]; header_Paragaraph.Format.Font.Size = 16; List <JCF_FormItem> questions = new JICSBaseFacade <JCF_FormItem>().GetQuery().Where(x => x.FormID == submissionForm.FormID).OrderBy(x => x.QuestionNum).ThenBy(x => x.RowNum).ToList(); foreach (JCF_FormItem question in questions) { question_Pragraph = section.AddParagraph(StripHTML(current_Viewable.nullCheck(question.Text).ToString())); question_Pragraph.Format.Alignment = ParagraphAlignment.Left; question_Pragraph.Format.Font.Name = "Times New Roman"; question_Pragraph.Format.Font.Color = Colors.Black; question_Pragraph.Format.Font.Size = 12; question_Pragraph.Format.Borders.Distance = "5pt"; question_Pragraph.Format.Borders.Color = color_List[i % 7]; List <JCF_Answer> answers = new JICSBaseFacade <JCF_Answer>().GetQuery().Where(x => x.ItemID == question.ID && x.SubmissionID == submissionForm.SubmissionID).ToList(); if (answers.Count > 0) { foreach (JCF_Answer answer in answers) { answer_Paragraph = section.AddParagraph(StripHTML(current_Viewable.nullCheck(answer.AnswerValue).ToString())); answer_Paragraph.Format.Alignment = ParagraphAlignment.Justify; answer_Paragraph.Format.Font.Name = "Times New Roman"; answer_Paragraph.Format.Font.Color = Colors.DarkGray; answer_Paragraph.Format.Font.Size = 12; } } else { answer_Paragraph = section.AddParagraph(" "); answer_Paragraph.Format.Alignment = ParagraphAlignment.Justify; answer_Paragraph.Format.Font.Size = 12; } } i++; } PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer(false); pdfRenderer.Document = document; pdfRenderer.RenderDocument(); filename = GetSubmissionFileName(submission); EventLog.WriteEntry("ICSNET", "FILENAME:" + filename, EventLogEntryType.Information); Response.Clear(); Response.ContentType = "application/pdf"; MemoryStream stream = new MemoryStream(); pdfRenderer.PdfDocument.Save(stream, false); Response.AddHeader("Content-Disposition", "attachment; filename=" + filename); Response.AddHeader("content-length", stream.Length.ToString()); Response.BinaryWrite(stream.ToArray()); Response.Flush(); stream.Close(); Response.End(); }