是否可以将pdf或视频文件等文件分成两个文件? [英] Is it possible to divide a file such as pdf or a video file into two file files?

查看:106
本文介绍了是否可以将pdf或视频文件等文件分成两个文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

出于好奇,我想知道是否可以将pdf或视频文件等文件分成两个文件?如果是的话怎么样? (asp.net和c#)

Just out of curiosity i would like to know if it possible to divide a file such as pdf or a video file into two file files? If yes than how? (asp.net and c#)

推荐答案

这取决于你所说的除法是什么意思。如果您将文件本身机械地分成两部分,那么对于PDF和视频来说,两个结果可能无效。特别是对于视频,它取决于所使用的视频格式和代码,但通常会发生这种情况:第一部分(当然,第二部分未被识别,因为没有标题)实际上甚至可以播放,但是,作为文件元数据显示错误的长度,导航失败,所以玩家甚至可以挂起;它实际上取决于玩家。我认为它的原因很明显。



如果你不拆分,但是,比方说,只需创建两个单独的PDF文件,然后复制部分内容在一个文件中,其余文件在另一个文件中,您将获得两个有效的PDF。怎么做?好吧,有足够的产品,Adobe或开源,以及库。



要使用PDF,请使用iText或其.NET端口,iTextSharp:

http://en.wikipedia.org/wiki/IText [ ^ ],

http://itextpdf.com/ [ ^ ] ,

http://sourceforge.net/projects/itextsharp/ [ ^ ]。



包括在内也是对Java iText网站的引用,因为大多数文档都在那里。如果您了解C#,那么理解基于Java的API文档并不困难。





使用视频,我知道最好的实用程序是ffMpeg或相关的libavcodec。请参阅:

http://en.wikipedia.org/wiki/Ffmpeg [< a href =http://en.wikipedia.org/wiki/Ffmpegtarget =_ blanktitle =New Window> ^ ],

http://en.wikipedia.org/wiki/Libavcodec [ ^ ],

http:// ffmpeg。 org / [ ^ ],

http://libav.org/ [ ^ ]。



现在,如何在.NET应用程序中以编程方式使用它?首先,您可以使用 System.Diagnostics.Process.Start 运行它来使用可用的实用程序:

http://msdn.microsoft.com/en-us/library/system.diagnostics.process.start.aspx [ ^ ]。



如果这还不够好,你可以自己将库包装在.NET程序集中,或找到合适的包装器。请参阅:

http://www.ffmpeg-csharp.com/ [ ^ ],

http://sourceforge.net/projects/sharpffmpeg/ [ ^ ],

http://vbffmpegwrapper.codeplex.com/ [ ^ ]。



毕竟,尝试找一些: http://bit.ly/VpboUJ [ ^ ]。



如果你想工作在你自己的包装但不知道如何,问一个问题,我会给你基本的想法(使用P / Invoke或C ++ / CLI混合模式项目)。



祝你好运,

-SA
It depends on what do you mean by "divide". If you mechanically split the file itself into two parts, chances are the two results would be invalid, for both PDF and video. For video, in particular, it depends on the video format and codes used, but here is what usually happens: first part (second in not recognized, of course, because there is no header) actually even plays, but, as the file metadata shows wrong length, navigation fails, so the player can even hangs; it actually depends on the player. I think the reason of it is pretty obvious.

If you don't split, but, say, simply create two separate PDF files, and then copy part of content in one file and the rest in another, you will get two valid PDFs. How to do that? Well, there are enough products, Adobe or open-source, and libraries.

To work with PDF, use iText, or its .NET port, iTextSharp:
http://en.wikipedia.org/wiki/IText[^],
http://itextpdf.com/[^],
http://sourceforge.net/projects/itextsharp/[^].

In included the reference to Java iText site as well, because most documentation is there. If you understand C#, it would not be difficult to understand Java-bases API documentation.


With video, the best utility I know is ffMpeg or related libavcodec. Please see:
http://en.wikipedia.org/wiki/Ffmpeg[^],
http://en.wikipedia.org/wiki/Libavcodec[^],
http://ffmpeg.org/[^],
http://libav.org/[^].

Now, how to use it programmatically in a .NET application? First, you can use the available utility by running it using System.Diagnostics.Process.Start:
http://msdn.microsoft.com/en-us/library/system.diagnostics.process.start.aspx[^].

If this is not good enough, you can wrap the library in a .NET assembly by yourself or find appropriate wrapper. Please see:
http://www.ffmpeg-csharp.com/[^],
http://sourceforge.net/projects/sharpffmpeg/[^],
http://vbffmpegwrapper.codeplex.com/[^].

After all, try to find some more: http://bit.ly/VpboUJ[^].

If you wish to work at such wrapper by yourself but don't know how, ask a question, I'll give you the basic ideas (using P/Invoke or C++/CLI "mixed-mode" project).

Good luck,
—SA






请参考以下网址...



http:// stackoverflow。 com / questions / 3967541 / how-to-split-large-files-efficient [ ^ ]



C#中的文件分割器实用程序 [ ^ ]



http://stackoverflow.com/questions/5659189/how-to-split-a-大文件到块中 [ ^ ]



快乐编码



Sebastian
Hi,

refer following urls...

http://stackoverflow.com/questions/3967541/how-to-split-large-files-efficiently[^]

File Splitter Utility in C#[^]

http://stackoverflow.com/questions/5659189/how-to-split-a-large-file-into-chunks-in-c[^]

Happy coding

Sebastian


这篇关于是否可以将pdf或视频文件等文件分成两个文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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