从内存流中读取存储的PDF我正在使用C#和SQLServer2012开发一个数据库项目。在我的一个表单中,我有一个PDF文件,其中的一些附加信息存储在表格中。这样就成功了,但是当我要取回存储的信息的时候,显示PDF文件就出问题了,因为显示不了,不知道怎么显示。我读到它无法在内存流中使用Adob??ePDF查看器显示,有什么办法吗?这是我从数据库中检索数据的代码:sql_com.CommandText="select*fromincoming_boks_tblwhere[incoming_bok_id]=@incoming_idand[incoming_date]=@incoming_date";sql_com.Parameters.AddWithValue("incoming_id",up_inco_num_txt.Text);sql_com.Parameters.AddWithValue("incoming_date",up_inco_date_txt.Text);sql_dr=sql_com.ExecuteReader();如果(sql_dr.HasRows){而(sql_dr.Read()){up_incoming_id_txt.Text=sql_dr[0].ToString();up_inco_num_txt.Text=sql_dr[1].ToString();up_inco_date_txt.Text=sql_dr[2].ToString();up_inco_reg_txt.Text=sql_dr[3].ToString();up_inco_place_txt.Text=sql_dr[4].ToString();up_in_out_txt.Text=sql_dr[5].ToString();up_subj_txt.Text=sql_dr[6].ToString();up_note_txt.Text=sql_dr[7].ToString();stringfile_ext=sql_dr[8].ToString();//pdf文件扩展名byte[]inco_file=(byte[])(sql_dr[9]);//pdf文件MemoryStreamms=newMemoryStream(inco_file);//在这里我不知道该怎么做h内存流文件数据及其存储位置。我怎样才能显示它?这个答案应该给你一些选择:HowtorenderapdfusingC#过去,我使用过谷歌的开源PDF渲染项目——PDFium有一个名为AC#nugetpackageforPdfiumViewer的工具,它提供了一个C#包装器允许显示和打印PDF的PDFium直接与Streams一起工作,因此不需要将数据写入磁盘这是我在WinForms应用程序中的示例以上是C#学习教程:读取存储的PDF共享的所有内容内存流。如果对你有用,需要进一步了解C#学习教程,希望大家多多关注——publicvoidLoadPdf(byte[]pdfBytes){varstream=newMemoryStream(pdfBytes);LoadPdf(stream)}publicvoidLoadPdf(Streamstream){//创建PDF文档varpdfDocument=PdfDocument.Load(stream);//将PDF文档加载到WinForms控件中pdfRenderer.Load(_pdfDocument);}本文收集自网络,不代表立场。如涉及侵权,请点击右侧联系管理员删除。如需转载请注明出处:
