Hello @Ropi27,
To find all Tabs in the current Draw document, and replace them with a Space, you could use the function Draw_ReplaceAll()
specified below.
Just call it as follows ( first open your PDF in LibreOffice Draw):
Draw_ReplaceAll( chr(9), chr(32) )
EDIT 2018-01-31 :
Or just call the helper method Draw_ReplaceAll_Tabs_with_a_Space()
directly from the menu “Tools : Macros : Run Macro…”.
Sub Draw_ReplaceAll_Tabs_with_a_Space()
Dim lCount as Long : lCount = Draw_ReplaceAll( chr(9), chr(32) )
msgbox "Replaced " & lCount & " Tabs with Spaces."
End Sub
Function Draw_ReplaceAll( strFind As String, strReplace As String ) As Long
REM Perform a Find/Replace inside the current Draw document.
REM <strFind> : String to be found and replaced; (Does not support Regular Expressions).
REM <strReplace>: String to replace the found substring with.
REM Returns the number of occurrences that were Found/Replaced.
Dim oDoc As Object : oDoc = ThisComponent
If oDoc.supportsService( "com.sun.star.drawing.GenericDrawingDocument" ) Then
Dim oDrawPages As Object : oDrawPages = oDoc.getDrawPages()
Dim oDrawPage As Object
Dim oReplace as Object
Dim lCount As Long
Dim i As Integer
For i = 0 To oDrawPages.getCount() - 1 REM Traverse all DrawPages.
oDrawPage = oDrawPages.getByIndex( i )
oReplace = oDrawPage.createReplaceDescriptor()
oReplace.setSearchString( strFind )
oReplace.setReplaceString( strReplace )
' oReplace.SearchCaseSensitive = True REM TODO: Optional parameters.'
' oReplace.SearchBackwards = True '
' oReplace.SearchWords = True '
lCount = lCount + oDrawPage.replaceAll( oReplace )
Next i
Draw_ReplaceAll = lCount
End If
End Function
HTH, lib