原創|使用教程|編輯:郝浩|2013-04-12 13:23:43.000|閱讀 1930 次
概述:Png Device類允許將PDF頁轉換為Png圖像。這個類提供了一個叫Process方法用來實現這一轉換過程。您首先需要創建一個文檔類對象,用于獲取需要轉換成PNG格式的指定PDF頁。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
Png Device類允許將PDF頁轉換為Png圖像。這個類提供了一個叫Process方法用來實現這一轉換過程。您首先需要創建一個文檔類對象,用于獲取需要轉換成PNG格式的指定PDF頁。之后,調用Process方法將頁面轉換為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()
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉載自:慧都控件網