在C#中从字节数组创建pdf [英] Creating a pdf from byte array in C#

查看:74
本文介绍了在C#中从字节数组创建pdf的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello All,



我有字节数组,我正在尝试使用下面的代码从中创建一个pdf。它没有显示任何错误/异常,但pdf也没有下载。



我在sql中使用image数据类型从db获取此字节数组/>


有人可以告诉我我在哪里做错了或从字节数组创建pdf的任何其他替代解决方案。



Hello All,

I have byte array and am trying to create a pdf from it using below code. Its not showing any error/exception but pdf also not getting downloaded.

Am getting this byte array from "db" while am using "image" datatype in sql

Can someone tell me where i am doing mistake or any other alternate solution for creating pdf from byte array.

private void downloadpdf(byte[] pdf)
        {

            Byte[] bytes = pdf;
            Response.Clear();

            MemoryStream ms = new MemoryStream(bytes);
            Response.ContentType = "application/pdf";
            Response.AddHeader("content-disposition", "attachment;filename=test.pdf");
            Response.Buffer = true;
            ms.WriteTo(Response.OutputStream);

            Response.End();











先谢谢






Thanks in Advance

推荐答案

在codeproject中有一篇关于你现在正在搜索的内容的文章,播种找到它或发布的内容足够代码,开发人员会帮助你。



希望有帮助
There is an entire article in codeproject about what you searching now, sow find it or post enough code such that developers will help you.

Hope that helps


这篇关于在C#中从字节数组创建pdf的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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