COM pressing PDF文件使得它更大 [英] compressing pdf file makes it bigger
本文介绍了COM pressing PDF文件使得它更大的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我COM preSS上传 .PDF
文件并将其保存到服务器的文件系统。一切正常,但文件变大,从30KB到48KB。什么可能我是做错了什么?这里的code部分,我COM preSS上传的文件:
的FileStream的SourceFile = System.IO.File.OpenRead(文件路径);
的FileStream destFile = System.IO.File.Create(zipPath);
GZipStream compStream =新GZipStream(destFile,COM pressionMode.Com preSS);尝试
{
INT theByte = sourceFile.ReadByte();
而(theByte!= -1)
{
compStream.WriteByte((字节)theByte);
theByte = sourceFile.ReadByte();
}
}
解决方案
我想这个问题是 GZipLib
在这里。我用 DotNetZip
而不是和现在预期的文件变得更小。它可以在这里下载 。
I compress the uploaded .pdf
files and save them to server's file system. Everything works well, but the file gets bigger, from 30kb to 48kb. What could I be doing wrong? Here's the code part I compress the uploaded file:
FileStream sourceFile = System.IO.File.OpenRead(filePath);
FileStream destFile = System.IO.File.Create(zipPath);
GZipStream compStream = new GZipStream(destFile, CompressionMode.Compress);
try
{
int theByte = sourceFile.ReadByte();
while (theByte != -1)
{
compStream.WriteByte((byte)theByte);
theByte = sourceFile.ReadByte();
}
}
解决方案
I guess the problem is with GZipLib
here. I used DotNetZip
instead and file gets smaller as expected now. It can be downloaded here.
这篇关于COM pressing PDF文件使得它更大的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文