1
Answer

Multiple records to be displayed on a single pdf file

Toh Zuan Yi

Toh Zuan Yi

13y
1.3k
1
hi guys forget about that previous question i asked, i already got the answer for it. Now the question is, after the user presses print button it navigates him to a page with 2 textboxes each controlled by a calender extender. so when the user selects 2 dates and presses print, all the records within the 2 dates will be selected and shown on a SINGLE PDF file. E.g a PDF file but with many pages. I have did the dummy for displaying a single record and it worked, but i need to do multiple records be it 2 records or 3 records for 4 or 5 and so on. can anyone help me with this? here is my code if u guys need references.

using System;
using System.IO;
using TallComponents.PDF.Layout;
using TallComponents.PDF.Layout.Paragraphs;
using TallComponents.PDF.Layout.Brushes;
using TallComponents.PDF.Layout.Fonts;


public partial class Diary_PDFMedicationList : System.Web.UI.Page
{
  protected void Page_Load(object sender, EventArgs e)
  {

  // create document
  Document doc = new Document();

 Section section = doc.Sections.Add();
  section.PageSize = PageSize.A4;

  int medicationListID = int.Parse(Request.QueryString["MedicationListID"]);

  MedicationList medicationList = DataManager.SelectMedicationList(medicationListID);
 
  for (int i = 0; i < 1; i++)
  {
  TextParagraph text = new TextParagraph();
  text.SpacingAfter = 10;
  text.Fragments.Add(new Fragment("Name of Medication: ", 16));
  section.Paragraphs.Add(text);
  }
  for (int i = 0; i < 1; i++)
  {
  TextParagraph text = new TextParagraph();
  text.SpacingAfter = 20;
  text.Fragments.Add(new Fragment(medicationList.MedicationName));
  section.Paragraphs.Add(text);
  }
  for (int i = 0; i < 1; i++)
  {
  TextParagraph text1 = new TextParagraph();
  text1.SpacingAfter = 10;
  text1.Fragments.Add(new Fragment("Dose:", 16));
  section.Paragraphs.Add(text1);
  }
  for (int i = 0; i < 1; i++)
  {
  TextParagraph text = new TextParagraph();
  text.SpacingAfter = 20;
  text.Fragments.Add(new Fragment(medicationList.Dose));
  section.Paragraphs.Add(text);
  }
  for (int i = 0; i < 1; i++)
  {
  TextParagraph text2 = new TextParagraph();
  text2.SpacingAfter = 10;
  text2.Fragments.Add(new Fragment("Frequency:", 16));
  section.Paragraphs.Add(text2);
  }
  for (int i = 0; i < 1; i++)
  {
  TextParagraph text = new TextParagraph();
  text.SpacingAfter = 20;
  text.Fragments.Add(new Fragment(medicationList.Frequency));
  section.Paragraphs.Add(text);
  }
  for (int i = 0; i < 1; i++)
  {
  TextParagraph text3 = new TextParagraph();
  text3.SpacingAfter = 10;
  text3.Fragments.Add(new Fragment("Prescribing Physician:", 16));
  section.Paragraphs.Add(text3);
  }
  for (int i = 0; i < 1; i++)
  {
  TextParagraph text = new TextParagraph();
  text.SpacingAfter = 20;
  text.Fragments.Add(new Fragment(medicationList.PrescribingPhysician));
  section.Paragraphs.Add(text);
  }
  for (int i = 0; i < 1; i++)
  {
  TextParagraph text4 = new TextParagraph();
  text4.SpacingAfter = 10;
  text4.Fragments.Add(new Fragment("Started When:", 16));
  section.Paragraphs.Add(text4);
  }
  for (int i = 0; i < 1; i++)
  {
  TextParagraph text = new TextParagraph();
  text.SpacingAfter = 20;
  text.Fragments.Add(new Fragment(medicationList.StartDate.ToString()));
  section.Paragraphs.Add(text);
  }
  for (int i = 0; i < 1; i++)
  {
  TextParagraph text5 = new TextParagraph();
  text5.SpacingAfter = 10;
  text5.Fragments.Add(new Fragment("Indicate if recent change in dose:", 16));
  section.Paragraphs.Add(text5);
  }
  for (int i = 0; i < 1; i++)
  {
  TextParagraph text = new TextParagraph();
  text.SpacingAfter = 20;
  text.Fragments.Add(new Fragment(medicationList.ChangeInDosage));
  section.Paragraphs.Add(text);
  }

  TextParagraph textParagraph = new TextParagraph();
  section.Paragraphs.Add(textParagraph);
  Fragment fragment = new Fragment();
  textParagraph.Fragments.Add(fragment);

  Area area = new Area(section.PageSize.Width - 350, section.PageSize.Height-20, 115, 500);

  section.ForegroundAreas.Add(area);

  fragment = new Fragment("Print Details", Font.TimesBold, 20);

  fragment.TextColor = System.Drawing.Color.Black;

  textParagraph = new TextParagraph();

  textParagraph.Fragments.Add(fragment);

  textParagraph.Border = new Border(new SolidBrush(System.Drawing.Color.White));

  area.Paragraphs.Add(textParagraph);


  // save the PDF directly to the browser
  doc.Write(Response);
  }
}

Answers (1)