哪种方法最适合在C#中创建PostScript? [英] Which approach is best for creating PostScript in C#?

查看:212
本文介绍了哪种方法最适合在C#中创建PostScript?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从我们的系统创建PostScript输出。我们的系统生成高度格式化的文档,转换成多种格式,我需要添加.ps作为其他格式。

I need to create PostScript output from our system. Our system produces highly formatted documents to numerous formats and I need to add .ps as an additional format.

有点奇怪,我们的代码都是用Java编写的,将IKVM用于我们库的.net版本。我们大约有5%的代码是用C#编写的,其余的都是使用IKVM进行Java转换的。

One bit of weirdness, our code is all written in Java and we use IKVM for the .net version of our library. We have about 5% of the code written in C# and the rest is Java converted with IKVM.

我使用允许我运行的库在Java端创建.ps文件。写入它提供的Graphics2D对象。 不幸的是,在.NET(通过IKVM)中,它的运行速度非常慢

I create .ps files on the Java side using a library that allows me to write to a Graphics2D object it provides. Unfortunately, in .NET (via IKVM) it's horribly slow.

因此,为了解决这个问题,我在想:

So, to solve this, I'm thinking:


  1. 进入IKVM代码,看看是否可以加快速度。它这么慢没有任何意义。


    • 优点,如果可行,可能是
      最快的分辨率。现在可以使用将来的Graphics2D库。

    • 缺点,如果不能,我浪费了时间。另外,向前
      ,我们将拥有自己的IKVM分支。


  • Advantage一起使用,这应该是非常快速且完全的&正确处理.ps。

  • 缺点,这只能解决.ps的问题。同样,对于一种格式,每年5K的销售量可能不会很多。

  • 在这种情况下,我将为位图& .wmf输出–将会很快&简单。


  • Advantage中创建一个GraphicsOutputBuilder,这是最干净,最正确的方法。而且我们可以轻松添加位图& .emf以这种方式输出(它们具有Graphic对象的方式来写入它们)。

  • 缺点,这是一项艰巨的工作,在学习PostScript的所有详细信息时,我们可能会遇到一些小问题。


  • 优点,这可能比图形方法少一些工作。

  • 缺点,完成后我们有了但是任何将来的格式,例如SVG,我们也必须全部重写。

感谢您对解决此问题的任何反馈。

I appreciate any feedback on solving this problem.

推荐答案

我们将创建IKVM的一个分支(临时名称为Windward) MVKI),我们将其放在NuGet上。

We’ll be creating a branch of IKVM (tentative name Windward MVKI) and we’ll put it up on NuGet.

我们发现的问题在converter.cs中– C2J.ConvertShape()。它访问path.PathPoints [i]。问题在于每次调用都会创建点数组。将调用移至for循环外的PathPoints,然后访问一次构建的数组副本以加快访问速度–很大。

The issue we found is in converter.cs – C2J.ConvertShape(). It accesses path.PathPoints[i]. The problem is on each call to that it creates the array of points. Moving the call to PathPoints outside the for loop and then accessing the copy of the array built once to access speeds it up – a lot.

换句话说:

for (int i = 0; i < points.Length; i++) {
PointF point = path.PathPoints[i];

已更改为:

PointF[] points = path.PathPoints;
for (int i = 0; i < points.Length; i++) {
PointF point = points[i];

这篇关于哪种方法最适合在C#中创建PostScript?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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