Search and replace to find all tabs and replace them with a space?

I have a pdf file that I have to reformat, so I I can edit it and remail it. I can’t upload a file showing the issue because I don’t have 3 points-not sure what that means::>

My edit would take me months, there’s almost 2000 pages in the document.

It appears the pdf has tabs in it (between the words) when I select the text and paste it into an ods file. I need to find each tab and convert it to a space…either that, or make the tab value equal to one so it will appear to be a space.

I can’t figure out how to use either possible solution.

HHHHHEEEEELLLLLLPPPPPP…

test file.odt

+1 … should be enough to upload your PDF file.

TY librebel, But I can only tell you what the screen says, it said I need 3 points. I can attach a screen capture showing my screen, but it won’t allow me to upload the screen capture till I get 3 points. Is there a quick and dirty way to get 3 points?

You already have 11 points ( the +1 vote gave you 10 karma points).

I’m new to the forum, and don’t know all the features yet. Now that I know the points refer to ‘karma points’, I’ll look them up to understand them!!! I see ‘karma’ listed on the page after I log in, so I did get a the short version of what karma points mean! I need to read the FAQ. It’s good to be aboard and thanks to all who run the forum and contribute. Many TY for the help.

This is what I have when I paste a paragraph from the pdf into writer:

What I say to people that say they hate exercise is that, fine, you can hate exercise. Oftentimes, you’re
not going to fall immediately in love with

This is what I would like to have as a result of some sort of search and replace (or similar) action:

What I say to people that say they hate exercise is that, fine, you can hate exercise. Often times, you’re
not going to fall immediately in love with

The message format above was changed by the forum when I submitted it-disregard it. I did upload my test file, which is a native writer file, see the edit to my original post.

Tabs have special meanings in Calc. Can you paste it into Writer? There, you would do a search for \t with “regular expressions” enabled, and replace it with a space.

I am pasting it into writer Paul, from pdf to writer. The test file I wanted to post is a writer document. Am I missing something? There is no calc involved.

I did find the /t with ‘regular expressions’ enabled in this forum with a search, but I do not know (and can’t find) a character that equates to a ‘space’. I tried tapping the space bar in the replace section of the dialog box for find and replace, but writer doesn’t recognize the space character if entered from the KB.

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

WOW, ty! But, I don’t understand any of this. I prefer to learn rather than to follow blindly-once learned, I do not have to continue looking for help/support. I am not sure why opening the pdf in Draw is needed, since I want the modified format to be readable in a writer document. What part of the libreoffice help file do I need to read in order to understand the suggested answer (I just need a ‘hint’…or some would say ‘a nudge in the right direction)’.

Yw @Ropi27,

If you open a PDF document in LibreOffice, it is automatically opened in Draw, since that is the LibreOffice program that can handle PDF.

I’ll update my answer with an easy way for you to call the macro directly from the menu Tools : Macros : Run Macro...

Nudge:
Help for LibreOffice Basic and Macros

This worked for me, with a bit of a mission (Can’t upvote yet though…)