Re: [libreoffice-users] corrupt files when using command line --print-to-file

2022-04-11 Thread Mike Scott

On 11/04/2022 15:16, Philip Jackson wrote:

Hi Mike,

I'm using LO 6.4.7.2 on UbuntuStudio 20.04 LTS and your --headless 
command line instruction works and produces a pdf file which passed the 
pdfinfo check with flying colours. I just rechecked to make sure.   So 
maybe your problem is distro related?


Thanks for your reply. Interesting to know it works for someone else 
I'll do a bit more checking on what's going on here.




But I don't use the --headless command very often because it breaks the 
links in my pdf output. So, I make use of the LO Writer gui to do   
file> export as>export as pdf  which gets me a workable pdf with working 
links (clickable table of contents etc). If I need to reassemble some 
pdf docs, I use pdftk utility because so many of the others break those 
links.


I can't use the gui at all. The target document odt is actually created 
by a perl web script that modifies a template odt file, then converted 
using LO to either doc or pdf for the end user all running in the cgi 
context.


IIRC simple pdf conversion loses brochure formatting when present in the 
document, hence use of --print-to-file.




Philip

On 11/04/2022 10:51, Mike Scott wrote:
I'm having a spot of bother trying to get a .ps or .pdf produced from 
a .odt using the command line.


I've revisited some code last used a few years ago, whose last step is 
just to use LO to do this conversion. It used to make a .ps file, but 
that now seems to have changed, and I get a .pdf instead - which is 
corrupt.



So I get for example


libreoffice --headless --print-to-file --outdir "./"  "./y.odt"
print /dhome/mike/homebrew software/service sheet production/web 
generator/y.odt -> /dhome/mike/homebrew software/service sheet 
production/web generator//y.pdf using 



pdfinfo y.pdf

Syntax Warning: May not be a PDF file (continuing anyway)
Syntax Error (2432): Illegal character '{'
Syntax Error: Couldn't find trailer dictionary
Syntax Error: Couldn't find trailer dictionary
Syntax Error: Couldn't read xref table

The resulting pdf won't load into a browser and upsets several of the 
pdf tools, although gimp or xreader can read it. Fortunately, pdf2ps 
accepts the file, so as a workaround, I do the LO --print-to-file and 
then run the result through pdf2ps and then back through ps2pdf; the 
result of that contortion seems OK.



Looking at the GUI instead, under the tools|options|print page, if I 
try to set options for print to file, the tick box for pdf is set and 
disabled. Yet if I select print to file in the normal print dialogue, 
I get a valid .ps file not a pdf.


I need to run this as a print job, since '--convert-to pdf' doesn't 
honour the brochure setting in place in the document. Using the GUI 
and printing works fine, but isn't useful for automated processing.


If anyone has a way better of doing a command line conversion to a pdf 
while honouring in particular the 'brochure' setting, I'd be grateful.




(This is with LO 6.4.7.2 under mint 20)





--
Mike Scott
Harlow, Essex, England

--
To unsubscribe e-mail to: users+unsubscr...@global.libreoffice.org
Problems? https://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: https://wiki.documentfoundation.org/Netiquette
List archive: https://listarchives.libreoffice.org/global/users/
Privacy Policy: https://www.documentfoundation.org/privacy


Re: [libreoffice-users] corrupt files when using command line --print-to-file

2022-04-11 Thread Philip Jackson

Hi Mike,

I'm using LO 6.4.7.2 on UbuntuStudio 20.04 LTS and your --headless command line 
instruction works and produces a pdf file which passed the pdfinfo check with 
flying colours. I just rechecked to make sure.   So maybe your problem is 
distro related?

But I don't use the --headless command very often because it breaks the links in my 
pdf output. So, I make use of the LO Writer gui to do   file> export as>export 
as pdf  which gets me a workable pdf with working links (clickable table of contents 
etc). If I need to reassemble some pdf docs, I use pdftk utility because so many of 
the others break those links.

Philip

On 11/04/2022 10:51, Mike Scott wrote:

I'm having a spot of bother trying to get a .ps or .pdf produced from a .odt 
using the command line.

