我想使用itextsharp库将gridview导出为pdf.问题是在pdf文档中缺少一些土耳其字符,如İ,ı,Ş,ş等.用于导出pdf的代码是:
protected void LinkButtonPdf_Click(object sender, EventArgs e)
{
Response.ContentType = "application/pdf";
Response.ContentEncoding = System.Text.Encoding.UTF8;
Response.AddHeader("content-disposition", "attachment;filename=FileName.pdf");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
System.IO.StringWriter stringWrite = new StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
GridView1.RenderControl(htmlWrite);
StringReader reader = new StringReader(textConvert(stringWrite.ToString()));
Document doc = new Document(PageSize.A4);
HTMLWorker parser = new HTMLWorker(doc);
PdfWriter.GetInstance(doc, Response.OutputStream);
doc.Open();
parser.Parse(reader);
doc.Close();
}
public static string textConvert(string S)
{
if (S == null) { return null; }
try
{
System.Text.Encoding encFrom = System.Text.Encoding.UTF8;
System.Text.Encoding encTo = System.Text.Encoding.UTF8;
string str = S;
Byte[] b = …Run Code Online (Sandbox Code Playgroud) 我试图将参数传递给 Xamarin.Forms 中的视图模型。但是我也想在加载页面时使用它,以使用该参数调用休息服务。但是在加载事件参数中始终为 null。(如果我可以看到该参数将其绑定到标签等...)我怎样才能使其正常工作并在视图模型的加载事件中使用该参数?任何帮助表示赞赏,谢谢
这是按钮单击事件并导航到 Samplepage。
private void OntaptedBildirimItem(string param)
{
this._navigationService.NavigateTo(nameof(Views.SamplePage), param);
}
Run Code Online (Sandbox Code Playgroud)
这是示例页面视图模型
private string _id;
public string id
{
get
{
return _id;
}
set
{
Set(() => id, ref _id, value);
}
}
public SamplePageViewModel(INavigationService navigationService) : base(navigationService)
{
this._navigationService = navigationService;
this.Title = "Sample Page=" + id; // here the id is always null,but if I use it to bind a label in xaml ,it has a value.
}
Run Code Online (Sandbox Code Playgroud)
这是示例页面代码
public SamplePage(string parameter)
{
InitializeComponent(); …Run Code Online (Sandbox Code Playgroud) 我想将页码添加到itextsharp pdf文件的页脚.我从html(asp.net repeater)生成pdf.我使用XMLWorkerHelper来解析html内容.我搜索了很多但是找不到任何有用的东西来实现这一点.