<< Click to Display Table of Contents >> Navigation: Direct Calls to DLL > pdfMakeImage - convert selected pages to bitmaps > Example .NET - C# |
Please note the const DLLName - they have to be changed for the demo vs. the PLUS version.
The full version also requires the correct licenses data.
This DLLs are required in the binary directory:
32 bit: wPDFViewDemo04.dll, wp_type1ttf.dll, wpdecodejp.dll
64 bit: wPDFViewDemo04x64.dll, wp_type1ttf64.dll, wpdecodejp64.dll
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices; // for DllImport
namespace CallWPViewPDF
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
int res;
if (IntPtr.Size == 8)
res = wpviewpdf64.MakeImage(textBox1.Text, "",
"testlic", "testkey", 12345, // License
textBox2.Text + "\\page%d.png", // Dest path
0, 10000,
200);
else res = wpviewpdf.MakeImage(textBox1.Text, "password", // pdf file, password
"testlic", "testkey", 12345, // License
textBox2.Text + "\\page%d.png", // Dest path
0, 10000,
200);
}
}
public class wpviewpdf : object
{
const string DLLNAME_32 = "wPDFViewDemo05.dll";
/* function pdfMakeImageW(filename: PWideChar; password: PWideChar;
licname, lickey: PWideChar; liccode: Cardinal; destpath: PWideChar;
// Use %d store page number !
frompage, to_page: Integer; jpegres: Integer): Integer; stdcall; */
[DllImport(DLLNAME_32, EntryPoint = "pdfMakeImageW",
CharSet = CharSet.Unicode, ExactSpelling = true,
CallingConvention = CallingConvention.StdCall)]
public static extern int MakeImage(
string filename,
string password,
string licname,
string lickey,
int liccode, // not "long" !
string destpath,
int frompage,
int to_page,
int jpegres);
}
public class wpviewpdf64 : object
{
const string DLLNAME_64 = "wPDFViewDemo05x64.dll";
[DllImport(DLLNAME_64, EntryPoint = "pdfMakeImageW",
CharSet = CharSet.Unicode, ExactSpelling = true,
CallingConvention = CallingConvention.StdCall)]
public static extern int MakeImage(string filename,
string password,
string licname,
string lickey,
int liccode, // not "long" !
string destpath,
int frompage,
int to_page,
int jpegres);
}
}