![](/img/trans.png)
[英]How to compress PDF file that is generated using HTML-Renderer library c#
[英]How to compress PDF file using sevenzipsharper in c#?
我可以使用以下代码压缩目录:
string dll = @"D:\7z.dll";
string source = @"D:\sample";
string output = @"D:\My7zipped.7z";
SevenZipBase.SetLibraryPath(dll);
SevenZipCompressor compressor = new SevenZipCompressor();
compressor.ZipEncryptionMethod = ZipEncryptionMethod.Aes256;
compressor.CompressionMethod = CompressionMethod.Lzma2;
compressor.CompressionLevel = CompressionLevel.Normal;
compressor.CompressDirectory(source, output);
但是我想压缩成一个PDF文件。 如何压缩成单个PDF文件?
使用SevenZipCompressor.CompressFiles
方法而不是SevenZipCompressor.CompressDirectory
。
请尝试自己找出基本知识(像这样)。 在这里问之前,您应该自己做一些工作。
SevenZipCompressor tmp =新的SevenZipCompressor(); tmp.CompressStream(File.OpenRead(sourceFile),File.Create(destinationFile));
在CodeProject上有一个示例,该示例使用SDK为7z创建C#接口。
http://www.codeproject.com/Articles/27148/C-NET-Interface-for-7-Zip-Archive-DLLs
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.