C#代码实现将PDF转换为PostScript(PS)格式
PostScript 是由 Adobe Systems 在 20 世纪 80 年代开发的一种页面描述语言,用于将数字图形或文本文件转换为适合打印的固定格式。随着时间的推移,虽然 PostScript(PS)文件格式已不如过去那样流行,但目前仍然受到大多数打印机的支持。
本文将介绍如何使用 Spire.PDF for .NET 以编程方式将 PDF 文件转换为 PostScript(PS)文件。
安装 Spire.PDF for .NET
首先,你需要在 .NET 项目中引用 Spire.PDF for .NET 包中包含的 DLL 文件。你可以通过提供的链接下载这些 DLL 文件,或者通过 NuGet 进行安装。
PM> Install-Package Spire.PDF
在 C# 和 VB.NET 中将 PDF 转换为 PostScript
将 PDF 转换为 PS 格式可以提升打印输出的质量。使用 Spire.PDF for .NET,你只需三行代码即可完成转换。具体步骤如下:
- 创建一个 PdfDocument 实例。
- 使用 PdfDocument.LoadFromFile() 方法加载示例 PDF 文件。
- 使用 PdfDocument.SaveToFile(string filename, FileFormat.POSTSCRIPT) 方法将 PDF 文件保存为 PS 文件。
示例代码如下:
using Spire.Pdf;
namespace PDFtoPS
{
class Program
{
static void Main(string[] args)
{
// 创建 PdfDocument 实例
PdfDocument document = new PdfDocument();
// 加载示例 PDF 文件
document.LoadFromFile("Test.pdf");
// 将 PDF 文件保存为 PS 文件
document.SaveToFile("toPostScript.ps", FileFormat.POSTSCRIPT);
}
}
}知识扩展
1.C# VB.NET将 PDF 转换为 PostScript
将 PDF 转换为 PS 可以提高打印输出的质量。使用 Spire.PDF for .NET,您只需三行代码即可完成转换。以下是详细步骤。
- 创建一个PdfDocument实例。
- 使用PdfDocument.LoadFromFile()方法加载示例 PDF 文件。
- 使用PdfDocument .SaveToFile(string filename, FileFormat.POSTSCRIPT)方法将 PDF 文件保存为 PS 文件。
C#
using Spire.Pdf;
namespace PDFtoPS
{
class Program
{
static void Main(string[] args)
{
//Create a PdfDocument instance
PdfDocument document = new PdfDocument();
//Load a sample PDF file
document.LoadFromFile("Test.pdf");
//Save the PDF file as a PS file
document.SaveToFile("toPostScript.ps", FileFormat.POSTSCRIPT);
}
}
}VB.NET
Imports Spire.PDF
Namespace PDFtoPS
Class Program
Private Shared Sub Main(ByVal args() As String)
'Create a PdfDocument instance
Dim document As PdfDocument = New PdfDocument
'Load a sample PDF file
document.LoadFromFile("Test.pdf")
'Save the PDF file as a PS file
document.SaveToFile("toPostScript.ps", FileFormat.POSTSCRIPT)
End Sub
End Class
End Namespace2.pdf转PostScript
pdftops version 4.03 [www.xpdfreader.com] Copyright 1996-2021 Glyph & Cog, LLC Usage: pdftops [options] <PDF-file> [<PS-file>] -f <int> : first page to print -l <int> : last page to print -level1 : generate Level 1 PostScript -level1sep : generate Level 1 separable PostScript -level2 : generate Level 2 PostScript -level2gray : generate Level 2 grayscale PostScript -level2sep : generate Level 2 separable PostScript -level3 : generate Level 3 PostScript -level3gray : generate Level 3 grayscale PostScript -level3sep : generate Level 3 separable PostScript -eps : generate Encapsulated PostScript (EPS) -form : generate a PostScript form -opi : generate OPI comments -noembt1 : don't embed Type 1 fonts -noembtt : don't embed TrueType fonts -noembcidps : don't embed CID PostScript fonts -noembcidtt : don't embed CID TrueType fonts -preload : preload images and forms -paper <string> : paper size (letter, legal, A4, A3, match) -paperw <int> : paper width, in points -paperh <int> : paper height, in points -nocrop : don't crop pages to CropBox -expand : expand pages smaller than the paper size -noshrink : don't shrink pages larger than the paper size -nocenter : don't center pages smaller than the paper size -pagecrop : treat the CropBox as the page size -userunit : honor the UserUnit -duplex : enable duplex printing -opw <string> : owner password (for encrypted files) -upw <string> : user password (for encrypted files) -q : don't print any messages or errors -cfg <string> : configuration file to use in place of .xpdfrc -v : print copyright and version info -h : print usage information -help : print usage information --help : print usage information -? : print usage information
到此这篇关于C#代码实现将PDF转换为PostScript(PS)格式的文章就介绍到这了,更多相关C# PDF转PostScript内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!
相关文章
C#使用XmlDocument或XDocument创建xml文件
这篇文章主要为大家详细介绍了C#使用XmlDocument或XDocument创建xml文件,具有一定的参考价值,感兴趣的小伙伴们可以参考一下2018-10-10
DevExpress实现自定义GridControl中按钮文字内容的方法
这篇文章主要介绍了DevExpress实现自定义GridControl中按钮文字内容的方法,需要的朋友可以参考下2014-08-08


最新评论