Forum


Replies: 9   Views: 5908
Transform.php docx to pdf
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by willow  · 20-05-2014 - 18:44

Hola,



estoy probando los ejemplos en concrecto PHPdocx/examples/advanced/Transform.php



Cuando ejecuto desde línea de comando "php Transform.php" solo me genera el archivo example_text.docx pero no el example_text.pdf y tampoco me muestra ningún error por consola.



Tengo instalado OpenOffice 4 y CentOS 6.5 64bit.



/opt/openoffice4/program/soffice.bin -headless -accept="socket,host=127.0.0.1,port=8100;urp;" -nofirststartwizard &



¿Alguna idea?



Gracias.Un saludo.



PD: Tengo la versión Pro+



 


Posted by jorgelj  · 21-05-2014 - 10:40

Hola,



Habilita la opción debug en el método transformDocx para ver toda la información posible y pégala para que la podamos revisar.



Comprueba también si puedes ejecutar correctamente la versión 64bits de OdfConverter en tu equipo. Es decir ejecútala desde la línea de comandos a ver si te da algún error.



Saludos.


Posted by willow  · 21-05-2014 - 12:52

 



Hola



Gracias por la respuesta.



Te indico:



[root@server advanced]# pwd



/var/www/html/PHPdocx/examples/advanced

[root@server advanced]# php Transform.php

2014-05-21T12:23:16+02:00 phpdocx_logger INFO  Create a temp file to use as initial ZIP file. DOCX is a ZIP file.

2014-05-21T12:23:16+02:00 phpdocx_logger INFO  Set language.

2014-05-21T12:23:16+02:00 phpdocx_logger INFO  Enable compatibility mode.

2014-05-21T12:23:16+02:00 phpdocx_logger INFO  Add text to word document.

2014-05-21T12:23:16+02:00 phpdocx_logger INFO  Set DOCX name to: example_text.

2014-05-21T12:23:16+02:00 phpdocx_logger INFO  DOCX is a new file, not a template.

2014-05-21T12:23:16+02:00 phpdocx_logger INFO  Remove existing template tags.

2014-05-21T12:23:16+02:00 phpdocx_logger INFO  Add word/document.xml content to DOCX file.

2014-05-21T12:23:16+02:00 phpdocx_logger INFO  Close ZIP file

2014-05-21T12:23:16+02:00 phpdocx_logger INFO  Copy DOCX file using a new name.

[root@server advanced]# ls

example_text.docx  FloatingTable.php  Report.php  Transform.php

[root@server advanced]#



 



No se crea el PDF...



[root@server 64]# pwd



/var/www/html/PHPdocx/lib/OdfConverter/64

[root@server 64]#  ./OdfConverter

./OdfConverter: error while loading shared libraries: libfontconfig.so.1: cannot open shared object file: No such file or directory





El problema estaba aquí. Instaladas las dependencias y listo.



[root@server 64]# pwd

/var/www/html/PHPdocx/lib/OdfConverter/64



 



root@server 64]# ./OdfConverter

Incorrect or missing conversion parameters: Input is missing



