2017-02-28 5 views
0

を生成するItextSharpを使用している間、私は、PDF内のリンクを取得していますが、色が引用フィールドにハイパーリンクを必要と同じiTextSharp欠落下線とアンカーの青色のPDFファイル

引用列を使用してアンカータグのために不足している下線と青。引用文字列にアンカータグがあります。

私はそれは、iTextのアンカーは、デフォルト(カラー/下線)でスタイリングされていないhereを記載されている

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); 
    } 
} 
+1

その問題に付随するコードはありますか?あなたの画面に何が表示されているのかわかりません。 – Filburt

答えて

1

アンカータグ(下線、ブルー色)のために独自の書式を適用する方法を教えてください。あなたは自分のスタイリングを適用する必要があります。

これらは必ずしもハイパーリンクではありません。

希望します。