private void RenderConvictToPdf(Convict convict, Aspose.Pdf.Generator.Pdf pdf) { var section = pdf.Sections.Add(); RenderPersonInfoToSection(convict, section); foreach (var crime in convict.Crimes) { RenderCrimeInfoToSection(crime,section); } }
private void RenderPersonInfoToSection(Convict convict, Section section) { var sb = new StringBuilder(); sb.Append("\n"); sb.Append("\n"); AppendLineBreak(sb); sb.Append(string.Format(convictInfoTemplate, convict.FullName, DateTime.Now.Year - convict.DateOfBirth.Year, Enum.GetName(typeof(Gender), convict.Gender), convict.Height, convict.Weight)); AppendLineBreak(sb); InsertParagraph(sb.ToString(), section); }
/// <summary> /// Creates a pdf representation for a convict and saves it to the output stream /// </summary> /// <param name="convict">The input data that is to be rendered</param> /// <param name="output">An output stream to hold the resulting pdf.This stream's disposal should be managed externaly</param> public void CreatePdf(Convict convict, Stream output) { var pdf = new Aspose.Pdf.Generator.Pdf(); RenderConvictToPdf(convict,pdf); pdf.Save(output); }