can some one help me with how to replace text and save, I want to open PDF search for some text example Apple and replace it with Banana save the pdf and exit
Here's my current code, Any help or direction will be appreciated.
Code: Select all
Public Sub CreateDoc()
Dim PXV As PDFXEdit.PXV_Inst
Dim pxc As New PDFXEdit.PXC_Inst
Dim Doc As IPXC_Document
Dim objdcb As IPXC_DocAuthCallback
Dim objContent As IPXC_Content
Dim retv() As Byte
Dim ar1(20) As String
Dim retv2 As IPXS_PDFVariant
Dim ts As IPXC_TState
Dim pf As PXC_PointF
Set PXV = New PDFXEdit.PXV_Inst
PXV.Init
Set pxc = PXV.GetExtension("PXC")
pxc.Init ""
Set Doc = pxc.OpenDocumentFromFile("Path\FP101A - Copy.pdf", Nothing)
Set objContent = Doc.Pages.Item(0).GetContent(CAccessMode_FullClone)
For i = 1 To objContent.Items.Count - 1
If objContent.Items.Item(i).Type = CIT_Text Then
Dim s() As String
Call objContent.Items.Item(i).Text_GetDataSA(retv())
Set retv2 = objContent.Items.Item(i).Text_GetData2()
For ir = LBound(retv) To UBound(retv)
sText = sText & Chr(retv(ir))
If sText = "SamplText" Then
MsgBox "Found: " & sText
'Replace "d" of "Approved" with the letter "N"
retv(3) = 65
Call retv2.Arr_SetInt(ir, 78)
Set ts = objContent.Items.Item(i).GetTState
'Set res = objContent.Items.Item(i).Text_SetData(retv2, ts) '<--- this line gives error Function not available in VB
End If
Next
Debug.Print sText
sText = vbNullString
End If
Next
Doc.WriteToFile "path\macroedited.pdf"
Doc.Close
pxc.Finalize
End Sub