如何在c#中将rtf内容转换为pdf文档? [英] How to convert rtf content to pdf document in c#?

查看:257
本文介绍了如何在c#中将rtf内容转换为pdf文档?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

实际上我有内容的word文档,我只是从文档中获取加密内容,然后我转换为



使用



MemoryStream objMemory = new MemoryStream(Convert.FromBase64String(data));



如何获取原始内容并将其存储到字符串变量 - 用于保存PDF文档中的内容



如果有人知道任何关于此的内容,请分享您的想法????



我正在尝试将rtf内容转换为pdf文档,同时尝试转换

i得到这样的输出...

PK \ 0 \ 0 \\\\\\\\\\\\\\\\\\\\\\\\\\\\\ [0] 0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\\ \\ 0 \\\\\\\\\\\\\\\\\\\ 0等等



我尝试过:



Microsoft.Office.Interop.Word.Application appWord = new Microsoft.Office.Interop.Word.Application();



在我的应用程序中使用它时我在创建应用程序类时遇到错误

检索具有CLSID {000209FF-0000的组件的COM类工厂由于以下错误,-0000-C000-000000000046}失败:80070005拒绝访问。 (来自HRESULT的异常:0x80070005(E_ACCESSDENIED))



MemoryStream objMemory = new MemoryStream(Convert.FromBase64String(data));

StreamWriter sw = new StreamWriter(ms_Obj);

sw.Flush();

ms_Obj.Position = 0;

StreamReader sr = new StreamReader(ms_Obj );

string myStr = sr.ReadToEnd();



输出内容:

PK \ 0 \\\\\\\\\\\\\\\\\\\\\\ [Content_Types] .xml ( \0 \0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\ 0 \\\\\\\\\\\\\\\\\\\ 0等等

Actually I have word document with contents, I just get the encrypted content from the document, then i converted that

using

MemoryStream objMemory = new MemoryStream(Convert.FromBase64String(data));

how to get the original content and store that to string variable - for saving that contents in PDF Document

If anyone know anything about this kindly share your ideas????

I am trying to convert the rtf content to pdf document, while trying to convert
i got the output like this...
PK\0\0\b\0\0\0!\0ߤ�lZ\0\0 \0\0\0\b[Content_Types].xml �(�\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0 etc

What I have tried:

Microsoft.Office.Interop.Word.Application appWord = new Microsoft.Office.Interop.Word.Application();

while using this in my application i got a err while creating Application Class
Retrieving the COM class factory for component with CLSID {000209FF-0000-0000-C000-000000000046} failed due to the following error: 80070005 Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))

MemoryStream objMemory = new MemoryStream(Convert.FromBase64String(data));
StreamWriter sw = new StreamWriter(ms_Obj);
sw.Flush();
ms_Obj.Position = 0;
StreamReader sr = new StreamReader(ms_Obj);
string myStr = sr.ReadToEnd();

Output content :
PK\0\0\b\0\0\0!\0ߤ�lZ\0\0 \0\0\0\b[Content_Types].xml �(�\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0 etc

推荐答案

您无法使用流来读取或写入这些文件,您必须使用相应的库。对于MSWord,请参阅 Microsoft.Office.Interop.Word名称空间() [ ^ ]和PDF格式见 iTextSharp,一个.NET PDF库SourceForge.net [ ^ ]。
You cannot use streams to read or write these files, you must use the appropriate libraries. For MSWord see Microsoft.Office.Interop.Word namespace ()[^] and for PDF see iTextSharp, a .NET PDF library | SourceForge.net[^].


这篇关于如何在c#中将rtf内容转换为pdf文档?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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