VB代码Private Declare Function PDFExtractToTIFF Lib "pdf2tif.dll" (ByVal Source As String, ByVal Dest As String, ByVal m_bIsSinglePage As Long, ByVal ownerpassword As String, ByVal userpassword As String) As Long
Private Declare Sub PDFExtractToTIFF_SetOptions Lib "pdf2tif.dll" (ByVal ptrKey As String, ByVal ptrValue As String)
Private Sub bconvert_Click()
' only PDF Files
cdialog.Filter = "PDF Files (*.PDF)|*.PDF"
' if ok
cdialog.ShowOpen
' if file specified
If cdialog.FileName <> "" Then
' Application exe path and add filename for txt
TIFFFile = App.Path + "\multipage.tif"
' Txt file exist ?
If Dir(TIFFFile) <> "" Then
' ok delete it
Kill TIFFFile
End If
PDFExtractToTIFF_SetOptions "RemoveThumbnail", "1"
PDFExtractToTIFF cdialog.FileName, TIFFFile, 1, "", ""
PDFExtractToTIFF cdialog.FileName, TIFFFile, 0, "", ""
End If
End SubVC代码#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>extern "C" __declspec(dllexport)
void __stdcall PDFExtractToTIFF_SetDPI(int xDPI, int yDPI);//The ptrKey can be selected one of following values,
// ptrKey = "XDPI", ptrValue = "300" or "600" or others
// ptrKey = "YDPI", ptrValue = "300" or "600" or others
// ptrKey = "AutoMergeStrips", ptrValue = "1" or "0"
// ptrKey = "ExportJPG", ptrValue = "1" or "0"
// ptrKey = "RemoveThumbnail", ptrValue = "1" or "0"
// ptrKey = "AutoRotate", ptrValue = "1" or "0"
// ptrKey = "AutoRotateOrientation", ptrValue = "1" or "0"
// ptrKey = "AutoInvertBWImage", ptrValue = "1" or "0"
// ptrKey = "AutoScale", ptrValue = "1" or "0"
// ptrKey = "FlipVerticalTIFFile", ptrValue = "1" or "0"
// ptrKey = "FlipHorizontalTIFFile", ptrValue = "1" or "0"
// ptrKey = "AddFileNameSuffix", ptrValue = "%04d" or "_%05d" or others
// ptrKey = "bQuickTIFFExtraction", ptrValue = "1" or "0"
// ptrKey = "FirstPage", ptrValue = first page number
// ptrKey = "LastPage", ptrValue = last page number
extern "C" __declspec(dllexport)
void __stdcall PDFExtractToTIFF_SetOptions(LPCTSTR ptrKey, LPCTSTR ptrValue);extern "C" __declspec(dllexport)
int __stdcall PDFExtractToTIFF(const char *ptrPDFName,const char *ptrTIFFName,
int m_bIsSinglePage,
const char* ownerPassword,
const char* userPassword);void main(int argc,char *argv[])
{
if(argc != 3)
{
printf("Usage: input.pdf output.tif");
return;
}
PDFExtractToTIFF_SetDPI(300,300);
PDFExtractToTIFF_SetOptions("AutoInvertBWImage","1");
PDFExtractToTIFF_SetOptions("AutoMergeStrips","1");
PDFExtractToTIFF_SetOptions("RemoveThumbnail","1");
int pagecount = PDFExtractToTIFF(argv[1],argv[2],0,NULL,NULL);
printf("Page Count(1): %d\n",pagecount);
printf("Please press any key to contine ...\n");
_getch();
PDFExtractToTIFF_SetDPI(200,200);
PDFExtractToTIFF_SetOptions("bQuickTIFFExtraction","0");
PDFExtractToTIFF_SetOptions("ExportJPG","1");
pagecount = PDFExtractToTIFF(argv[1],argv[2],1,NULL,NULL);
printf("'%s' Page Count(1): %d\n",argv[2],pagecount);
}
Private Declare Sub PDFExtractToTIFF_SetOptions Lib "pdf2tif.dll" (ByVal ptrKey As String, ByVal ptrValue As String)
Private Sub bconvert_Click()
' only PDF Files
cdialog.Filter = "PDF Files (*.PDF)|*.PDF"
' if ok
cdialog.ShowOpen
' if file specified
If cdialog.FileName <> "" Then
' Application exe path and add filename for txt
TIFFFile = App.Path + "\multipage.tif"
' Txt file exist ?
If Dir(TIFFFile) <> "" Then
' ok delete it
Kill TIFFFile
End If
PDFExtractToTIFF_SetOptions "RemoveThumbnail", "1"
PDFExtractToTIFF cdialog.FileName, TIFFFile, 1, "", ""
PDFExtractToTIFF cdialog.FileName, TIFFFile, 0, "", ""
End If
End SubVC代码#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>extern "C" __declspec(dllexport)
void __stdcall PDFExtractToTIFF_SetDPI(int xDPI, int yDPI);//The ptrKey can be selected one of following values,
// ptrKey = "XDPI", ptrValue = "300" or "600" or others
// ptrKey = "YDPI", ptrValue = "300" or "600" or others
// ptrKey = "AutoMergeStrips", ptrValue = "1" or "0"
// ptrKey = "ExportJPG", ptrValue = "1" or "0"
// ptrKey = "RemoveThumbnail", ptrValue = "1" or "0"
// ptrKey = "AutoRotate", ptrValue = "1" or "0"
// ptrKey = "AutoRotateOrientation", ptrValue = "1" or "0"
// ptrKey = "AutoInvertBWImage", ptrValue = "1" or "0"
// ptrKey = "AutoScale", ptrValue = "1" or "0"
// ptrKey = "FlipVerticalTIFFile", ptrValue = "1" or "0"
// ptrKey = "FlipHorizontalTIFFile", ptrValue = "1" or "0"
// ptrKey = "AddFileNameSuffix", ptrValue = "%04d" or "_%05d" or others
// ptrKey = "bQuickTIFFExtraction", ptrValue = "1" or "0"
// ptrKey = "FirstPage", ptrValue = first page number
// ptrKey = "LastPage", ptrValue = last page number
extern "C" __declspec(dllexport)
void __stdcall PDFExtractToTIFF_SetOptions(LPCTSTR ptrKey, LPCTSTR ptrValue);extern "C" __declspec(dllexport)
int __stdcall PDFExtractToTIFF(const char *ptrPDFName,const char *ptrTIFFName,
int m_bIsSinglePage,
const char* ownerPassword,
const char* userPassword);void main(int argc,char *argv[])
{
if(argc != 3)
{
printf("Usage: input.pdf output.tif");
return;
}
PDFExtractToTIFF_SetDPI(300,300);
PDFExtractToTIFF_SetOptions("AutoInvertBWImage","1");
PDFExtractToTIFF_SetOptions("AutoMergeStrips","1");
PDFExtractToTIFF_SetOptions("RemoveThumbnail","1");
int pagecount = PDFExtractToTIFF(argv[1],argv[2],0,NULL,NULL);
printf("Page Count(1): %d\n",pagecount);
printf("Please press any key to contine ...\n");
_getch();
PDFExtractToTIFF_SetDPI(200,200);
PDFExtractToTIFF_SetOptions("bQuickTIFFExtraction","0");
PDFExtractToTIFF_SetOptions("ExportJPG","1");
pagecount = PDFExtractToTIFF(argv[1],argv[2],1,NULL,NULL);
printf("'%s' Page Count(1): %d\n",argv[2],pagecount);
}
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons;type
TForm1 = class(TForm)
OpenPDF: TOpenDialog;
BitBtn1: TBitBtn;
procedure BitBtn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;const
DLLName='pdf2tif.dll';
//Private Declare Function PDFExtractToTIFF Lib "pdf2tif.dll" (ByVal Source As String, ByVal Dest As String, ByVal m_bIsSinglePage As Long, ByVal ownerpassword As String, ByVal userpassword As String) As Long
function PDFExtractToTIFF (Source,Dest:string;m_bIsSinglePage:LongInt;ownerpassword,userpassword:string):LongInt;external DLLName;
//Private Declare Sub PDFExtractToTIFF_SetOptions Lib "pdf2tif.dll" (ByVal ptrKey As String, ByVal ptrValue As String)
procedure PDFExtractToTIFF_SetOptions(ptrKey,ptrValue:string); external DLLName;var
Form1:TForm;
implementation{$R *.dfm}procedure TForm1.BitBtn1Click(Sender: TObject);
var FileName,TIFFFile:string;
begin
TIFFFile:='c:\1.tif';
if OpenPDF.Execute then
FileName:=OpenPDF.FileName;
ShowMessage(FileName);
if FileExists(FileName) then
begin
PDFExtractToTIFF_SetOptions('RemoveThumbnail', '1');
PDFExtractToTIFF(FileName,TIFFFile,1,'','');
PDFExtractToTIFF(FileName,TIFFFile,0,'','');
end;
end;end.
DLLName = 'pdf2tif.dll';
//Private Declare Function PDFExtractToTIFF Lib "pdf2tif.dll" (ByVal Source As String, ByVal Dest As String, ByVal m_bIsSinglePage As Long, ByVal ownerpassword As String, ByVal userpassword As String) As Long
function PDFExtractToTIFF (Source, Dest: PChar; m_bIsSinglePage:LongBool; ownerpassword, userpassword: PChar): Integer; stdcall; external DLLName;
//Private Declare Sub PDFExtractToTIFF_SetOptions Lib "pdf2tif.dll" (ByVal ptrKey As String, ByVal ptrValue As String)
procedure PDFExtractToTIFF_SetOptions(ptrKey, ptrValue: PChar); stdcall; external DLLName;