原創(chuàng)|使用教程|編輯:郝浩|2013-04-12 13:23:43.000|閱讀 1941 次
概述:Png Device類允許將PDF頁(yè)轉(zhuǎn)換為Png圖像。這個(gè)類提供了一個(gè)叫Process方法用來(lái)實(shí)現(xiàn)這一轉(zhuǎn)換過(guò)程。您首先需要?jiǎng)?chuàng)建一個(gè)文檔類對(duì)象,用于獲取需要轉(zhuǎn)換成PNG格式的指定PDF頁(yè)。
# 界面/圖表報(bào)表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關(guān)鏈接:
Png Device類允許將PDF頁(yè)轉(zhuǎn)換為Png圖像。這個(gè)類提供了一個(gè)叫Process方法用來(lái)實(shí)現(xiàn)這一轉(zhuǎn)換過(guò)程。您首先需要?jiǎng)?chuàng)建一個(gè)文檔類對(duì)象,用于獲取需要轉(zhuǎn)換成PNG格式的指定PDF頁(yè)。之后,調(diào)用Process方法將頁(yè)面轉(zhuǎn)換為PNG圖像。
下面是具體示例代碼
C#
//open document
Document pdfDocument = new Document("input.pdf");
using (FileStream imageStream = new FileStream("image.png", FileMode.Create))
{
//create PNG device with specified attributes
//Width, Height, Resolution, Quality
//Quality [0-100], 100 is Maximum
//create Resolution object
Resolution resolution = new Resolution(300);
PngDevice pngDevice = new PngDevice(resolution);
//convert a particular page and save the image to stream
pngDevice.Process(pdfDocument.Pages[1], imageStream);
//close stream
imageStream.Close();
VB.NET
'open document
Dim pdfDocument As New Document("input.pdf")
Using imageStream As New FileStream("image.png", FileMode.Create)
'create PNG device with specified attributes
'Width, Height, Resolution, Quality
'Quality [0-100], 100 is Maximum
'create Resolution object
Dim resolution As New Resolution(300)
Dim pngDevice As New PngDevice(resolution)
'convert a particular page and save the image to stream
pngDevice.Process(pdfDocument.Pages(1), imageStream)
'close stream
imageStream.Close()
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請(qǐng)務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請(qǐng)郵件反饋至chenjj@ke049m.cn
文章轉(zhuǎn)載自:慧都控件網(wǎng)