如何在pdf文件中显示stringbilder数据? [英] how to show stringbilder data in pdf file?

查看:62
本文介绍了如何在pdf文件中显示stringbilder数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在提供示例示例

正在打开pdf文件,但未播放数据


i am giving sample example

it is opening pdf file but data is not played


Response.Clear();
Response.Buffer = true;
Response.AddHeader("content-disposition", "attachment;filename=sample.pdf");
Response.ContentType = "application/pdf";
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append("<table cellpadding=2 cellspacing=1 border=1 width=800 height=500>");
sb.Append ("<tr>");
sb.Append("<td>column-1</td><td>column-2</td><td>column-3</td><td>column-4</td><td>column-5</td><td>column-6</td><td>column-7</td><td>column-8</td>");
sb.Append ("</tr>");
sb.Append ("<tr>");
sb.Append ("<td>1</td><td>2</td><td>3</td><td>4</td><td>5</td><td>6</td><td>7</td><td>8</td>");
sb.Append ("</tr>");
sb.Append("</table>");
Response.Write(sb.ToString ());
Response.End();



修改TR-请使用< pre>标签周围的代码,使其更易于阅读.



Edit TR - Please use <pre> tags around your code, makes it easier to read.

推荐答案

这将不起作用.您发送给浏览器的响应是HTML文件,而不是PDF.设置Response.ContentType不足以产生PDF.

您将要查看一个库,例如 iTextSharp [
This will not work. The response you are sending the browser is an HTML file, not a PDF. Setting Response.ContentType is not enough to produce the PDF.

You''re going to want to look at a library such as iTextSharp[^]to create the PDF. You can then send the generated file in the response.


这篇关于如何在pdf文件中显示stringbilder数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