没有找到合适的产品?
联系客服协助选型:023-68661681
提供3000多款全球软件/控件产品
针对软件研发的各个阶段提供专业培训与技术咨询
根据客户需求提供定制化的软件开发服务
全球知名设计软件,显著提升设计质量
打造以经营为中心,实现生产过程透明化管理
帮助企业合理产能分配,提高资源利用率
快速打造数字化生产线,实现全流程追溯
生产过程精准追溯,满足企业合规要求
以六西格玛为理论基础,实现产品质量全数字化管理
通过大屏电子看板,实现车间透明化管理
对设备进行全生命周期管理,提高设备综合利用率
实现设备数据的实时采集与监控
利用数字化技术提升油气勘探的效率和成功率
钻井计划优化、实时监控和风险评估
提供业务洞察与决策支持实现数据驱动决策
翻译|行业资讯|编辑:胡涛|2023-07-31 14:25:20.357|阅读 40 次
概述:本文介绍了使用Spire.PDF for .NET 通过 document.SaveAsImage() 和 JoinTiffImages() 方法将 PDF 文档保存为 tiff 图像的详细方法,欢迎查阅~
# 界面/图表报表/文档/IDE等千款热门软控件火热销售中 >>
相关链接:
Spire.Doc 是一款专门对 Word 文档进行操作的 类库。在于帮助开发人员无需安装 Microsoft Word情况下,轻松快捷高效地创建、编辑、转换和打印 Microsoft Word 文档。拥有近10年专业开发经验Spire系列办公文档开发工具,专注于创建、编辑、转换和打印Word/PDF/Excel等格式文件处理,小巧便捷。
E-iceblue 功能类库Spire 系列文档处理组件均由中国本土团队研发,不依赖第三方软件,不受其他国家的技术或法律法规限制,同时适配国产操作系统如中科方德、中标麒麟等,兼容国产文档处理软件 WPS(如 .wps/.et/.dps 等格式
Spire.PDF for.net下载 Spire.PDF for java下载
Tiff图像作为图形容器,可以存储光栅图像和矢量图像;可能包含支持 1 至 24 位颜色深度的高质量图形;支持有损和无损压缩;还支持多层和页面。如果您希望文档能够转换为高质量的图形,并且在压缩过程中保存时不丢失图像文件信息,tiff 图像是您的最佳选择。
本文介绍了使用Spire.PDF for .NET 通过 document.SaveAsImage() 和 JoinTiffImages() 方法将 PDF 文档保存为 tiff 图像的详细方法,Spire.PDF for .NET是一个 PDF 组件,包含令人难以置信的丰富的创建、阅读、编辑功能并在.NET、Silverlight 和 WPF 平台上操作 PDF 文档。下面的屏幕截图显示了将 PDF 文档保存为 tiff 图像后的结果:
该方法的主要步骤是:
第 1 步:创建一个新的 pdf 文档并加载它。
PdfDocument document = new PdfDocument(); document.LoadFromFile(@"sample.pdf");
步骤2: 使用document.SaveAsImage()方法将pdf文档保存为图像数组。
private static Image[] SaveAsImage(PdfDocument document) { Image[] images = new Image[document.Pages.Count]; for (int i = 0; i < document.Pages.Count; i++) { //use the document.SaveAsImage() method save the pdf as image images[i] = document.SaveAsImage(i); } return images; }
步骤 3:使用 JoinTiffImages() 方法将 pdf 页面中的图像保存为 tiff 图像类型,并指定编码器和图像编码器参数。
public static void JoinTiffImages(Image[] images, string outFile, EncoderValue compressEncoder) { //use the save encoder Encoder enc = Encoder.SaveFlag; EncoderParameters ep = new EncoderParameters(2); ep.Param[0] = new EncoderParameter(enc, (long)EncoderValue.MultiFrame); ep.Param[1] = new EncoderParameter(Encoder.Compression, (long)compressEncoder); Image pages = images[0]; int frame = 0; ImageCodecInfo info = GetEncoderInfo("image/tiff"); foreach (Image img in images) { if (frame == 0) { pages = img; //save the first frame pages.Save(outFile, info, ep); } else { //save the intermediate frames ep.Param[0] = new EncoderParameter(enc, (long)EncoderValue.FrameDimensionPage); pages.SaveAdd(img, ep); } if (frame == images.Length - 1) { //flush and close. ep.Param[0] = new EncoderParameter(enc, (long)EncoderValue.Flush); pages.SaveAdd(ep); } frame++; } }
完整代码:
[C#]
using System; using System.Drawing; using System.Drawing.Imaging; using Spire.Pdf; namespace SavePdfAsTiff { class Program { static void Main(string[] args) { PdfDocument document = new PdfDocument(); document.LoadFromFile(@"01.pdf"); JoinTiffImages(SaveAsImage(document),"result.tiff",EncoderValue.CompressionLZW); System.Diagnostics.Process.Start("result.tiff"); } private static Image[] SaveAsImage(PdfDocument document) { Image[] images = new Image[document.Pages.Count]; for (int i = 0; i < document.Pages.Count; i++) { images[i] = document.SaveAsImage(i); } return images; } private static ImageCodecInfo GetEncoderInfo(string mimeType) { ImageCodecInfo[] encoders = ImageCodecInfo.GetImageEncoders(); for (int j = 0; j < encoders.Length; j++) { if (encoders[j].MimeType == mimeType) return encoders[j]; } throw new Exception(mimeType + " mime type not found in ImageCodecInfo"); } public static void JoinTiffImages(Image[] images, string outFile, EncoderValue compressEncoder) { //use the save encoder Encoder enc = Encoder.SaveFlag; EncoderParameters ep = new EncoderParameters(2); ep.Param[0] = new EncoderParameter(enc, (long)EncoderValue.MultiFrame); ep.Param[1] = new EncoderParameter(Encoder.Compression, (long)compressEncoder); Image pages = images[0]; int frame = 0; ImageCodecInfo info = GetEncoderInfo("image/tiff"); foreach (Image img in images) { if (frame == 0) { pages = img; //save the first frame pages.Save(outFile, info, ep); } else { //save the intermediate frames ep.Param[0] = new EncoderParameter(enc, (long)EncoderValue.FrameDimensionPage); pages.SaveAdd(img, ep); } if (frame == images.Length - 1) { //flush and close. ep.Param[0] = new EncoderParameter(enc, (long)EncoderValue.Flush); pages.SaveAdd(ep); } frame++; } } } }
[VB.NET]
Imports System Imports System.Drawing Imports System.Drawing.Imaging Imports Spire.Pdf Namespace SavePdfAsTiff Class Program Sub Main() Dim document As PdfDocument = New PdfDocument() document.LoadFromFile("01.pdf") JoinTiffImages(SaveAsImage(document), "result.tiff", EncoderValue.CompressionLZW) System.Diagnostics.Process.Start("result.tiff") End Sub Private Shared Function SaveAsImage(ByVal document As PdfDocument) Dim images() As Image = New Image(document.Pages.Count-1) {} Dim i As Integer For i = 0 To document.Pages.Count - 1 Step i + 1 images(i) = document.SaveAsImage(i) Next Return images End Function Private Shared Function GetEncoderInfo(ByVal mimeType As String) As ImageCodecInfo Dim encoders() As ImageCodecInfo = ImageCodecInfo.GetImageEncoders() Dim j As Integer For j = 0 To encoders.Length - 1 Step j + 1 If encoders(j).MimeType = mimeType Then Return encoders(j) End If Next Throw New Exception(mimeType + " mime type not found in ImageCodecInfo") End Function Public Shared Sub JoinTiffImages(ByVal images() As Image, ByVal outFile As String, ByVal compressEncoder As EncoderValue) 'use the save encoder Dim enc As Encoder = Encoder.SaveFlag Dim ep As EncoderParameters = New EncoderParameters(2) ep.Param(0) = New EncoderParameter(enc, CType(EncoderValue.MultiFrame, Long)) ep.Param(1) = New EncoderParameter(Encoder.Compression, CType(compressEncoder, Long)) Dim pages As Image = images(0) Dim frame As Integer = 0 Dim info As ImageCodecInfo = GetEncoderInfo("image/tiff") Dim img As Image For Each img In images If frame = 0 Then pages = img 'save the first frame pages.Save(outFile, info, ep) Else 'save the intermediate frames ep.Param(0) = New EncoderParameter(enc, CType(EncoderValue.FrameDimensionPage, Long)) pages.SaveAdd(img, ep) End If If frame = images.Length - 1 Then 'flush and close. ep.Param(0) = New EncoderParameter(enc, CType(EncoderValue.Flush, Long)) pages.SaveAdd(ep) End If frame = frame + 1 Next End Sub End Class End Namespace
以上便是如何PDF 文档另存为 tiff 图像,如果您有其他问题也可以继续浏览本系列文章,获取相关教程,你还可以给我留言或者加入我们的官方技术交流群。
欢迎下载|体验更多E-iceblue产品
获取更多信息请咨询 ;技术交流Q群(767755948)
本站文章除注明转载外,均为本站原创或翻译。欢迎任何形式的转载,但请务必注明出处、不得修改原文相关链接,如果存在内容上的异议请邮件反馈至chenjj@wqylolg.cn
本文将从产品功能、核心优势及行业应用场景三个维度,解析Aspose的热门产品如何助力企业提升文档管理效率。
产线级 MES 通过与检测设备的深度集成,实现数据的自动采集和智能分析,为企业提供更加精准、高效的质量管理方案。
HOOPS Communicator作为一款强大的工业设计工具,其碰撞检测和运动模拟功能为工程师和设计师提供了invaluable的支持。通过不断的技术创新和功能优化,HOOPS Communicator将助力企业在数字化转型的浪潮中,实现更加高效、智能和精准的工业设计与制造,引领工业设计走向新的高度。
Spire.Doc for .NET 是一款专门对 Word 文档进行操作的 .NET 类库。
Spire.XLS for .NETSpire.XLS for .NET是专业.NET Excel组件,快速完成对Excel各类编程操作
Spire.PDF for .NETSpire.PDF for .NET是独立的PDF控件,用于.NET程序中创建、编辑和操作PDF文档
服务电话
重庆/ 023-68661681
华东/ 13452821722
华南/ 18100878085
华北/ 17347785263
客户支持
技术支持咨询服务
服务热线:400-700-1020
邮箱:sales@wqylolg.cn
关注我们
地址 : 重庆市九龙坡区火炬大道69号6幢