Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Incorporating DLL File in VFP program
Message
From
19/12/2013 04:30:24
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Incorporating DLL File in VFP program
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP
Network:
Windows XP
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01590624
Message ID:
01590624
Views:
195
I am new to working with DLL files. I have a DLL named PS2PDF.dll. It is used to create PDF from PS file.

My vfp Table has two columns INFILE and OUTFILE. Thousands of Records are like this:-

infile outfile
C:\x:\1234.ps D:\X1234.Pdf
C:\x:\23.ps D:\X23.Pdf
C:\Y:\238.ps D:\Y238.Pdf

I need a simple code to convert PS files to PDF using the above DLL.

Here is a sample VB code showing form and all. I need a simple VFP code for Fast conversion using the above DLL file. (i.e Conversion code using the DLL)

Please Guide

Here is the sample C & VB code as given in example of the DLL

C Code
      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
Harsh
Next
Reply
Map
View

Click here to load this message in the networking platform