Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用ItextSharp生成Pdf文件时缺少锚定的下划线和蓝色_C#_Html_Asp.net_Itext - Fatal编程技术网

C# 使用ItextSharp生成Pdf文件时缺少锚定的下划线和蓝色

C# 使用ItextSharp生成Pdf文件时缺少锚定的下划线和蓝色,c#,html,asp.net,itext,C#,Html,Asp.net,Itext,我得到了pdf格式的链接,但使用相同的iTextSharp的锚定标记缺少下划线和蓝色 引文字段中的引文列需要超链接。引用字符串具有锚定标记 请让我知道如何为锚定标记下划线和蓝色应用自己的格式 protected void GeneratePdfReport(DataTable RRDT) { // DataRow dr = GetData("SELECT * FROM Employees where EmployeeId = " + ddlEmployees.SelectedItem.V

我得到了pdf格式的链接,但使用相同的iTextSharp的锚定标记缺少下划线和蓝色

引文字段中的引文列需要超链接。引用字符串具有锚定标记

请让我知道如何为锚定标记下划线和蓝色应用自己的格式

 protected void GeneratePdfReport(DataTable RRDT)
{
   // DataRow dr = GetData("SELECT * FROM Employees where EmployeeId = " + ddlEmployees.SelectedItem.Value).Rows[0]; ;
   // DataRow dr = RRDT.Rows[0];

    try
    {
        Document document = new Document(PageSize.A4, 40f, 88f, 30f, 10f);
        Font NormalFont = FontFactory.GetFont("Arial", 12, Font.NORMAL, Color.BLACK);
        using (System.IO.MemoryStream memoryStream = new System.IO.MemoryStream())
        {
            PdfWriter writer = PdfWriter.GetInstance(document, memoryStream);
            Phrase phrase = null;
            PdfPCell cell = null;
            PdfPTable table = null;
            Color color = null;

            document.Open();

            //Header Table
            table = new PdfPTable(1);
            table.TotalWidth = 500f;
            table.LockedWidth = true;
            //    table.SetWidths(new float[] { 1f });
            table.SpacingBefore = 20f;
            table.HorizontalAlignment = Element.ALIGN_LEFT;

            string TempCollege = "";
            string TempDepartment = "";
            string TempPublication = "";



            foreach (DataRow dr in RRDT.Rows)
            {

                if (dr["College"].ToString() != TempCollege || TempCollege == "")
                {

                //Citation
                phrase = new Phrase();
                phrase.Add(new Chunk(HttpUtility.HtmlDecode(dr["Citation"].ToString()) + "\n", FontFactory.GetFont("Arial", 10, Font.NORMAL, Color.BLACK)));
                cell = PhraseCell(phrase, PdfPCell.ALIGN_LEFT);
                cell.PaddingBottom = 3f;
                cell.PaddingTop = 3f;

                table.AddCell(cell);
            }

            document.Add(table);

            document.Close();


                byte[] bytes = memoryStream.ToArray();
                memoryStream.Close();
                Response.Clear();
                Response.ContentType = "application/pdf";
                Response.AddHeader("Content-Disposition", "attachment; filename=ResearchReport.pdf");
                Response.Buffer = true;
                Response.Cache.SetCacheability(HttpCacheability.NoCache);
                Response.BinaryWrite(bytes);
                Response.ContentEncoding = Encoding.UTF8;
                HttpContext.Current.Response.Flush(); 
                HttpContext.Current.Response.SuppressContent = true;  
                HttpContext.Current.ApplicationInstance.CompleteRequest();
        }
    }
    catch (ThreadAbortException ex)
    {
        String errorString = "Something went wrong:";
        UCSparkCommon.SendExceptionEmail(errorString, ex);
    }
    catch (Exception ex)
    {
        String errorString = "Something went wrong:";
        UCSparkCommon.SendExceptionEmail(errorString, ex);
    }
}
据称,itext锚不采用默认颜色/下划线设置样式。您必须应用自己的样式

它们不应该是,因为它们不一定是超链接


希望能有所帮助。

有解决这个问题的代码吗?我们看不到你屏幕上的内容。