Open a PDF with LibreOffice

Hello

Trying to help somebody I built a process which opens aPages document in Pages,
export it in standard PDF
then open this standard PDF with LibreOffice which gives the ability to export as PDF/A which is required by the asker.
Quite everything works - using GUIScripting.
The only problem is that, from time to time the process opening in LibreOffice doen’t do its duty.

For test, I wrote this short script :

set theMainApp to path to application id "org.libreoffice.script" 

set cheminPDFtemp to (choose file "Choose a PDF file" of type {"com.adobe.pdf"}) as text

tell application "Finder" to open file cheminPDFtemp using theMainApp

Sometimes it works but sometimes it display an alert saying :
[format]« LibreOffice.app » est une application
téléchargée d’Internet. Voulez-vous vraiment
l’ouvrir ?
Safari.app a téléchargé ce fichier le 21 août 2016.
[Annuler] [Ouvrir][/format]

In English it means :

[format]« LibreOffice.app » is an application downloaded thru the Internet. Do you really want to open it ?
Safari.app downloaded the file on 2016/08/21
[Cancel] [Open][/format]

Clicking the Open button changes nothing. Sometimes the file opens after some minutes.

If I apply the script to a pdf which was created by LibreOffice, it opens well.

Is it a way to get a correct opening with standard PDFs.

At this time I have a workaround : replace the header %PDF-1.3 by %PDF-1.4

It seems awful but at least it works.

Yvan KOENIG running El Capitan 10.11.6 in French (VALLAURIS, France) mercredi 31 aout 2016 23:23:17

Up

Nobody knows ?

Yvan KOENIG running El Capitan 10.11.6 in French (VALLAURIS, France) vendredi 2 septembre 2016 18:26:48

Hi Yvan.

The only thing I would suggest you is to turn off the warning in the Mac.

You can do that trough Terminal with this commands :

defaults write com.apple.LaunchServices LSQuarantine -bool NO
killall -KILL Finder

To enable it again use:

defaults write com.apple.LaunchServices LSQuarantine -bool YES
killall -KILL Finder

Hope it helps,
Jorge

It may be a quarantine issue, but turning it off is a potentially dangerous thing to do. It’s there for a reason. If it is causing a problem, better to remove the quarantine setting from the relevant files.

Thanks to both of you.

I don’t know why, trying to get rid of the problem by a click on the dedicated button changed nothing during 15 days but this morning LibreOffice open the file with no problem.

During these 15 days I built an alternate scheme to open the documents;

The script grabs the doc with choose file
it moves it in a dedicated folder which is normally empty
it activate LibreOffice
it issue keystroke “o” using {command down} to get the Open file dialog
it issue keystroke “g” using {command down, shift down}
it fill the dedicated field with the POSIX path of the temporary folder
It extract the position and size of the second row in the outline displaying the file available
it use cliclick to double click in the named row to open the file.

Surprising enough, this scheme didn’t send the offending dialog.

It may appear as a cumbersome scheme but, as - all in all - I must rely upon GUI scripting to apply the tasks which are the real goal of the script, it’s not really annoying.
The final script has 1648 lines but many of them are comments.
There are about 700 true instructions.

Funny detail, to add a feature required by the asker, I had to use BridgePlus which gave me the idea to drop my old recursive scheme used to treat files embedded in nested folders. I just ask BridePlus to build a list of every files with its own recursive instruction.
Then I easily treat the listed items.

During years I was warned upon possible AppleScript stack overflow - which I never faced although the script was originally designed to build a table of every files available in CDs delivered with paper magazines. Yes, it was years ago, I guess that some of you didn’t know this era.
Now, using BridgePlus to build the list I guess that I will use less memory.

Yvan KOENIG running El Capitan 10.11.6 in French (VALLAURIS, France) vendredi 16 septembre 2016 11:17:39