Giter VIP home page Giter VIP logo

reportbro-lib's Introduction

ReportBro Lib

ReportBro is a library to generate PDF and XLSX reports. Report templates can be created with ReportBro Designer, a Javascript Plugin which can be integrated in your web application.

See the ReportBro project website on https://www.reportbro.com for full documentation and demos.

Features

  • Python >= 3.8 support
  • Generate pdf and xlsx reports
  • Supports (repeating) header and footer
  • Allows predefined and own page formats
  • Use text, line, images, barcodes and tables, page breaks
  • Text and element styling
  • Evaluate expressions, define conditional styles, format parameters

Installation

pip install reportbro-lib

Go to https://www.reportbro.com/framework/api#lib-arguments for more information on configuration and usage.

Python Coding Style

The PEP 8 (Python Enhancement Proposal) standard is used which is the de-facto code style guide for Python. An easy-to-read version of PEP 8 can be found at https://pep8.org

For pull requests the same coding styles should be used.

ReportBro Cloud

With ReportBro Cloud you can manage all your reports in your account and use only a simple web request in your application to get the report file. Try ReportBro as cloud service.

License

  • Commercial license

If you want to use ReportBro to develop commercial applications and projects, the Commercial license is the appropriate license. With this license, your source code is kept proprietary. Purchase a ReportBro Commercial license at https://www.reportbro.com/framework/license

This license includes ReportBro PLUS with additional features.

  • Open-source license

If you are creating an open-source application under a license compatible with the GNU AGPL license v3, you may use ReportBro under the terms of the AGPLv3.

Read more about ReportBro's license options at https://www.reportbro.com/framework/license.

reportbro-lib's People

Contributors

alhman avatar bmiklautz avatar mariarauch avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

reportbro-lib's Issues

Tornado

Issue when attempting to generate a report
ServerRequest(protocol='http', host='XXX.XXX.XXX.XXX:8000', method='PUT', uri='/reportbro/report/run', version='HTTP/1.1', remote_ip='XXX.XXX.XXX.XXX') Traceback (most recent call last): File "/usr/local/lib/python3.6/dist-packages/tornado/web.py", line 1592, in _execute result = yield result File "/usr/local/lib/python3.6/dist-packages/tornado/gen.py", line 1133, in run value = future.result() File "/usr/local/lib/python3.6/dist-packages/tornado/gen.py", line 1221, in handle_yield self.future = convert_yielded(yielded) File "/usr/lib/python3.6/functools.py", line 807, in wrapper return dispatch(args[0].__class__)(*args, **kw) File "/usr/local/lib/python3.6/dist-packages/tornado/gen.py", line 1363, in convert_yielded raise BadYieldError("yielded unknown object %r" % (yielded,)) tornado.gen.BadYieldError: yielded unknown object '{"errors": []}' ERROR:tornado.access:500 PUT /reportbro/report/run (101.182.96.139) 432.37ms

missing data on export to xls

I'm going to reference an issue here, because they complement each other.
issue: #29

as I had to generate the report, I took the totals and in fact managed to generate the pdf
Captura de Tela_selecionar área_20230314100055

however when generating an xls, there is no data, only comes what is shown in the image below.
Captura de Tela_selecionar área_20230314100448

should have the same behavior as the pdf

Generate pdf failed error 500

I am using reportbro-lib through Docker (Image : python:3.8.1-buster)
I'm sending 50 data with use of section which create 50 pages pdf working fine
But I'm getting following error for 20000 data
I have also tried with Python 3.6 and Python 3.7
And also checked no data are blank or null

ERROR:tornado.application:Uncaught exception PUT /rbro/report/save (172.19.0.6)
HTTPServerRequest(protocol='http', host='generate_pdf', method='PUT', uri='/rbro/report/save', version='HTTP/1.1', remote_ip='172.19.0.6')
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/tornado/web.py", line 1699, in _execute
    result = await result
TypeError: object str can't be used in 'await' expression
ERROR:tornado.access:500 PUT /rbro/report/save (172.19.0.6) 612.54ms

Conditional Formatting

Hey there Thanks for the awesome library!

I just have a question that how can we apply multiple level of conditional formatting to table rows i.e. if value is
Screenshot_1
more than 10 color will be green, if value is less than 10 color will be red

SSRF on Image URL Import

Hi,

I think there is a SSRF Vulnerability on Image URL Import functionality.

try:
                req = request.Request(image_url, headers=headers)
                self.image_data = BytesIO(request.urlopen(req).read())
            except Exception as ex:
                raise ReportBroError(
                    Error('errorMsgLoadingImageFailed', object_id=image_id, field='source', info=str(ex)))

