Skip to Content
Menu
You need to be registered to interact with the community.
This question has been flagged
1 Odgovori
972 Prikazi

Hello ! 

I have a bit of a problem, I want to generate some to retrieve the binary of my pdf and then display it to the user.


but with this request :

$reportName = 'account.report_invoice';

        $data = $encoder->encode([[$this->erp_invoice_id], $reportName]);


        $client = new Client($this->config['server_url'] . 'object');

        $client->setOption(Client::OPT_RETURN_TYPE, XMLParser::RETURN_PHP);

        $response = $client->send(

            new Request('execute_kw', [

                new Value($this->config['database']),

                new Value($this->config['uid'], Value::$xmlrpcInt),

                new Value($this->config['pass']),

                new Value('report'),

                new Value('get_pdf'),

                $data

            ])

        );


I get this error :

Error fetching PDF: Invalid response payload (you can use the setDebug method to allow analysis of the response) XML error 9: Invalid character at line 9, column 13

I have the impression that the problem comes from the data I'm receiving, but how do I manage this?
Thanks for your help !

Avatar
Opusti
Avtor Best Answer

I found this solution for downloading the PDF

$encoder = new Encoder();
$data = $encoder->encode([$this->erp_invoice_id]);

$client = new Client($this->config['server_url'] . 'report');
$client->setOption(Client::OPT_RETURN_TYPE, XMLParser::RETURN_PHP);
$response = $client->send(
new Request('render_report', [
new Value($this->config['database']),
new Value($this->config['uid'], Value::$xmlrpcInt),
new Value($this->config['pass']),
new Value('account.report_invoice'),
$data
])
);

if (!$response->faultCode()) {
$res = $response->value();

$pdf_data = base64_decode($res['result']);
return (object)[
'data' => $pdf_data,
'invoice_id' => $this->erp_invoice_id,
];
} else {
trigger_error("ERROR GET PDF : " . $this->erp_invoice_id . " - Erreur PDF OdooV8 API :
" . $response->faultString(), E_USER_ERROR);
}
Avatar
Opusti
Related Posts Odgovori Prikazi Aktivnost
0
avg. 20
3685
3
avg. 25
188
3
avg. 25
1548
1
avg. 25
357
2
jul. 25
2806