If you need to print from any application you can use some simple code which imports the pdfPrint function directly. You do not need to create any control or any form for it. Simply import this function from the DLL. This works in VB, in Delphi, in .NET.
Declaration of the print function in C
stdcall int pdfPrint( char *filename, char *password: char *licname, char *lickey: PChar, unsigned long liccode, char *options);
MSVC++ 6.0 / MFC Example:
HINSTANCE hiDll = LoadLibrary( "wPDFView02.dll" ); // int pdfPrint(string filename, string password, string license_name, string license_key, int license_code, string options); typedef int( __stdcall * TypePdfPrint) ( char*, char*, char*, char*, unsigned long, char* ); TypePdfPrint pDllPdfPrint = (TypePdfPrint) GetProcAddress( hiDll, "pdfPrint" ); if(pDllPdfPrint) { CString csOptions = "HEADERC=" + csFilePath + ",FOOTERC=" + csFilePath; CString csLicPwd = ""; // empty CString csLicName = "..."; // add license data CString csLicKey = "..."; int iLicCode = ...;
int iR = pDllPdfPrint( csFilePath.GetBuffer(0), csLicPwd.GetBuffer(0), csLicName.GetBuffer(0), csLicKey.GetBuffer(0), iLicCode, csOptions.GetBuffer(0) ); if(iR <= 0) AfxMessageBox( "Cannot print the file " + csFilePath ); }
Visual Basic 6 Example:
Private Declare Function pdfPrint Lib "wPDFView02.dll" ( _ ByVal strFilenames As String, _ ByVal strPassword As String, _ ByVal strLicName As String, _ ByVal strLicKey As String, _ ByVal lngLicCode As Long, _ ByVal strOptions As String _ ) As Long
Private Sub Command1_Click() If pdfPrint(Text1.Text, "", "LIC_NAME", "LIC_CODE", 0, "") <= 0 Then MsgBox ("Cannot print PDF file") End If End Sub
.NET Example:
// .NET C# Code to print directly using the wPDFViewDemo01 Engine DLL // using System.Runtime.InteropServices; [DllImport("wPDFViewDemo01.dll", CharSet=CharSet.Ansi)] public static extern int pdfPrint(string filename, string password, string license_name, string license_key, int license_code, string options); private void Print_Click(object sender, System.EventArgs e) { pdfPrint(FileName.Text, "", // Password or "" "","",0, // License Information ""); // Options }
Delphi Example
function pdfPrint(filename: PChar; password: PChar; licname, lickey: PChar; liccode: Cardinal; options: PChar): Integer; stdcall; external 'wPDFViewDemo01.dll' name 'pdfPrint';
Please update the code to use wPDFViewDemo01.dll or wPDFView01.dll.
The options string can contain several parameters. They need to be placed in quotes (") and separated by comma sings.
PRINTER=xxxx - select printer name COPIES=n - select count of copies COLLATE=1 - enable collate mode LISTPRINTER=1 - list all printer names to debug console LISTTRAY=1 - list all paper trays to debug console TRAY1=N - printer tray for first page TRAY2=N - printer tray for all pages STRETCH=1 - print the page inside physical page margins STRETCH=2 - print the page stretched to the page size (don't add margins) WATERMARK=name of a enhanced meta file to print a watermark on all pages (stretched to page size!) OVERPAGE=name of a enhanced meta file to print a drawing over all pages (stretched to page size!) DUPLEX - select duplex mode: 0 = simplex, 1=horizontal, 2=vertical
new options in version 2: HEADERFONT can be used to set the font name for the header text, HEADERFONTSIZE = size in pt FOOTERFONT can be used to set the font name for the footer text, FOOTERFONTSIZE = size in pt
HEADERL - string to print in header on left side (at the top of printable area) HEADERC - string to print in header centered HEADERR - string to print in header on right side FOOTERL - string to print in footer on left side (at the bottom of printable area) FOOTERC - string to print in footer centered FOOTERR - string to print in footer on right side
In these strings you can use the placeholder [#] to print the current page number and [##] to print the page count.
|