Hello
Is it possible to do it? I have tried some ways, but it allways loses most of the Pdf data. Showing olny one corner of A3 page. Converter Works finne with A4 format pages. Any tips ?
namespace ToImage
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
//pdf file
String file = @"C:\Users\jyrgen\Desktop\Skännitud\201412031030.pdf";
//open pdf document
PdfDocument doc = new PdfDocument();
doc.LoadFromFile(file);
//doc.Split(file);
//doc.Pages.Add(PdfPageSize.A2);
doc.PageSettings.Size = PdfPageSize.A3;
doc.PageSettings.Rotate = PdfPageRotateAngle.RotateAngle0;
doc.PageSettings.Width = -3000;
doc.PageScaling = PdfPrintPageScaling.ActualSize;
//doc.PageSettings.Height = 1200;
//doc.PageSettings.Width = 1000;
Bitmap bmp = new Bitmap(doc.SaveAsImage(0)) ;
//bmp.SetResolution(0.0005F, 0.0005F);
//bmp.Height = 1200;
//bmp.Width = 1000;
Image emf = doc.SaveAsImage(0, Spire.Pdf.Graphics.PdfImageType.Metafile);
//emf.VerticalResolution = "700";
Image zoomImg = new Bitmap((int)(emf.Size.Width + 25), (int)(emf.Size.Height + 25));
using (Graphics g = Graphics.FromImage(zoomImg))
{
g.ScaleTransform(2.0f, 2.0f);
g.DrawImage(emf, new Rectangle(new Point(10, 20), emf.Size), new Rectangle(new Point(10, 20), emf.Size), GraphicsUnit.Pixel);
}
bmp.Save("convertToBmp.bmp", ImageFormat.Bmp);
System.Diagnostics.Process.Start("convertToBmp.bmp");
emf.Save("convertToEmf.png", ImageFormat.Png);
System.Diagnostics.Process.Start("convertToEmf.png");
zoomImg.Save("convertToZoom.png", ImageFormat.Png);
System.Diagnostics.Process.Start("convertToZoom.png");
}
}
}