콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
1 회신
1077 화면

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 !

아바타
취소
작성자 베스트 답변

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);
}
아바타
취소
관련 게시물 답글 화면 활동
0
8월 20
3833
1
8월 25
502
2
8월 25
528
3
8월 25
691
3
8월 25
1873