I've revisited some code last used a few years ago, whose last step is just to 
use LO to do this conversion. It used to make a .ps file, but that now seems to 
have changed, and I get a .pdf instead - which is corrupt.


So I get for example


libreoffice --headless --print-to-file --outdir "./"  "./y.odt"

print /dhome/mike/homebrew software/service sheet production/web generator/y.odt -> 
/dhome/mike/homebrew software/service sheet production/web generator//y.pdf using 



pdfinfo y.pdf

Syntax Warning: May not be a PDF file (continuing anyway)
Syntax Error (2432): Illegal character '{'
Syntax Error: Couldn't find trailer dictionary
Syntax Error: Couldn't find trailer dictionary
Syntax Error: Couldn't read xref table

The resulting pdf won't load into a browser and upsets several of the pdf 
tools, although gimp or xreader can read it. Fortunately, pdf2ps accepts the 
file, so as a workaround, I do the LO --print-to-file and then run the result 
through pdf2ps and then back through ps2pdf; the result of that contortion 
seems OK.


Looking at the GUI instead, under the tools|options|print page, if I try to set 
options for print to file, the tick box for pdf is set and disabled. Yet if I 
select print to file in the normal print dialogue, I get a valid .ps file not a 
pdf.

I need to run this as a print job, since '--convert-to pdf' doesn't honour the 
brochure setting in place in the document. Using the GUI and printing works 
fine, but isn't useful for automated processing.

If anyone has a way better of doing a command line conversion to a pdf while 
honouring in particular the 'brochure' setting, I'd be grateful.



(This is with LO 6.4.7.2 under mint 20)


--
To unsubscribe e-mail to: users+unsubscr...@global.libreoffice.org
Problems? https://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: https://wiki.documentfoundation.org/Netiquette
List archive: https://listarchives.libreoffice.org/global/users/
Privacy Policy: https://www.documentfoundation.org/privacy


[libreoffice-users] corrupt files when using command line --print-to-file

2022-04-11 Thread Mike Scott

Hi all.

I'm having a spot of bother trying to get a .ps or .pdf produced from a 
.odt using the command line.


I've revisited some code last used a few years ago, whose last step is 
just to use LO to do this conversion. It used to make a .ps file, but 
that now seems to have changed, and I get a .pdf instead - which is corrupt.



So I get for example


libreoffice --headless --print-to-file --outdir "./"  "./y.odt"
print /dhome/mike/homebrew software/service sheet production/web 
generator/y.odt -> /dhome/mike/homebrew software/service sheet 
production/web generator//y.pdf using 



pdfinfo y.pdf

Syntax Warning: May not be a PDF file (continuing anyway)
Syntax Error (2432): Illegal character '{'
Syntax Error: Couldn't find trailer dictionary
Syntax Error: Couldn't find trailer dictionary
Syntax Error: Couldn't read xref table

The resulting pdf won't load into a browser and upsets several of the 
pdf tools, although gimp or xreader can read it. Fortunately, pdf2ps 
accepts the file, so as a workaround, I do the LO --print-to-file and 
then run the result through pdf2ps and then back through ps2pdf; the 
result of that contortion seems OK.



Looking at the GUI instead, under the tools|options|print page, if I try 
to set options for print to file, the tick box for pdf is set and 
disabled. Yet if I select print to file in the normal print dialogue, I 
get a valid .ps file not a pdf.


I need to run this as a print job, since '--convert-to pdf' doesn't 
honour the brochure setting in place in the document. Using the GUI and 
printing works fine, but isn't useful for automated processing.


If anyone has a way better of doing a command line conversion to a pdf 
while honouring in particular the 'brochure' setting, I'd be grateful.




(This is with LO 6.4.7.2 under mint 20)

--
Mike Scott
Harlow, Essex, England

--
To unsubscribe e-mail to: users+unsubscr...@global.libreoffice.org
Problems? https://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: https://wiki.documentfoundation.org/Netiquette
List archive: https://listarchives.libreoffice.org/global/users/
Privacy Policy: https://www.documentfoundation.org/privacy