将.pdf文件转换为缩略图视图 [英] convert .pdf file to thumbnail view

查看:169
本文介绍了将.pdf文件转换为缩略图视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用c#

在ASP.NET中将.pdf文件转换为缩略图视图,字符串形式名称){
//int size = 100;
试试
{
//decoder.decodePage(PageNumber);
//decoder.setPageParameters(1,PageNumber); //值缩放(1 = 100%).页码
coder.useHiResScreenDisplay(true);

//下面的行设置了72 dpi的倍数,即:72 * 4.166 = 300dpi
encoder.setExtractionMode(32,72,4.166f);
BufferedImage PDF =解码器.getPageAsImage(PageNumber);
//width = PDF.getWidth()* .75;
//height = PDF.getHeight()* .75;
宽度= PDF.getWidth();
高度= PDF.getHeight();

GraphicsConfiguration gc = getDefaultConfiguration();
final BufferedImage PNG = getScaledInstance(PDF,(int)Math.round(width),(int)Math.round(height),gc);
字符串fileName = jTextAreaTargetDirectoryPath.getText()+"\\" +表单名+-" + PageNumber +".png";
ImageIO.write(PNG,"png",新File(fileName));
coder.flushObjectValues(true);
}
catch(特例例外){
ex.printStackTrace();
//flogger.log(Level.SEVERE,无法从页面生成图像.",例如);
}

}


请点击下面的链接查看示例

http://amitpatriwala.wordpress.com/2009/08/28/pdf -viewer-in-asp-net/ [ 字符串图像="D:\\ test.png";

试试
{
GflAx.GflAxClass g =新的GflAx.GflAxClass();
g.EpsDpi = 150;
g.Page = 1;
g.LoadBitmap(file);
g.SaveFormat = GflAx.AX_SaveFormats.AX_PNG;
g.SaveBitmap(image);
MessageBox.Show(此,"PDF到PNG的转换已结束");
}
catch(ex ex例外){
MessageBox.Show(this,"GflAx error:" + ex.Message);
}
}


how to convert .pdf file to thumbnail view in asp.net with c#

private void generatePNGfromPDF(PdfDecoder decoder, int PageNumber, double width, double height, String formname){
//int size = 100;
try
{
//decoder.decodePage(PageNumber);
//decoder.setPageParameters(1,PageNumber); //values scaling (1=100%). page number
decoder.useHiResScreenDisplay(true);

// the below line sets the multiple of 72 dpi ie: 72 * 4.166 = 300dpi
decoder.setExtractionMode(32, 72, 4.166f);
BufferedImage PDF = decoder.getPageAsImage(PageNumber);
//width = PDF.getWidth() * .75;
//height = PDF.getHeight() * .75;
width = PDF.getWidth();
height = PDF.getHeight();

GraphicsConfiguration gc = getDefaultConfiguration();
final BufferedImage PNG = getScaledInstance(PDF, (int)Math.round(width), (int)Math.round(height), gc);
String fileName = jTextAreaTargetDirectoryPath.getText() + "\\" + formname + "-" + PageNumber + ".png";
ImageIO.write(PNG, "png", new File( fileName ));
decoder.flushObjectValues(true);
}
catch(Exception ex){
ex.printStackTrace();
//flogger.log(Level.SEVERE, "Cannot generate image from page.", ex);
}

}


Plz click the below link to see the exapmle

http://amitpatriwala.wordpress.com/2009/08/28/pdf-viewer-in-asp-net/[^]


The GFL SDK/GFLAx (http://www.xnview.com/en/gfl.html) free library component can be used to convert PDF to image format. It works for ASP, VB, C# etc. GhostScript (http://sourceforge.net/projects/ghostscript/) is required for it to work.

Example code in C#:

{
string file = "D:/test.pdf";
string image = "D:\\test.png";

try
{
GflAx.GflAxClass g = new GflAx.GflAxClass();
g.EpsDpi = 150;
g.Page = 1;
g.LoadBitmap(file);
g.SaveFormat = GflAx.AX_SaveFormats.AX_PNG;
g.SaveBitmap(image);
MessageBox.Show(this, "PDF to PNG conversion ended");
}
catch (Exception ex) {
MessageBox.Show(this, "GflAx error: " + ex.Message);
}
}


这篇关于将.pdf文件转换为缩略图视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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