If attacker gives internal URL it will return the response. I think the server needs to check if file is image or it can be very dangerous

table with more than one expression does not work accordingly

I have a simple table and I need to group it with groups expression, but it doesn't work or I'm doing it wrong.

See the images of how I'm defining the template.

Captura de Tela_selecionar área_20230314084554
Captura de Tela_selecionar área_20230314084610
Captura de Tela_selecionar área_20230314084633
Captura de Tela_selecionar área_20230314084651

in the content I need to group by code(item_codigo_interno), because I can't repeat the item with the same code, so I use expression.

however, doing this way, the total that should be at the end of each expression group is lost.
Captura de Tela_selecionar área_20230314085257

in short, the total should be below item 59
and item 59 above total and below item 58

test data used

[
  {
    "tipo" : "produto"
    "ven_id" : "dbdcba72-cdf8-4e76-a668-0e8a503d774c"
    "codigo_interno" : "81"
    "data_emissao" : "2023-03-13 11:49"
    "data_validade" : "2023-03-13 11:49"
    "data_negociacao" : "2023-03-13 11:49"
    "data_prazo_entrega" : "2023-03-13 16:14"
    "numero_pedido_compra" : null
    "tipo_negociacao" : "Pedido de venda"
    "status_negociacao" : "Faturado"
    "item_id" : "0aa7f321-a30d-4254-9371-4393c79ed4f4"
    "item_codigo_interno" : "58"
    "item_descricao" : "PISO LAMINADO AC3 FXM2093"
    "item_quantidade" : 10.0
    "item_vlr_unitario" : 23.0
    "item_vlr_total" : 230.0
    "destinatario_nome" : "Glauber"
    "destinatario_cpf_cnpj" : "07000000002"
    "destinatario_endereco" : "Rua Alberto Biavatti, 100 - Parque de Exposições - 89711-196 - Concórdia/SC - Brasil"
    "vendedor_nome" : "Glauber"
    "vendedor_email" : "[email protected]"
    "numero_documento_fiscal" : 69
    "id_estabelecimento" : "00000000-61bc-8ed0-a6ec-2155a040475d"
  },
  {
    "tipo" : "produto"
    "ven_id" : "03e37632-6bb9-4a42-bd20-766a2a6244ff"
    "codigo_interno" : "82"
    "data_emissao" : "2023-03-13 11:51"
    "data_validade" : "2023-03-13 11:51"
    "data_negociacao" : "2023-03-13 11:50"
    "data_prazo_entrega" : "2023-03-13 16:14"
    "numero_pedido_compra" : null
    "tipo_negociacao" : "Pedido de venda"
    "status_negociacao" : "Faturado"
    "item_id" : "0aa7f321-a30d-4254-9371-4393c79ed4f4"
    "item_codigo_interno" : "58"
    "item_descricao" : "PISO LAMINADO AC3 FXM2093"
    "item_quantidade" : 10.0
    "item_vlr_unitario" : 23.0
    "item_vlr_total" : 230.0
    "destinatario_nome" : "Glauber"
    "destinatario_cpf_cnpj" : "07000000002"
    "destinatario_endereco" : "Rua Alberto Biavatti, 100 - Parque de Exposições - 89711-196 - Concórdia/SC - Brasil"
    "vendedor_nome" : "Glauber"
    "vendedor_email" : "[email protected]"
    "numero_documento_fiscal" : 70
    "id_estabelecimento" : "00000000-61bc-8ed0-a6ec-2155a040475d"
  },
  {
    "tipo" : "produto"
    "ven_id" : "ab7738d5-8f56-4304-af68-2fb491ff24f3"
    "codigo_interno" : "83"
    "data_emissao" : "2023-03-13 11:53"
    "data_validade" : "2023-03-13 11:53"
    "data_negociacao" : "2023-03-13 11:53"
    "data_prazo_entrega" : "2023-03-13 16:14"
    "numero_pedido_compra" : null
    "tipo_negociacao" : "Pedido de venda"
    "status_negociacao" : "Faturado"
    "item_id" : "d5c4c05a-62f2-4752-bfc7-7e3f42833c62"
    "item_codigo_interno" : "59"
    "item_descricao" : "PISO LAMINADO AC3 FXM2250"
    "item_quantidade" : 10.0
    "item_vlr_unitario" : 15.0
    "item_vlr_total" : 150.0
    "destinatario_nome" : "Glauber"
    "destinatario_cpf_cnpj" : "07000000002"
    "destinatario_endereco" : "Rua Alberto Biavatti, 100 - Parque de Exposições - 89711-196 - Concórdia/SC - Brasil"
    "vendedor_nome" : "Glauber"
    "vendedor_email" : "[email protected]"
    "numero_documento_fiscal" : 71
    "id_estabelecimento" : "00000000-61bc-8ed0-a6ec-2155a040475d"
  },
  {
    "tipo" : "produto"
    "ven_id" : "f7f833c2-9402-484f-8008-6eef98b07a8a"
    "codigo_interno" : "84"
    "data_emissao" : "2023-03-13 11:55"
    "data_validade" : "2023-03-13 11:55"
    "data_negociacao" : "2023-03-13 11:54"
    "data_prazo_entrega" : "2023-03-13 16:14"
    "numero_pedido_compra" : null
    "tipo_negociacao" : "Pedido de venda"
    "status_negociacao" : "Faturado"
    "item_id" : "d5c4c05a-62f2-4752-bfc7-7e3f42833c62"
    "item_codigo_interno" : "59"
    "item_descricao" : "PISO LAMINADO AC3 FXM2250"
    "item_quantidade" : 10.0
    "item_vlr_unitario" : 15.0
    "item_vlr_total" : 150.0
    "destinatario_nome" : "JESSICA"
    "destinatario_cpf_cnpj" : "07000000002"
    "destinatario_endereco" : "RUA PRIMO FACHINELLO, 78 - BELA VISTA - CASA - 89683-000 - Ponte Serrada/SC - Brasil"
    "vendedor_nome" : "Glauber"
    "vendedor_email" : "[email protected]"
    "numero_documento_fiscal" : 72
    "id_estabelecimento" : "00000000-61bc-8ed0-a6ec-2155a040475d"
  },
  {
    "tipo" : "produto"
    "ven_id" : "54aaa2d8-e5b6-4cae-a8e1-cb0e01775879"
    "codigo_interno" : "85"
    "data_emissao" : "2023-03-13 11:56"
    "data_validade" : "2023-03-13 11:56"
    "data_negociacao" : "2023-03-13 11:56"
    "data_prazo_entrega" : "2023-03-13 16:14"
    "numero_pedido_compra" : null
    "tipo_negociacao" : "Pedido de venda"
    "status_negociacao" : "Faturado"
    "item_id" : "0aa7f321-a30d-4254-9371-4393c79ed4f4"
    "item_codigo_interno" : "58"
    "item_descricao" : "PISO LAMINADO AC3 FXM2093"
    "item_quantidade" : 10.0
    "item_vlr_unitario" : 23.0
    "item_vlr_total" : 230.0
    "destinatario_nome" : "JESSICA"
    "destinatario_cpf_cnpj" : "07000000002"
    "destinatario_endereco" : "RUA PRIMO FACHINELLO, 78 - BELA VISTA - CASA - 89683-000 - Ponte Serrada/SC - Brasil"
    "vendedor_nome" : "Glauber"
    "vendedor_email" : "[email protected]"
    "numero_documento_fiscal" : 73
    "id_estabelecimento" : "00000000-61bc-8ed0-a6ec-2155a040475d"
  }
]

