Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6013465
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:33:08+00:00 2026-05-23T02:33:08+00:00

I am trying to Export database table content in my pdf through the code

  • 0

I am trying to Export database table content in my pdf through the code on clicking on a link button I am calling this following function on a link button

        public void EXportCaseAsText(int caseid)
        {

        DateTime pubdate = new DateTime();
       // System.IO.MemoryStream msReport = new System.IO.MemoryStream();
        int pageno = 1, questionno = 1;
        int count = BlFactory.CipCaseWorkflowItemBl.LoadWorkflowForCase(caseid).Count;
        Font HeaderFont = FontFactory.GetFont(FontFactory.TIMES_ROMAN, 14, Font.BOLD, iTextSharp.text.Color.RED);
        Font OptionsFont = FontFactory.GetFont(FontFactory.TIMES_ROMAN, 10, Font.BOLD, iTextSharp.text.Color.BLACK);
        Font TrueFont = FontFactory.GetFont(FontFactory.TIMES_ROMAN, 10, Font.UNDERLINE, iTextSharp.text.Color.BLUE);
        Font dataFont = FontFactory.GetFont(FontFactory.TIMES_ROMAN, 10, Font.NORMAL, iTextSharp.text.Color.BLACK);
        Font datefont = FontFactory.GetFont(FontFactory.TIMES_ROMAN, 14, Font.BOLD, iTextSharp.text.Color.BLUE);
        if (count > 0)
        {

            try
            {
                Document document = new Document(PageSize.A4);
                //PdfWriter.GetInstance(document, new FileStream("D:\\RCMS\\Acr3S.Cmf.Web\\bin\\Debug\\my.pdf", FileMode.Create));

                PdfWriter writer = PdfWriter.GetInstance(document, Response.OutputStream);

                document.Open();

                DateTime pub = getCasePublishedDate(caseid);
                if (pub.ToShortDateString().Equals("1/1/0001"))
                {
                    Paragraph paragraph = new Paragraph(new Paragraph("Not yet published",datefont));
                    paragraph.Alignment = Element.ALIGN_CENTER;
                    document.Add(paragraph);
                }
                else
                {
                    string date = DateFormatter.GetFormattedDate(pub);
                    Paragraph paragraph = new Paragraph(new Paragraph(date, datefont));
                    paragraph.Alignment = Element.ALIGN_CENTER;
                    document.Add(paragraph);

                }

                for (int i = 0; i < count; i++)
                {
                    CipCaseWorkflowItem item = (new NHibernate.DebugHelpers.CollectionProxy<Acr3S.Core.Domain.CipCaseWorkflowItem>
                                            (BlFactory.CipCaseWorkflowItemBl.LoadWorkflowForCase(caseid))).Items[i];

                    switch (item.Type)
                    {
                        case CaseContentItemType.BaseCaseTextElement:
                            {
                                CipTextElementScriptItem textItem = (CipTextElementScriptItem)BlFactory.CipCaseWorkflowItemBl.LoadWorkflowForCase(caseid, item.Id);

                                if (textItem != null && textItem.Id!=null && textItem.ContentElement !=null)
                                {
                                    switch (textItem.ElementType.ToString())
                                    {
                                        case "Diagnosis":
                                            {
                                                Paragraph par = new Paragraph("Diagnosis", HeaderFont);
                                                //Chunk chunk = new Chunk(textItem.ContentElement.PlainText.Trim(), dataFont);
                                                //par.Add("\n");
                                                //par.Add(chunk);
                                                document.Add(par);
                                                StyleSheet styles = new StyleSheet();
                                                ArrayList objects = HTMLWorker.ParseToList(new StringReader(textItem.ContentElement.Text), styles);
                                                for (int k = 0; k < objects.Count; ++k)
                                                {
                                                    document.Add((IElement)objects[k]);
                                                }
                                                break;
                                            }
                                        case "History":
                                            {
                                                Paragraph par = new Paragraph("History", HeaderFont);
                                                //Chunk chunk = new Chunk(textItem.ContentElement.PlainText.Trim(), dataFont);
                                                //par.Add("\n");
                                                //par.Add(chunk);
                                                document.Add(par);
                                                StyleSheet styles = new StyleSheet();
                                                ArrayList objects = HTMLWorker.ParseToList(new StringReader(textItem.ContentElement.Text), styles);
                                                for (int k = 0; k < objects.Count; ++k)
                                                {
                                                    document.Add((IElement)objects[k]);
                                                }
                                                break;
                                            }



                                        case "Discussion":
                                            {
                                                Paragraph par = new Paragraph("Discussion", HeaderFont);
                                                //par.Add("\n");
                                                //Chunk chunk = new Chunk(textItem.ContentElement.PlainText.Trim(), dataFont);
                                                //par.Add(chunk);
                                                document.Add(par);
                                                StyleSheet styles = new StyleSheet();
                                                ArrayList objects = HTMLWorker.ParseToList(new StringReader(textItem.ContentElement.Text), styles);
                                                for (int k = 0; k < objects.Count; ++k)
                                                {
                                                    document.Add((IElement)objects[k]);
                                                }
                                                break;
                                            }


                                        case "CasePoints":
                                            {
                                                Paragraph par = new Paragraph("Case Points", HeaderFont);
                                                //Chunk chunk = new Chunk(textItem.ContentElement.PlainText.Trim(), dataFont);
                                                //par.Add("\n");
                                                //par.Add(chunk);
                                                document.Add(par);
                                                StyleSheet styles = new StyleSheet();
                                                ArrayList objects = HTMLWorker.ParseToList(new StringReader(textItem.ContentElement.Text), styles);
                                                for (int k = 0; k < objects.Count; ++k)
                                                {
                                                    document.Add((IElement)objects[k]);
                                                }
                                                break;
                                            }



                                    }
                                }

                                break;
                            }

                    }
                }
                document.Close();
                Response.AddHeader("content-disposition", "attachment;filename=" + getCaseName(caseid) + ".pdf");
                Response.ContentType = "application/pdf";
                Response.End();

            }

            catch (DocumentException de)
            {
                Console.Error.WriteLine(de.Message);
            }


        }

    }

