Link to home
Start Free TrialLog in
Avatar of SWB-Consulting
SWB-Consulting

asked on

How to fix X11 display issue?

When running this cronjob on my Fedora 7 Server:

# create pdfs and preview  
*/15 * * * * /usr/bin/convertdir2pdf restart /var/www/html/_files >> /var/www/html/_logs/convertdir2pdf.log 2>> /var/www/html/_logs/convertdir2pdf.log #JOB_ID_5

I am getting this error :

/usr/lib/openoffice.org/program/swriter.bin X11 error: Can't open display: localhost:0.0
   Set DISPLAY environment variable, use -display option
   or check permissions of your X-Server
   (See "man X" resp. "man xhost" for details)

I made sure that DISPLAY=:0.0 is in the crontab file but still giving my problems, any solution ?

My guess is that the problem is because of this line in the macro (see macro below)

"oDoc = StarDesktop.loadComponentFromURL(cURL, "_blank", 0, Array(MakePropertyValue("Hidden", True), ))"

so that the macro needs a X11 running, is there any solution to run this macro w/o GUI?
This is the content of "/usr/bin/convertdir2pdf" :
 
/usr/bin/oowriter -display localhost:0.0 -accept="socket,host=localhost,port=2002;urp;" -headless "macro:///Standard.Module1.ConvertWordToPDF($1)";
 
And this is the macro: 
 
REM  *****  BASIC  *****
 
Sub ConvertWordToPDF(cFile)
   cURL = ConvertToURL(cFile)
   
   ' Open the document.
   ' Just blindly assume that the document is of a type that OOo will
   '  correctly recognize and open -- without specifying an import filter.
   oDoc = StarDesktop.loadComponentFromURL(cURL, "_blank", 0, Array(MakePropertyValue("Hidden", True), ))
   
   cFile = Left(cFile, Len(cFile) - 4) + ".pdf"
   cURL = ConvertToURL(cFile)
   
   ' Save the document using a filter.
   oDoc.storeToURL(cURL, Array(MakePropertyValue("FilterName", "writer_pdf_Export"), ))
   
   oDoc.close(True)
   
End Sub
 
Function MakePropertyValue( Optional cName As String, Optional uValue ) As com.sun.star.beans.PropertyValue
   Dim oPropertyValue As New com.sun.star.beans.PropertyValue
   If Not IsMissing( cName ) Then
      oPropertyValue.Name = cName
   EndIf
   If Not IsMissing( uValue ) Then
      oPropertyValue.Value = uValue
   EndIf
   MakePropertyValue() = oPropertyValue
End Function

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of ravenpl
ravenpl
Flag of Poland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Xvfb should fix this issue - not clear if asker managed to do it though?