Usage: OdfConverter.exe /I PathOrFilename [/O PathOrFilename] [/<OPTIONS>]



  Where options are:

     /I PathOrFilename  Name of the file to transform (or input folder in case of batch conversion)

     /O PathOrFilename  Name of the output file (or output folder)

     /F                 Overwrite existing file(s)

     /V                 Validate the result of the transformation against the schemas

     /P                 Show conversion progress on the command line

     /REPORT Filename   Name of the report file that should be generated (existing files will be replaced)

     /LEVEL Level       Level of reporting: 1=DEBUG, 2=INFO, 3=WARNING, 4=ERROR



  Batch options (use one of the /BATCH-<format> options at a time):

     /BATCH-ODT         Do a batch conversion over every ODT file in the input folder (Note: use /F to replace existing files)

     /BATCH-DOCX        Do a batch conversion over every DOCX file in the input folder (Note: use /F to replace existing files)

     /BATCH-ODP         Do a batch conversion over every ODP file in the input folder (Note: use /F to replace existing files)

     /BATCH-PPTX        Do a batch conversion over every PPTX file in the input folder (Note: use /F to replace existing files)

     /BATCH-ODS         Do a batch conversion over every ODS file in the input folder (Note: use /F to replace existing files)

     /BATCH-XLSX        Do a batch conversion over every XLSX file in the input folder (Note: use /F to replace existing files)

     /R                 Process subfolders recursively during batch conversion



  Conversion direction options (to disable automatic file type detection):

     /ODT2DOCX          Force conversion to DOCX regardless of input file extension

     /DOCX2ODT          Force conversion to ODT regardless of input file extension

     /ODS2XLSX          Force conversion to XLSX regardless of input file extension

     /XLSX2ODS          Force conversion to ODS regardless of input file extension

     /ODP2PPTX          Force conversion to PPTX regardless of input file extension

     /PPTX2ODP          Force conversion to ODP regardless of input file extension



  Developer options:

     /XSLT Path         Path to a folder containing XSLT files (must be the same as used in the lib)

     /NOPACKAGING       Don't package the result of the transformation into a ZIP archive (produce raw XML)

     /SKIP Name         Skip a post-processing (provide the post-processor's name)



[root@server advanced]# php Transform.php

2014-05-21T12:45:40+02:00 phpdocx_logger INFO  Create a temp file to use as initial ZIP file. DOCX is a ZIP file.

2014-05-21T12:45:40+02:00 phpdocx_logger INFO  Set language.

2014-05-21T12:45:40+02:00 phpdocx_logger INFO  Enable compatibility mode.

2014-05-21T12:45:40+02:00 phpdocx_logger INFO  Add text to word document.

2014-05-21T12:45:40+02:00 phpdocx_logger INFO  Set DOCX name to: example_text.

2014-05-21T12:45:40+02:00 phpdocx_logger INFO  DOCX is a new file, not a template.

2014-05-21T12:45:40+02:00 phpdocx_logger INFO  Remove existing template tags.

2014-05-21T12:45:40+02:00 phpdocx_logger INFO  Add word/document.xml content to DOCX file.

2014-05-21T12:45:40+02:00 phpdocx_logger INFO  Close ZIP file

2014-05-21T12:45:40+02:00 phpdocx_logger INFO  Copy DOCX file using a new name.

[root@server advanced]# ls -l

total 44

-rw-r--r-- 1 root root 24333 may 21 12:45 example_text.docx

-rw-r--r-- 1 root root  1985 may 21 12:45 example_text.pdf

-rwxrwxrwx 1 root root  3601 may  8 09:38 FloatingTable.php

-rwxrwxrwx 1 root root  5320 may  8 09:38 Report.php

-rwxrwxrwx 1 root root  1904 may 20 14:51 Transform.php

[root@server advanced]#



Gracias por todo.



Saludos.


Posted by willow  · 28-05-2014 - 11:06

Una duda,



porque desde consola si se genera el PDF y desde Apache (http://IP/pdf.php) ¿no?



El fichero "error.log" de Apache muestra este mensaje:



sh: line 1: 27292 Aborted                 /var/www/includes/PHPdocx/classes/../lib/OdfConverter/64/OdfConverter /I /tmp/tempDocX_5385a49ac0f01.docx /O /tmp/tempOdt_5385a49ac3d6e.odt > /dev/null 2>&1



¿alguna idea?



Gracias.


Posted by jorgelj  · 28-05-2014 - 12:52

Hola,



Puede deberse a permisos del sistema de archivos, la existencia de SELinux que bloquea la ejecución, o por permisos de Apache para invocar programas externos... Es decir el origen del problema puede ser de uno o más errores de configuración.



¿Has probado con el método de ejecución 'script' disponible como opción en el método?



Saludos.


Posted by willow  · 28-05-2014 - 17:48

Acabo de probarlo, ahora no me muestra error en el fichero "error.log" pero sigue sin generarme el archivo .PDF



$dir_tmp ='/tmp'; $dir ='/tmp'; $fichero = 'fichero.pdf'; $doc_tmp = 'documento';



$docx->createDocx($dir_tmp.$doc_tmp);



$docx->transformDocx($dir_tmp.$doc_tmp.'.docx', $dir.$fichero, null, array('method' => 'script'));



Selinux lo tengo desactivado.



¿cúales son los permisos que tengo que tener?



El archivo "/var/www/includes/PHPdocx/lib/OdfConverter/64/OdfConverter" tiene permiso 755 para el usuario "apache" y grupo "root"...



¿Alguna sugerencia?



Muchas gracias.



Saludos.


Posted by jorgelj  · 29-05-2014 - 09:11

Hola,



Con la información aportada no nos es posible averiguar el origen del error. Te recomendamos que revises los logs del servidor web y del sistema operativo para detectar el problema y poder solucionar.



En todo caso puedes comprar un ticket de soporte y nos conectaremos a tu servidor para hacer las pruebas correspondientes. Para esto necesitaremos acceso por SSH.



Saludos.


Posted by willow  · 04-06-2014 - 09:12

Con esta información me puede ayudar si es tema de permisos u otro tema ¿? Gracias. ** (OdfConverterTestStatic.exe:2004): CRITICAL **: _wapi_shm_file_open: shared file [/var/www/.wapi/shared_data-intranet-Linux-x86_64-328-12-0] open error: No such file or directory ** (OdfConverterTestStatic.exe:2004): CRITICAL **: _wapi_shm_attach: shared file [/var/www/.wapi/shared_data-intranet-Linux-x86_64-328-12-0] open error ** ERROR **: file shared.c: line 349 (shm_semaphores_init): assertion failed: (tmp_shared != NULL) aborting... ** (process:2004): WARNING (recursed) **: Thread (nil) may have been prematurely finalized Stacktrace: ** (process:2004): WARNING (recursed) **: Thread (nil) may have been prematurely finalized Native stacktrace: /var/www/includes/PHPdocx/classes/../lib/OdfConverter/64/OdfConverter() [0x44ca20] /lib64/libpthread.so.0(+0xf710) [0x7f6b5876f710] /lib64/libc.so.6(gsignal+0x35) [0x7f6b56103925] /lib64/libc.so.6(abort+0x175) [0x7f6b56105105] /lib64/libglib-2.0.so.0(g_logv+0x53a) [0x7f6b5801d98a] /lib64/libglib-2.0.so.0(g_log+0x83) [0x7f6b5801da23] /lib64/libglib-2.0.so.0(g_assert_warning+0x34) [0x7f6b5801da64] /var/www/includes/PHPdocx/classes/../lib/OdfConverter/64/OdfConverter() [0x52784c] /var/www/includes/PHPdocx/classes/../lib/OdfConverter/64/OdfConverter() [0x521ef3] /var/www/includes/PHPdocx/classes/../lib/OdfConverter/64/OdfConverter(mono_once+0x85) [0x516575] /var/www/includes/PHPdocx/classes/../lib/OdfConverter/64/OdfConverter(_wapi_handle_new+0x33) [0x521e73] /var/www/includes/PHPdocx/classes/../lib/OdfConverter/64/OdfConverter() [0x51d885] /var/www/includes/PHPdocx/classes/../lib/OdfConverter/64/OdfConverter(CreateSemaphore+0x19e) [0x51dc2e] /var/www/includes/PHPdocx/classes/../lib/OdfConverter/64/OdfConverter() [0x4f42cc] /var/www/includes/PHPdocx/classes/../lib/OdfConverter/64/OdfConverter(mono_runtime_init+0x25) [0x4ad5a5] /var/www/includes/PHPdocx/classes/../lib/OdfConverter/64/OdfConverter() [0x540ea1] /var/www/includes/PHPdocx/classes/../lib/OdfConverter/64/OdfConverter(mono_main+0x396) [0x4333d6] /var/www/includes/PHPdocx/classes/../lib/OdfConverter/64/OdfConverter(main+0x17d) [0x432ae3] /lib64/libc.so.6(__libc_start_main+0xfd) [0x7f6b560efd1d] /var/www/includes/PHPdocx/classes/../lib/OdfConverter/64/OdfConverter(fmod+0x81) [0x4326e9] Debug info from gdb: ================================================================= Got a SIGABRT while executing native code. This usually indicates a fatal error in the mono runtime or one of the native libraries used by your application. ================================================================= Jun 04, 2014 11:09:27 AM com.artofsolving.jodconverter.openoffice.connection.AbstractOpenOfficeConnection connect INFO: connected Jun 04, 2014 11:09:27 AM com.artofsolving.jodconverter.openoffice.connection.AbstractOpenOfficeConnection disposing INFO: disconnected Exception in thread "main" java.lang.IllegalArgumentException: inputFile doesn't exist: /tmp/tempOdt_538ee2474b481.odt at com.artofsolving.jodconverter.openoffice.converter.AbstractOpenOfficeDocumentConverter.convert(AbstractOpenOfficeDocumentConverter.java:90) at com.artofsolving.jodconverter.openoffice.converter.AbstractOpenOfficeDocumentConverter.convert(AbstractOpenOfficeDocumentConverter.java:74) at com.artofsolving.jodconverter.openoffice.converter.AbstractOpenOfficeDocumentConverter.convert(AbstractOpenOfficeDocumentConverter.java:70) at com.artofsolving.jodconverter.cli.ConvertDocument.convertOne(ConvertDocument.java:154) at com.artofsolving.jodconverter.cli.ConvertDocument.main(ConvertDocument.java:133)

Posted by willow  · 04-06-2014 - 09:21

En este hilo lo explica: http://www.phpdocx.com/en/forum/default/topic/666 Ahora si me funciona. Gracias.

Posted by jorge  · 04-06-2014 - 11:17

Hola, Perfecto, nos alegra que hayas podido resover el problema. Saludos.