Page 1 of 1

[Solved] [PHP] Problem to export PDF /A with puno

Posted: Wed Nov 24, 2010 5:43 pm
by nclement
Hello.

I would like to convert an .odt file into a PDF /A file but when I do this the result is a PDF 1.4 file.

Here is my source code :

Code: Select all

...
$path= "file:///d:/tmp/myPDFA.pdf";
$storePDF = array();
$aFilterData[] = array();

// Set PDF Version to A-1
$aFilterData[0] = $osm->Bridge_GetStruct("com.sun.star.beans.PropertyValue") ;
$aFilterData[0]->Name = "SelectPdfVersion";
$aFilterData[0]->Value = 1; // 0 for PDF 1.4  1 for PDF/A-1

$storePDF[0]= $osm->Bridge_GetStruct("com.sun.star.beans.PropertyValue") ;
$storePDF[0]->Name="FilterName";
$storePDF[0]->Value = "writer_pdf_Export";
$storePDF[1] = $osm->Bridge_GetStruct("com.sun.star.beans.PropertyValue") ;
$storePDF[1]->Name="FilterData";
$storePDF[1]->Value = $aFilterData;

$rtpl->storeToURL($path,$storePDF); 
I don't know why I get a PDF 1.4 instead of a PDF/1-4 file.
When I read the wiki page refering to PDF export :
http://wiki.services.openoffice.org/wik ... PDF_export

It is said :
SelectPdfVersion :
Specifies the version of PDF to emit.
Possible values:
* 0 = PDF 1.4 (default selection).
* 1 = PDF/A-1 (ISO 19005-1:2005)
My OOo version is 3.1.

Thanks for your help.

Re: [PHP] Problem to export PDF /A with puno

Posted: Wed Dec 08, 2010 10:10 am
by nclement
I have succeeded in getting a PDF/A-1 file under JAVA & OOo SDK in (http://wiki.services.openoffice.org/wik ... clipseTuto)
with these lines of code :

Code: Select all

         PropertyValue pdfFilterData[] = new PropertyValue[2];
         pdfFilterData[0] = new PropertyValue();
         pdfFilterData[0].Name = "SelectPdfVersion";
         pdfFilterData[0].Value = new Integer(1);
         pdfFilterData[1] = new PropertyValue();
         pdfFilterData[1].Name = "UseTaggedPDF";
         pdfFilterData[1].Value = new Boolean("true"); // or false

         PropertyValue[] conversionProperties = new PropertyValue[2];
         conversionProperties[0] = new PropertyValue();
         conversionProperties[0].Name = "FilterName";
         conversionProperties[0].Value = "writer_pdf_Export";
         conversionProperties[1] = new PropertyValue();
         conversionProperties[1].Name = "FilterData";
         conversionProperties[1].Value = pdfFilterData;
If you know why it works under Java and not under PHP keep us posted please.

Re: [PHP] Problem to export PDF /A with puno

Posted: Wed Dec 08, 2010 11:52 am
by hanya
It seems the problem is value conversion in the puno bridge. The array of the css.beans.PropertyValue is passed to any type element of a .beans.PropertyValue in this case. PHP is not well typed language and it can not be convert the value into correct typed value of C++, which makes some problems. You can find the same kind of problem for python in this forum and pyuno bridge uses uno.Any class to pass typed value as any typed value.
You need to pass the value to it as typed value which can be converted to correct typed value by the bridge, but I do not know about puno.

Re: [PHP] Problem to export PDF /A with puno

Posted: Wed Dec 08, 2010 4:16 pm
by nclement
Thanks for your answer I think you are right. The problem comes from the PHP array which is not typed.
Unfortunately I haven't found anything about PropertyValue's array under PHP.

Re: [PHP] Problem to export PDF /A with puno

Posted: Thu Dec 09, 2010 5:21 pm
by nclement
I have tried the code below and I get a PDF/A-1 file ! :D

Code: Select all

$aFilterData  = array();
$aFilterData [0] = $osm->Bridge_GetStruct("com.sun.star.beans.PropertyValue");
$aFilterData [0]->Name = "SelectPdfVersion";
$aFilterData [0]->Value = 1;
$obj  = $osm->Bridge_GetValueObject();
$obj->set("[]com.sun.star.beans.PropertyValue",$aFilterData );
$storePDF = array();
$storePDF[0] = $osm->Bridge_GetStruct("com.sun.star.beans.PropertyValue");
$storePDF[0]->Name = "FilterName";
$storePDF[0]->Value = "writer_pdf_Export";
$storePDF[1] = $osm->Bridge_GetStruct("com.sun.star.beans.PropertyValue");   
$storePDF[1]->Name = "FilterData";
$storePDF[1]->Value = $obj;
$rtpl->storeToURL($path,$storePDF);