pdf转换成jpg示例分享

时间:2021-05-26

复制代码 代码如下:
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using System.Collections;
/**
Convert PDF to Image Format(JPEG) using Ghostscript API

convert a pdf to jpeg using ghostscript command line:
gswin32c -q -dQUIET -dPARANOIDSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dFirstPage=1 -dAlignToPixels=0 -dGridFitTT=0 -sDEVICE=jpeg -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -r100x100 -sOutputFile=output.jpg test.pdf
see also:http://ponent();

}
private void button1_Click(object sender, EventArgs e)
{
PDFConvert convertor = new PDFConvert();
convertor.pdf2jpgTest();
Image img = Image.FromFile(@"C://tmp//pdfimg//out.jpg");
myBitmap = new Bitmap(img);

Graphics G = this.CreateGraphics();
GraphicsUnit GU = G.PageUnit;
BMPContainer = myBitmap.GetBounds(ref GU); //X,Y = 0

// Graphics g = this.CreateGraphics();
//g.DrawImage(myBitmap, 1, 1);
this.Invalidate();
}
private Bitmap myBitmap;
private RectangleF BMPContainer;
protected override void OnPaint(PaintEventArgs e)
{
Graphics G = e.Graphics;
if (myBitmap != null)
{
G.DrawImage(myBitmap, BMPContainer);
}
base.OnPaint(e);
}
}
}

声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。

相关文章