Tafsir Ahamed

Tafsir Ahamed

  • NA
  • 62
  • 960

Generate pdf from rich text column in sharepoint 2013 c#

Mar 29 2022 11:59 AM

I have a rich text column in my sharepoint 2013 list. I want to export the contents of that column as pdf and save it to local file system. I tried to do it by using Spire.Doc and iTextSharp but didn't work.

private static void DownloadFiles(SPListItem item)
{
    try
    {
        string _strPDF = Convert.ToString(item["More Details"]);
        string _strPDFTitle = Convert.ToString(item["Project"]);

        FileStream fs = new FileStream(@"C:\Users\Administrator\" + _strPDFTitle + ".pdf", FileMode.Create, FileAccess.Write, FileShare.None);

        Document doc = new Document();
        PdfWriter oPdfwriter = PdfWriter.GetInstance(doc, fs);
        doc.Open();
        doc.Add(new Paragraph(_strPDF));
        doc.Close();
    }
    catch (Exception ex)
    {
        //throw ex;
        Console.WriteLine("DownloadFiles method error: {0}", ex.Message);
    }
}

Is there any way to achieve this? 


Answers (1)