I am seeking assistance in generating the Base64 representation of a PDF file that I intend to print. The goal is to merge an image into this PDF using PyPDF2. I have successfully managed to merge images into PDFs, but I need guidance on obtaining the Base64 representation of the existing PDF file so that I can include it in my project.
is it possible if somehow i could get base64 of report which i am printing using _get_report_values and return my modified pdf ?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Księgowość
- Zapasy
- PoS
- Project
- MRP
To pytanie dostało ostrzeżenie
I did this in v16 with something like this:
report = self.env.ref('stock.action_report_delivery')
pdf_content, dummy = self.env['ir.actions.report'].sudo().with_context(lang=self.partner_id.lang)._render_qweb_pdf(report, self.id)
data = base64.encodebytes(pdf_content)
Hope it helps :)-
Hope this snippet helps
from io import BytesIO
import base64
input_file = fields.Binary('File')
outputb64 = BytesIO(base64.b64decode(self.input_file)
thanks for the reply
actually there is no Binary field in my scenerio but a qweb report which i am printing from the action button on a form . i was hoping i could the content of the pdf on that part
Podoba Ci się ta dyskusja? Dołącz do niej!
Stwórz konto dzisiaj, aby cieszyć się ekskluzywnymi funkcjami i wchodzić w interakcje z naszą wspaniałą społecznością!
Zarejestruj sięPowiązane posty | Odpowiedzi | Widoki | Czynność | |
---|---|---|---|---|
|
4
sty 25
|
44552 | ||
|
0
paź 24
|
1450 | ||
|
0
paź 24
|
5 | ||
|
1
maj 23
|
2988 | ||
|
0
sty 23
|
2469 |