我有一种情况,我想 转换RTF 文档 到图像 对于存档和打印。我使用。网。
是否有任何库存,可以帮助我这个转换?

我需要

  • 转换RTF图像服务器上
  • 设置纸张大小,需要加以附着在创建图像

一种商业图书馆是一个选项,但我更喜欢操作系统。如果有一个客户面的方式来做到,这是一个有效的答案,但是服务器方将是极好的。

编辑:

感谢所有伟大的答案。由于所有的它们涉及印刷RTF文件,我有后续行动的问题:

  • 什么是最好的方式打印RTF文件服务器上
有帮助吗?

解决方案

我的建议就是,有一个印刷驱动程序转储到一个像这样,你可以使用标准印刷功能(包括纸张大小)和然后抓住的文件和使用,实际印刷或存档。

免费和开放源代码版本是: 虚拟的图像打印机的驾驶员

其他提示

我们不得不处理与这个最近。我们的应用程序将允许用户为编辑一些RTF在一个标准的控制(配有视觉工作室),然后将它转换成图像所以我们可以把它送到另一个应用程序,没有理解RTF。

我看起来相当困难的网络和它出现唯一的可能性,是采取的截图控制和转换到一个图象。这意味着任何案文外面的视区域(即你不得不滚动)不会出现。让我感到惊讶真的,它不得不砍死了这样。

我知道你问的关于商业库但是我想让你知道我的经验的内控制。

扩大在罗伯特的答案,你可以,如果有必要,避免下载标准的打印驱动程序的通过只挑选一个"标准的"打印机的操作系统和打印文件。大量的驱动程序justing使用标准的版本postscript。它通常是很容易的转换postscript文件的pdf文件,查看如果需要的话。印刷他们通常是很容易的,太。

这种解决方案是稍微更多的工作比仅仅使用一个专门的驱动器,其输出一个图像。

我能捕捉到图画的是通过下列代码段。我认为这可以使用。

private void ShowBitmap_btn_Click(object sender, RoutedEventArgs e)
    {
        if (MyTextBox_txt == null)
            return;

        Rect _descendentBounds = VisualTreeHelper.GetDescendantBounds(MyTextBox_txt);
        //RenderTargetBitmap _targetBitmap = new RenderTargetBitmap((Int32)_descendentBounds.Width, 
        //                                                          (Int32)_descendentBounds.Height, 
        //                                                          96, 96, PixelFormats.Pbgra32);

        Rect _tempRect = new Rect(System.Windows.Forms.Screen.PrimaryScreen.Bounds.X,
                                    System.Windows.Forms.Screen.PrimaryScreen.Bounds.Y,
                                    System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width,
                                    System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height);
        RenderTargetBitmap _targetBitmap = new RenderTargetBitmap((Int32)_tempRect.Width,
                                                                            (Int32)_tempRect.Height,
                                                                                96, 96, PixelFormats.Pbgra32);

        DrawingVisual _drawingVisual = new DrawingVisual();

        using (DrawingContext _drwaingContext = _drawingVisual.RenderOpen())
        {
            VisualBrush _visualBrush = new VisualBrush(MyTextBox_txt);
            _drwaingContext.DrawRectangle(_visualBrush, null, new Rect(new Point(), _tempRect.Size));
        }

        _targetBitmap.Render(_drawingVisual);

        PngBitmapEncoder _png = new PngBitmapEncoder();

        _png.Frames.Add(BitmapFrame.Create(_targetBitmap));
        Stream _fileStream;
        _fileStream = File.Create(@"E:\sample1.png");

        _png.Save(_fileStream);

        System.Drawing.Bitmap _tempBitmap = new System.Drawing.Bitmap(_fileStream);
        _tempBitmap.Save(@"E:\sample1.bmp");

        _fileStream.Close();
        _fileStream.Dispose();

    }
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top