add italic,bold, italicBold fonts - got error

If i try add multiple font files

additional_fonts = [
        dict(
            value='OpenSans', 
            filename=assetFontPath + 'OpenSans-Regular.ttf',
            bold_italic_filename=assetFontPath + 'OpenSans-BoldItalic.ttf',
            bold_filename=assetFontPath + 'OpenSans-Bold.ttf',
            italic_filename=assetFontPath + 'OpenSans-Italic.ttf'
        )
    ]

I got an error "undefined font opensans"
I debug into lib code and find that in set_font added only first opensansB font and font['added'] set to True, but opensans font and other not added.

Then I get this error

if I change lib code like this:

                if not font['added'].get(family + '_' + style):
                    filename = font['style2filename'].get(style)
                    self.add_font(family, style=style, fname=filename, uni=font['uni'])
                    font['added'][family + '_' + style] = True

all works

After updating to latest version it broke

ReportBroError at /hrm/salary_slip/
ReportBroError: msg_key=errorMsgLoadingImageFailed, object_id=None, field=image, info='_io.BytesIO' object has no attribute 'rfind', context=None

Tipp excel dynamic formulas

There is some study to be able to use similar expressions as in excel.
Example =SUM(COL4) , where here would be the sum of all column data(COL4) up to this point that has the expression.

another examples:

sum horizontally as.
=SUM(COL1:COL4)

=DIV(...) division
=SUB(...) subtraction
=MULT(...) multiplication

It would generate even more dynamism to the library.

Image Unknown Error