The problem is somethime Discussion data is not showing in pdf something History data is not showing in pdf sometime case point data is not showing in pdf while all data is present in table

I am not getting why it is happening

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T02:33:09+00:00Added an answer on May 23, 2026 at 2:33 am

    Replace

    document.Add(par);
    StyleSheet styles = new StyleSheet();
    ArrayList objects = HTMLWorker.ParseToList(new StringReader(textItem.ContentElement.Text), styles);
    for (int k = 0; k < objects.Count; ++k)
    {
      document.Add((IElement)objects[k]);
    }
    

    By

    // New Code implemented:

    document.Add(par);
    StyleSheet styles = new StyleSheet();
    string tempText = textItem.ContentElement.Text;
    tempText = tempText.Replace("\"", "&#34;");
    ArrayList objects = HTMLWorker.ParseToList(new StringReader(tempText), styles);
    for (int k = 0; k < objects.Count; ++k)
    {
        document.Add((IElement)objects[k]);
    }
    

    this will work fine…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to bulk export out of a sql table, the code works
I've got this code I'm trying to use to export data from Excel to
I'm trying to export an Excel database into .txt (Tab Delimited), but some of
Im trying to export a .dmp of an oracle database but am getting the
I'm trying to export the schema of my database so another developer can have
I am trying to do an automated xml export from an access database using
I trying to export an HTML table named Table that is dynamically binded to
I am trying to export data from database to an excel sheet, using php
I'm trying to export my application's database to SDcard. It works excellent for emulator,
I'm trying to export some data from MATLAB to a database. I use a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.