如何使用C#来渲染PDF文件 [英] How to render pdfs using C#

查看:522
本文介绍了如何使用C#来渲染PDF文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要加载和图形使用C#绘制的PDF文件。我并不需要对它们进行编辑或任何东西,只是使它们在给定的缩放级别。

I want to load and draw pdf files graphically using C#. I don't need to edit them or anything, just render them at a given zoom level.

我已经找到了PDF库似乎上一代要集中。我该怎么做呢?

The pdf libraries I have found seem to be focussed on generation. How do I do this?

感谢。

推荐答案

有万一一些其他的选择的Adobe ActiveX是不是你要找的东西(因为Acrobat中必须是在用户机器上present你不能出货自己)。

There are a few other choices in case the Adobe ActiveX isn't what you're looking for (since Acrobat must be present on the user machine and you can't ship it yourself).

有关创建PDF preVIEW,先看看StackOverflow上一些关于这个问题的其他讨论:

For creating the PDF preview, first have a look at some other discussions on the subject on StackOverflow:

  • How can I take preview of documents?
  • Get a preview jpeg of a pdf on windows?
  • .NET open PDF in winform without external dependencies
  • PDF Previewing and viewing

在过去的两年我谈一些事情你可以试试:

In the last two I talk about a few things you can try:


  • 您可以得到一个商业渲染器( PDFViewForNet ,的PDFRasterizer.NET ABCPDF ,< A HREF =htt​​p://www.activepdf.com/> ActivePDF , XpdfRasterizer 和其他其他答案...)。结果
    大多数是相当昂贵的,虽然,特别是如果你关心的是使一个简单的preVIEW /缩略图。

  • You can get a commercial renderer (PDFViewForNet, PDFRasterizer.NET, ABCPDF, ActivePDF, XpdfRasterizer and others in the other answers...).
    Most are fairly expensive though, especially if all you care about is making a simple preview/thumbnails.

在除了奥马尔Shahine的code段中,有一个 $ C $的CProject文章,演示如何使用Adobe的ActiveX,但它可能会过时,容易被新版本打破,其合法性不明朗(基本上它的确定供内部使用,但你不能出货和你不能用它在服务器上生成PDF的图像)。

In addition to Omar Shahine's code snippet, there is a CodeProject article that shows how to use the Adobe ActiveX, but it may be out of date, easily broken by new releases and its legality is murky (basically it's ok for internal use but you can't ship it and you can't use it on a server to produce images of PDF).

您可以看看源$ C ​​$ C为 SumatraPDF ,一个开放源代码的PDF浏览器窗口。

You could have a look at the source code for SumatraPDF, an OpenSource PDF viewer for windows.

还有 poppler的,使用的 中的xpdf作为渲染引擎。
所有这些都是伟大的,但他们将需要承担相当数量,使使他们的工作,并与.net接口以及他们往往是在GPL下发布。

There is also Poppler, a rendering engine that uses Xpdf as a rendering engine. All of these are great but they will require a fair amount of commitment to make make them work and interface with .Net and they tend to be be distributed under the GPL.

您可能要考虑使用 GhostScript的作为一个跨preTER因为渲染页面是一个非常简单的过程。结果
其缺点是,你要么需要重新包装它与您的应用程序安装,或者使之成为pre-必要的(或者您的安装过程中的至少一部分)。结果
这不是一个很大的挑战,它肯定比有其他渲染引擎按摩到与.net的合作更加容易。结果
我做了一个小的项目,你会发现在开发前preSS论坛作为附件。结果
小心的通过Ghostscript的许可要求。结果
如果你不能与随后的商业软件离开可能是你唯一的选择。

You may want to consider using GhostScript as an interpreter because rendering pages is a fairly simple process.
The drawback is that you will need to either re-package it to install it with your app, or make it a pre-requisite (or at least a part of your install process).
It's not a big challenge, and it's certainly easier than having to massage the other rendering engines into cooperating with .Net.
I did a small project that you will find on the Developer Express forums as an attachment.
Be careful of the license requirements for GhostScript through.
If you can't leave with that then commercial software is probably your only choice.

这篇关于如何使用C#来渲染PDF文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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