When I try to show image(url) from parameter in its ok in your demo's preview. But on my own server I am having this error. (except this issue my server is all ok). How can I fix this? Is this because of I use 2.7 version of python?

2020-03-03 15:03:31,697: 500 PUT / (10.0.0.249) 77.99ms 2020-03-03 15:03:59,725: Uncaught exception PUT / (10.0.0.249) HTTPServerRequest(protocol='https', host='saglamhkn.pythonanywhere.com', method='PUT', uri='/', version='HTTP/1.1', remote_ip='10.0.0.249') Traceback (most recent call last): File "/home/saglamhkn/.virtualenvs/my-virtualenv/local/lib/python2.7/site-packages/tornado/web.py", line 1592, in _execute result = yield result File "/home/saglamhkn/.virtualenvs/my-virtualenv/local/lib/python2.7/site-packages/tornado/gen.py", line 1133, in run value = future.result() File "/home/saglamhkn/.virtualenvs/my-virtualenv/local/lib/python2.7/site-packages/tornado/concurrent.py", line 261, in result raise_exc_info(self._exc_info) File "/home/saglamhkn/.virtualenvs/my-virtualenv/local/lib/python2.7/site-packages/tornado/gen.py", line 1221, in handle_yield self.future = convert_yielded(yielded) File "/home/saglamhkn/.virtualenvs/my-virtualenv/local/lib/python2.7/site-packages/singledispatch.py", line 210, in wrapper return dispatch(args[0].__class__)(*args, **kw) File "/home/saglamhkn/.virtualenvs/my-virtualenv/local/lib/python2.7/site-packages/tornado/gen.py", line 1363, in convert_yielded raise BadYieldError("yielded unknown object %r" % (yielded,)) BadYieldError: yielded unknown object '{"errors": []}' 2020-03-03 15:03:59,727: 500 PUT / (10.0.0.249) 23.09ms

computed parameters in lists

Can computed parameters placed in lists?
I got error with it at this code.
I set List / text parameter and set textElementEval checkbox.
My expression is valid:

(str(${width}) + str('м.')) if (${width} > 0) else str('')

Table component with mutli groups expression

Hello,

I have a rather strange behaviour when I print this type of report.

The report is simply composed of a Table which is linked to the structured data in the following way:
Family, Type, Group, Quantity

I have calculated myself (in this data) the sums of 4 groups I want to display.

In this report, I want to have a break :

  • for sum_ftg_group => sum
  • for sum_ft_group => sum
  • for sum_f_group => sum + page break
  • for sum_group => sum total

Everything works fine except the page break on sum_f_group (3rd). On the next page, the first break is not on sum_ftg_group.

In the attached PDF file, you will notice on page 2 that the break (sum_ftg_group) 1A0 does not occur. Same thing on the 3rd page with 2A0

Have I done something wrong?

image

deabadd5-f567-4628-b1dd-91fc9ddb9059.pdf
reportbro_example.txt

ReportBro version is 3.0 / 3.0.5

Tornado error 500 using conditional style

Hi, when i'm using the community server my reports works well, but when i point the report to my own report server using the example reportbro_server.py i get this error.

reportbro_server   | ERROR:tornado.application:Uncaught exception PUT /reportbro/report/run (172.19.0.1)
reportbro_server   | HTTPServerRequest(protocol='http', host='local.geducar.com:8080', method='PUT', uri='/reportbro/report/run', version='HTTP/1.1', remote_ip='172.19.0.1')
reportbro_server   | Traceback (most recent call last):
reportbro_server   |   File "/usr/local/lib/python3.8/site-packages/tornado/web.py", line 1699, in _execute
reportbro_server   |     result = await result
reportbro_server   | TypeError: object str can't be used in 'await' expression
reportbro_server   | ERROR:tornado.access:500 PUT /reportbro/report/run (172.19.0.1) 7.14ms

I get this error only when i use Conditional style, but with no conditional styles this works well.

Possible bug: table printed on multiple pages

I encountered this bug, a table set with 3 rows "content" and "footer", the printed content was larger than the page size, so the table was printed twice.
temporarily solved by decreasing the height of a "content" row so as to print the table on a single sheet

Parameters page_number and page_count do not work outside header or footer

I need to print the number of pages (page_count) on one of the document pages (and not in the header or the footer).

But if i put them there, i just receive "0". And they work just fine if i put them on the document's header or footer.

I think, they should work the same way in the whole document, not just header and footer.

Dependency problem with Babel 2.14.0

Hi,

We've noticed some problems with number formatting. In particular, the "Thansands separator" property is no longer supported with this version of Babel.

it works fine with the previous version of Babel 2.13.1

See video below

babel_issue.mp4

Best regards,

