I am using the following code to export an Open Office document as a pdf file using Delphi:
procedure TOOoWriter.SaveToPDF(FileName: string);
var
wProperties: variant;
begin
if not (fConnected and fDocumentOpened) then
abort;
wProperties := VarArrayCreate([0, 3], varVariant);
if fHTMLSrc then
wProperties[0] := MakePropertyValue('FilterName', 'writer_web_pdf_Export')
else
wProperties[0] := MakePropertyValue('FilterName', 'writer_pdf_Export');
wProperties[1] := MakePropertyValue('CompressionMode', '1');
wProperties[2] := MakePropertyValue('Pages', 'All');
wProperties[3] := MakePropertyValue('Overwrite', TRUE);
fDocument.StoreToURL('file:///'+ StringReplace(FileName, '\', '/', [rfIgnoreCase, rfReplaceAll]), wProperties);
end;
All is working well except:
it insists on opening the resultant pdf file (but not the OO file). This is problematic because I will be writing 100s of files without user interaction.
if the output pdf file does not exist I get an exception, but the file is created properly. The second time it works ok as the file was created the first time.
Are there solutions to these problems?