long id = CreatePDF(d:\\test\\out.pdf); if( id > 0 ) { Convert(id); ClosePDF(id); }VB code
VERSION 5.00 Begin VB.Form Form1 BorderStyle = 4 'Fixed ToolWindow Caption = "AdultPDF PS to PDF sdk demo" ClientHeight = 2430 ClientLeft = 45 ClientTop = 345 ClientWidth = 6345 LinkTopic = "Form1" MaxButton = 0 'False MinButton = 0 'False ScaleHeight = 2430 ScaleWidth = 6345 ShowInTaskbar = 0 'False StartUpPosition = 3 'Windows Default Begin VB.CommandButton btnDemo2 Caption = "demo2" Height = 495 Left = 2520 TabIndex = 1 Top = 840 Width = 1335 End Begin VB.CommandButton btnDemo1 Caption = "demo1" Height = 495 Left = 480 TabIndex = 0 Top = 840 Width = 1335 End End Attribute VB_Name = "Form1" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False 'SDK interface definitions. '========================================================================================================================================================= Private Declare Function apCreate Lib "ps2pdf.dll" Alias "_apCreate@0" () As Long Private Declare Sub apClose Lib "ps2pdf.dll" Alias "_apClose@4" (ByVal id As Long) Private Declare Function apConvert Lib "ps2pdf.dll" Alias "_apConvert@4" (ByVal id As Long) As Long Private Declare Function apSetFunc Lib "ps2pdf.dll" Alias "_apSetFunc@24" (ByVal id As Long, ByVal code As Long, ByVal nOptVal1 As Long, ByVal nOptVal2 As Long, ByVal pOptVal1 As String, ByVal pOptVal2 As String) As Long Private Declare Function apGetFunc Lib "ps2pdf.dll" Alias "_apGetFunc@24" (ByVal id As Long, ByVal code As Long, ByVal nOptVal1 As Long, ByVal nOptVal2 As Long, ByVal pOptVal1 As String, ByVal pOptVal2 As String) As Long ' Supported option definitions. Const AP_Set_Output = 3000 Const AP_Set_Input = 3001 Const AP_Set_PDFInfo = 3006 Const AP_Set_PDFEncrypt = 3007 'Supported pdf header information Const AP_PDF_TITLE = "title" Const AP_PDF_SUBJECT = "subject" Const AP_PDF_AUTHOR = "author" Const AP_PDF_KEYWORDS = "keywords" Const AP_PDF_APPLICATION = "creator" 'Supported encryption mode Const AP_PDF_ENCRYPT_40 = 40 Const AP_PDF_ENCRYPT_128 = 128 'Supported user access permissions Const AP_PDF_PERMISSION_NONE = 0 Const AP_PDF_PERMISSION_PRINT = 1 Const AP_PDF_PERMISSION_COPYING = 2 Const AP_PDF_PERMISSION_MODIFY = 4 Const AP_PDF_PERMISSION_ALL = 7 ' Convert ps files to a general pdf file. Private Sub btnDemo1_Click() Dim id, iRet As Long id = apCreate() If (id <> 0) Then apSetFunc id, AP_Set_Input, 0, 0, "test1.ps", 0 'input file. apSetFunc id, AP_Set_Input, 0, 0, "test2.ps", 0 'input file. apSetFunc id, AP_Set_Output, 0, 0, "test1.pdf", 0 'output format and file. apSetFunc id, AP_Set_PDFInfo, 0, 0, AP_PDF_TITLE, "untitled document" apSetFunc id, AP_Set_PDFInfo, 0, 0, AP_PDF_AUTHOR, "adultpdf" apSetFunc id, AP_Set_PDFInfo, 0, 0, AP_PDF_APPLICATION, "PS to PDF sdk demo" iRet = apConvert(id) apClose id End If End Sub ' Convert ps files to an restricted pdf file. Private Sub btnDemo2_Click() Dim id, iRet As Long Dim sUserPw, sOwnerPw As String sUserPw = "1111" sOwnerPw = "2222" id = apCreate() If (id <> 0) Then apSetFunc id, AP_Set_Input, 0, 0, "test1.ps", 0 'input file. apSetFunc id, AP_Set_Input, 0, 0, "test2.ps", 0 'input file. apSetFunc id, AP_Set_Output, 0, 0, "test2.pdf", 0 'output format and file. apSetFunc id, AP_Set_PDFInfo, 0, 0, AP_PDF_TITLE, "untitled document" apSetFunc id, AP_Set_PDFInfo, 0, 0, AP_PDF_AUTHOR, "adultpdf" apSetFunc id, AP_Set_PDFInfo, 0, 0, AP_PDF_APPLICATION, "PS to PDF sdk demo" apSetFunc id, AP_Set_PDFEncrypt, AP_PDF_ENCRYPT_128, AP_PDF_PERMISSION_PRINT + AP_PDF_PERMISSION_COPYING, sUserPw, sOwnerPw iRet = apConvert(id) apClose id End If End Sub