Script for removing all the images from a PDF

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
pleaseplease11q
Posts: 2
Joined: Wed Feb 15, 2023 1:50 am

Script for removing all the images from a PDF

Post by pleaseplease11q »

I am on linux mint 21.
I am useing the code:

Code: Select all

Sub DeleteAllPics()
Dim oDoc As Object
Dim oDrawPage As Object
Dim oShape As Object
Dim iShape As Integer
Dim iSheet As Integer
oDoc = ThisComponent
For iSheet = 0 To oDoc.getSheets().getCount() - 1
oDrawPage = oDoc.getSheets().getByIndex(iSheet).getDrawPage()
For iShape = oDrawPage.getCount() - 1 To 0 Step -1
oShape = oDrawPage.getByIndex(i)
oDrawPage.remove(oShape)
Next iShape
Next iSheet
End Sub
From the post https://ask.libreoffice.org/t/writer-ho ... nt/14649/4. But when I try to run it, I get the error message:

BASIC runtime error.

Property or method not found: getSheets.

I looked at this post https://ask.libreoffice.org/t/missing-p ... s/77912/11, but I did not know how to interpret it.
Last edited by MrProgrammer on Wed Feb 15, 2023 2:02 am, edited 2 times in total.
Reason: Added [code] tags
OpenOffice 2.4 on Ubuntu 9.04
User avatar
robleyd
Moderator
Posts: 5082
Joined: Mon Aug 19, 2013 3:47 am
Location: Murbko, Australia

Re: Script for removing all the images from a pdf.

Post by robleyd »

Cheers
David
OS - Slackware 15 64 bit
Apache OpenOffice 4.1.15
LibreOffice 24.2.2.2; SlackBuild for 24.2.2 by Eric Hameleers
pleaseplease11q
Posts: 2
Joined: Wed Feb 15, 2023 1:50 am

Re: Script for removing all the images from a PDF

Post by pleaseplease11q »

That was my post. I just did not get the answers i needed.
OpenOffice 2.4 on Ubuntu 9.04
User avatar
Zizi64
Volunteer
Posts: 11359
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Script for removing all the images from a PDF

Post by Zizi64 »

Property or method not found: getSheets.
A Draw document has not any Sheets.

Please study Andrew Pitonyak's free macro books.
https://www.pitonyak.org/oo.php

You need some similar thing:

Code: Select all

	oDrawDoc = Thiscomponent
	oPages = oDrawDoc.GetDrawPages()
	
	iPageCount = oPages.GetCount() 
	For i = 0 to iPageCount-1
		oDrawPage = oDrawDoc.DrawPages(i)
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
Post Reply