Cannot install at Pythonanywhere

Hi
We start Django web at Pythonanywhere.
However the Pythonanywhere created mytsite as app source app folder.
Select the python 3.8.0
Follow through steps in Readme.rst
and then http://abc.pythonanywhere.com/albums

Error message is here
Using the URLconf defined in mysite.urls, Django tried these URL patterns, in this order:
admin/
The current path, albums, didn't match any of these.

What can we do?

Add reportbro to conda

While one can use pip when using Anaconda and Miniconda, it can result in version conflicts. It would be more direct to use the conda packaging to install reportbro for use with Anaconda.

The easiest way might be to add it to the Conda Forge. I have been unable to find out how packages get added to the standard Anaconda distribution.

I've only created this issue for reportbro-lib, but I expect it would make sense to have reportbro-designer as a conda package also.

I'm assuming there are enough Anaconda and Miniconda users looking for an alternative to reportlab to make this a worthwhile exercise...

Images in the section band broken

When trying to implement using images on the section band , the same image is repeated over and over again , instead of the image url provided in the list

Steps to test

  1. create a section on the report
  2. add image widget
  3. To the data to source in the parameter add list
  4. in the list add textfield
  5. assign the text field to image widget as source
  6. assign the test data to the data source parameter
  7. preview

adding the report requested with test data for testing on your end
{"report":{"docElements":[{"elementType":"section","id":36,"containerId":"0_content","y":80,"label":"","dataSource":"${albums}","header":false,"footer":false,"printIf":"","headerData":{"elementType":"none","id":37,"containerId":"0_content","linkedContainerId":38,"height":100,"alwaysPrintOnSamePage":true,"shrinkToContentHeight":false,"repeatHeader":false},"contentData":{"elementType":"none","id":39,"containerId":"0_content","linkedContainerId":40,"height":400,"alwaysPrintOnSamePage":true,"shrinkToContentHeight":false},"footerData":{"elementType":"none","id":41,"containerId":"0_content","linkedContainerId":42,"height":100,"alwaysPrintOnSamePage":true,"shrinkToContentHeight":false}},{"elementType":"image","id":43,"containerId":40,"x":70,"y":40,"width":445,"height":290,"source":"${name}","image":"","imageFilename":"","horizontalAlignment":"left","verticalAlignment":"top","backgroundColor":"","printIf":"","removeEmptyElement":false,"link":"","spreadsheet_hide":false,"spreadsheet_column":"","spreadsheet_addEmptyRow":false},{"elementType":"text","id":47,"containerId":40,"x":90,"y":10,"width":100,"height":20,"content":"${name}","eval":false,"styleId":"","bold":false,"italic":false,"underline":false,"strikethrough":false,"horizontalAlignment":"left","verticalAlignment":"top","textColor":"#000000","backgroundColor":"","font":"helvetica","fontSize":12,"lineSpacing":1,"borderColor":"#000000","borderWidth":1,"borderAll":false,"borderLeft":false,"borderTop":false,"borderRight":false,"borderBottom":false,"paddingLeft":2,"paddingTop":2,"paddingRight":2,"paddingBottom":2,"printIf":"","removeEmptyElement":false,"alwaysPrintOnSamePage":true,"pattern":"","link":"","cs_condition":"","cs_styleId":"","cs_bold":false,"cs_italic":false,"cs_underline":false,"cs_strikethrough":false,"cs_horizontalAlignment":"left","cs_verticalAlignment":"top","cs_textColor":"#000000","cs_backgroundColor":"","cs_font":"helvetica","cs_fontSize":12,"cs_lineSpacing":1,"cs_borderColor":"#000000","cs_borderWidth":"1","cs_borderAll":false,"cs_borderLeft":false,"cs_borderTop":false,"cs_borderRight":false,"cs_borderBottom":false,"cs_paddingLeft":2,"cs_paddingTop":2,"cs_paddingRight":2,"cs_paddingBottom":2,"spreadsheet_hide":false,"spreadsheet_column":"","spreadsheet_colspan":"","spreadsheet_addEmptyRow":false},{"elementType":"image","id":46,"containerId":"0_content","x":130,"y":0,"width":80,"height":80,"source":"https://i1076.photobucket.com/albums/w455/shyamjoshi/Screen%20Shot%202019-08-19%20at%203.43.14%20PM_zps1l4qpice.png","image":"","imageFilename":"","horizontalAlignment":"left","verticalAlignment":"top","backgroundColor":"","printIf":"","removeEmptyElement":false,"link":"","spreadsheet_hide":false,"spreadsheet_column":"","spreadsheet_addEmptyRow":false}],"parameters":[{"id":1,"name":"page_count","type":"number","arrayItemType":"string","eval":false,"nullable":false,"pattern":"","expression":"","showOnlyNameType":true,"testData":""},{"id":2,"name":"page_number","type":"number","arrayItemType":"string","eval":false,"nullable":false,"pattern":"","expression":"","showOnlyNameType":true,"testData":""},{"id":9,"name":"current_date","type":"date","arrayItemType":"string","eval":false,"nullable":false,"pattern":"d. MMMM yyyy, H:mm","expression":"","showOnlyNameType":false,"testData":""},{"id":10,"name":"year","type":"number","arrayItemType":"string","eval":false,"nullable":true,"pattern":"0","expression":"","showOnlyNameType":false,"testData":""},{"id":12,"name":"albums","type":"array","arrayItemType":"string","eval":false,"nullable":false,"pattern":"","expression":"","showOnlyNameType":false,"testData":"[{"name":"https://i1076.photobucket.com/albums/w455/shyamjoshi/Screen%20Shot%202019-08-19%20at%203.43.14%20PM_zps1l4qpice.png"},{"name":"https://i1076.photobucket.com/albums/w455/shyamjoshi/Screen%20Shot%202019-08-19%20at%203.43.14%20PM_zps1l4qpice.png"},{"name":"https://i1076.photobucket.com/albums/w455/shyamjoshi/Screen%20Shot%202019-08-19%20at%203.43.14%20PM_zps1l4qpice.png"}]","children":[{"id":13,"name":"name","type":"string","arrayItemType":"string","eval":false,"nullable":false,"pattern":"","expression":"","showOnlyNameType":false,"testData":""}]}],"styles":[{"id":33,"name":"Table Header","bold":true,"italic":false,"underline":false,"strikethrough":false,"horizontalAlignment":"center","verticalAlignment":"middle","textColor":"#000000","backgroundColor":"","font":"helvetica","fontSize":"10","lineSpacing":1,"borderColor":"#000000","borderWidth":"1","borderAll":false,"borderLeft":false,"borderTop":false,"borderRight":false,"borderBottom":false,"paddingLeft":"2","paddingTop":"2","paddingRight":"2","paddingBottom":"2"},{"id":34,"name":"Table Content","bold":false,"italic":false,"underline":false,"strikethrough":false,"horizontalAlignment":"left","verticalAlignment":"middle","textColor":"#000000","backgroundColor":"","font":"helvetica","fontSize":"9","lineSpacing":1,"borderColor":"#000000","borderWidth":"1","borderAll":false,"borderLeft":false,"borderTop":false,"borderRight":false,"borderBottom":false,"paddingLeft":"2","paddingTop":"2","paddingRight":"2","paddingBottom":"2"},{"id":35,"name":"Table Content Highlight","bold":true,"italic":false,"underline":false,"strikethrough":false,"horizontalAlignment":"center","verticalAlignment":"middle","textColor":"#3d85c6","backgroundColor":"","font":"helvetica","fontSize":"9","lineSpacing":1,"borderColor":"#000000","borderWidth":"1","borderAll":false,"borderLeft":false,"borderTop":false,"borderRight":false,"borderBottom":false,"paddingLeft":"2","paddingTop":"2","paddingRight":"2","paddingBottom":"2"}],"version":2,"documentProperties":{"pageFormat":"A4","pageWidth":"","pageHeight":"","unit":"mm","orientation":"portrait","contentHeight":"","marginLeft":"10","marginTop":"10","marginRight":"10","marginBottom":"10","header":true,"headerSize":"80","headerDisplay":"always","footer":true,"footerSize":"30","footerDisplay":"always","patternLocale":"en","patternCurrencySymbol":"$"}},"outputFormat":"pdf","data":{"current_date":"","year":"","albums":[{"name":"https://i1076.photobucket.com/albums/w455/shyamjoshi/Screen%20Shot%202019-08-19%20at%203.43.14%20PM_zps1l4qpice.png"},{"name":"https://i1076.photobucket.com/albums/w455/shyamjoshi/Screen%20Shot%202019-08-19%20at%203.43.14%20PM_zps1l4qpice.png"},{"name":"https://i1076.photobucket.com/albums/w455/shyamjoshi/Screen%20Shot%202019-08-19%20at%203.43.14%20PM_zps1l4qpice.png"}]},"isTestData":true}

Cannot make "Create PDF with Python script" work

Hi,

I hope someone could help me.
I'm trying to test the ReportBro tutorial "Create PDF with Python script" (https://www.reportbro.com/guide/view/9/script-pdf).
I always get this error when I run the script :

Traceback (most recent call last):
File "rbro_test.py", line 43, in
report_file = report.generate_pdf()
File "C:\Users\user2\Documents\py_jupyterlab\reportbro_test\venv\lib\site-packages\reportbro\reportbro.py", line 632, in generate_pdf
renderer = DocumentPDFRenderer(
File "C:\Users\user2\Documents\py_jupyterlab\reportbro_test\venv\lib\site-packages\reportbro\reportbro.py", line 52, in init
self.pdf_doc = FPDFRB(
File "C:\Users\user2\Documents\py_jupyterlab\reportbro_test\venv\lib\site-packages\reportbro\reportbro.py", line 403, in init
self.set_doc_option('core_fonts_encoding', core_fonts_encoding)
AttributeError: 'FPDFRB' object has no attribute 'set_doc_option'

I downloaded the python script and the report template from ReportBro page. I read the Docs page but I do not understand how to solve the error.

Thank you

May you use fpdf2 because its faster

Hi, I am using reportbro for a long time, I came across a library fpdf2 it's way faster because generating around 5k pages takes 100 seconds on report bro on my i5 machine windows 10 py 3.9.

divide of 2 numbers in list not working

We have a list in the parameters with variables and some of them are numbers.

Now we created (at the end) of this list a new variabel where we use the evaluate option to divide 2 of these numbers. This creates a error creating the pdf. to test we change the divide sign with multiple and it works normally.

does not work:
${ProductPrice_TAXexcl} / ${Price_VATexcl}

do work:
${ProductPrice_TAXexcl} * ${Price_VATexcl}

Instead of creating this in the parameters we also tried to do this in the section part but same issue there.

PS: We are using reportbro-lib-plus-2.1.1 because upgrade to version 3.x.x gives issues with the templates that were made in 2.x.x version.

Image in collection parameter rendering with base64 image data

Exception thrown rendering an image document element with its source set to an image parameter inside a collection parameter. eg. ${Collection.Img}. The data provided includes a b64 encoded string eg. {"Collection": {"Img": "data:image/png;base64,...."}}.

Reportbro-lib version 1.5.1

report_definition = {
  "docElements":[{"elementType":"image","id":3,"containerId":"0_content","x":40,"y":130,"width":80,"height":80,"source":"${Collection.Img}","image":"","imageFilename":"","horizontalAlignment":"left","verticalAlignment":"top","backgroundColor":"","printIf":"","removeEmptyElement":false,"link":"","spreadsheet_hide":false,"spreadsheet_column":"","spreadsheet_addEmptyRow":false}],
  "parameters":[{"id":1,"name":"Collection","type":"map","arrayItemType":"string","eval":false,"nullable":false,"pattern":"","expression":"","showOnlyNameType":true,"testData":"","children":[{"id":2,"name":"Img","type":"image","arrayItemType":"string","eval":false,"nullable":false,"pattern":"","expression":"","showOnlyNameType":false}]}],
  "styles":[],
  "version":3,
  "documentProperties":{"pageFormat":"A4","pageWidth":"","pageHeight":"","unit":"mm","orientation":"portrait","contentHeight":"","marginLeft":"","marginTop":"","marginRight":"","marginBottom":"","header":true,"headerSize":"80","headerDisplay":"always","footer":true,"footerSize":"80","footerDisplay":"always","patternLocale":"en","patternCurrencySymbol":"$"}
 }

data = {"Collection": {"Img": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=="}}

Traceback (most recent call last):
  File "report_build.py", line 52, in <module>
    app = run_app()
  File "report_build.py", line 36, in run_app
    reportBytes = report.generate_pdf()
  File "/reportbro/reportbro.py", line 614, in generate_pdf
    return renderer.render()
  File "/reportbro/reportbro.py", line 79, in render
    self.content_band.prepare(self.context, self.pdf_doc)
  File "/reportbro/containers.py", line 36, in prepare
    elem.prepare(ctx, pdf_doc=pdf_doc, only_verify=only_verify)
  File "/reportbro/elements.py", line 65, in prepare
    str(Context.get_parameter_context_id(param_ref))
  File "/reportbro/context.py", line 101, in get_parameter_context_id
    return param_ref.data['__context_id']
KeyError: '__context_id'

It appears that the call to get_parameter_context_id is failing as no __context_id has been assigned to children of ParameterType.map in evaluate_parameters.

Always print on same page doesn't work

Hello, I deactivated the option because it generates an error but it still does not work.

{'msg_key': 'errorMsgSectionBandNotOnSamePage', 'object_id': 43, 'field': 'alwaysPrintOnSamePage', 'info': None, 'context': None}

Can't add an image dynamically

Hello

I try to insert an image in a report.
Steps :
in designer :

  1. add parameter, select image and name logo
  2. add an image widget on the report
  3. set ${logo} in data source of the widget.

I'm using django and i don't know the way to pass the logo image in this line :

params = dict(logo=my_logo)

I tried :

  • base64 image:
with open(file_db.file.path, "rb") as img_file:
        my_logo = base64.b64encode(img_file.read())

i keep this error:
report error: {'msg_key': 'errorMsgInvalidImage', 'object_id': 11, 'field': 'source', 'info': None, 'context': None}

Support for Multiple Calendars (e.g., Gregorian and Nepali)

Currently, ReportBro does not support multiple calendars, such as the Gregorian and Nepali calendars. I would like to inquire if this feature is already supported but perhaps I have overlooked it. If it is not supported, I would like to understand what changes would need to be made in order to incorporate multiple calendars into the library.

Ideally - I should be able to provide parameter on the backend like that will tell reportbro how to display the date - gregorian only, secondary calendar (using provided function with formatting) or both (so for example "07.02.2024 (24.10.2080)").

If this is not yet possible could you guide me and tell what would have to be reworked in the library if I were to create a proper PR?

Thank you for your assistance.

IndexError: pop from empty list

I'm getting this error, detail that in version 2.1.1 I don't get this error and now in version 3.0.4 or 3.0.5 I get the error.

Here is the link to the template with the data that generates the error: https://gist.githubusercontent.com/GlauberF/d6403fea9b5403e2afb44d1a7aea6e00/raw/34d1ec1c0f1e9e04bbbf6deb0b7632f1f6d93619/template.json

in the template, inside report is the definitions
and the data field is the fact data I am sending to the report

my environment
reportbro-lib==3.0.5
SQLAlchemy==1.4.46
tornado==6.2
Python 3.7.10
pip 20.2.2 from /usr/lib/python3.7/site-packages/pip (python 3.7)
OS Linux

Error that is on my tornado server.

reportbro_server.py:99: RemovedIn20Warning: Deprecated API features detected! These feature(s) are not compatible with SQLAlchemy 2.0. To prevent incompatible upgrades prior to updating applications, ensure requirements files are pinned to "sqlalchemy<2.0". Set environment variable SQLALCHEMY_WARN_20=1 to show all deprecation warnings.  Set environment variable SQLALCHEMY_SILENCE_UBER_WARNING=1 to silence this message. (Background on SQLAlchemy 2.0 at: https://sqlalche.me/e/b8d9)
  report_request.c.created_on < (now - datetime.timedelta(minutes=3))))
Uncaught exception PUT /report/run (127.0.0.1)
HTTPServerRequest(protocol='http', host='127.0.0.1:8050', method='PUT', uri='/report/run', version='HTTP/1.1', remote_ip='127.0.0.1')
Traceback (most recent call last):
  File "/var/app/current/report-server-py/env/lib64/python3.7/site-packages/tornado/web.py", line 1711, in _execute
    result = method(*self.path_args, **self.path_kwargs)
  File "reportbro_server.py", line 107, in put
    report_file = report.generate_pdf()
  File "/var/app/current/report-server-py/env/lib64/python3.7/site-packages/reportbro/reportbro.py", line 621, in generate_pdf
    return renderer.render()
  File "/var/app/current/report-server-py/env/lib64/python3.7/site-packages/reportbro/reportbro.py", line 83, in render
    complete = self.content_band.create_render_elements(0, height, self.context, self.pdf_doc)
  File "/var/app/current/report-server-py/env/lib64/python3.7/site-packages/reportbro/containers.py", line 117, in create_render_elements
    container_height=container_height, ctx=ctx, pdf_doc=pdf_doc)
  File "/var/app/current/report-server-py/env/lib64/python3.7/site-packages/reportbro/elements.py", line 953, in get_next_render_element
    content_row.update_group_changed_row_indices()
  File "/var/app/current/report-server-py/env/lib64/python3.7/site-packages/reportbro/elements.py", line 1188, in update_group_changed_row_indices
    self.group_changed_row_indices.pop(0)
IndexError: pop from empty list
500 PUT /report/run (127.0.0.1) 69.96ms

Error Reporting

I note that the reportbro.com demo server reports back with errors, my server of reportbro-lib just gives me a 500 error if there is any mismatch or issue.

Any advice of where we might be able to enable error reporting?

"Page break" is not working in PDF

I have added page break between two sections on my designer page. Then I tried to export PDF by calling generate_pdf method. Which returns a PDF with no page break !

My expection: Showing two sections in different pages
Result Found: Showing sections one after another on same page

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.