如何将PDF加载到内存中,然后通过acrobat阅读器进行读取

本文关键字:acrobat 读取 然后 PDF 加载 内存 | 更新日期: 2023-09-27 18:26:57

我想做的是从闪存驱动器将pdf加载到内存中,然后通过acrobat阅读器读取pdf。其想法是,如果用户移除闪存,他/她仍然可以读取pdf,因为它已加载到内存/RAM中。我试着使用我从这个线程得到的下面的代码将MemoryStream保存到文件或从文件加载MemoryStream

这用于写入文件

FileStream file = new FileStream("file.bin", FileMode.Create, System.IO.FileAccess.Write);
byte[] bytes = new byte[ms.Length];
ms.Read(bytes, 0, (int)ms.Length);
file.Write(bytes, 0, bytes.Length);
file.Close();
ms.Close();

这用于读取文件

MemoryStream ms = new MemoryStream();
FileStream file = new FileStream("file.bin", FileMode.Open, FileAccess.Read);
byte[] bytes = new byte[file.Length];
file.Read(bytes, 0, (int)file.Length);
ms.Write(bytes, 0, (int)file.Length);
file.Close();
ms.Close();

我对编程还比较陌生,我正在努力学习c#。这似乎是一个愚蠢的问题,但我不明白如何实现代码。感谢您的帮助:)

如何将PDF加载到内存中,然后通过acrobat阅读器进行读取

将文件下载到一个位置,然后从fileLocation将文件加载到Adobe中。我不确定你是否可以直接将内存流传递给Adobe Reader。

获取PDF文件的路径并执行以下操作:

//Get the path
var path = @"C:'Users'MyUser'My Documents'MyPdf.pdf"
//Open adobe reader with the file
Process.Start(path);