Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error 500 when generating pdf report #47

Closed
ky0112 opened this issue May 1, 2022 · 4 comments
Closed

Error 500 when generating pdf report #47

ky0112 opened this issue May 1, 2022 · 4 comments

Comments

@ky0112
Copy link

ky0112 commented May 1, 2022

When generating large PDF report with a lot of base 64 image in it, it will hit error 500 during the generating pdf report process.

Here is the debug log
image

2022-05-02 00_35_47-RuntimeError at _report_download_pdf_7 - Brave

Traceback:
Environment:

Request Method: GET
Request URL: http://127.0.0.1:8000/report/download/pdf/7

Django Version: 3.2.5
Python Version: 3.8.10
Installed Applications:
['django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'martor',
'django_bleach',
'preport']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware']

Traceback (most recent call last):
File "/home/admin123/.local/share/virtualenvs/petereport-_1hU1HQ3/lib/python3.8/site-packages/django/core/handlers/exception.py", line 47, in inner
response = get_response(request)
File "/home/admin123/.local/share/virtualenvs/petereport-_1hU1HQ3/lib/python3.8/site-packages/django/core/handlers/base.py", line 181, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/admin123/.local/share/virtualenvs/petereport-_1hU1HQ3/lib/python3.8/site-packages/django/contrib/auth/decorators.py", line 21, in _wrapped_view
return view_func(request, *args, **kwargs)
File "/opt/petereport/app/preport/views.py", line 941, in reportdownloadpdf
output_pypandoc = pypandoc.convert_text(final_markdown_output, to='pdf', outputfile=pdf_file_output, format='md', extra_args=['-H', PDF_HEADER_FILE, '--from', 'markdown+yaml_metadata_block+raw_html', '--template', PETEREPORT_LATEX_FILE, '--table-of-contents', '--toc-depth', '4', '--number-sections', '--highlight-style', 'breezedark', '--filter', 'pandoc-latex-environment', '--listings'])
File "/home/admin123/.local/share/virtualenvs/petereport-_1hU1HQ3/lib/python3.8/site-packages/pypandoc/init.py", line 100, in convert_text
return _convert_input(source, format, 'string', to, extra_args=extra_args,
File "/home/admin123/.local/share/virtualenvs/petereport-_1hU1HQ3/lib/python3.8/site-packages/pypandoc/init.py", line 321, in _convert_input
raise RuntimeError(

Exception Type: RuntimeError at /report/download/pdf/7
Exception Value: Pandoc died with exitcode "43" during conversion: b'libpng error: IDAT: invalid stored block lengths\nlibpng error: IDAT: invalid stored block lengths\nlibpng error: IDAT: invalid stored block lengths\nError producing PDF.\n!pdfTeX error: pdflatex: libpng: internal error\n ==> Fatal error occurred, no output PDF file produced!\n\n'

Thanks

@1modm
Copy link
Owner

1modm commented May 3, 2022

Hi @ky0112,

I was taking a look into this issue, and unfortunately the issue is generated by libpng and pandoc (the tools used to convert the images and create the reports). My only suggestion is to try some workarounds like use jpg instead of png to see if this error is not generated, or use the media file storage option (instead of storage in DB) to see if works. For that you need to set 'martor_upload_method': 'MEDIA' and in django 'debug': True

https://1modm.github.io/petereport/configuration/#markdown-configuration

Thanks

@1modm 1modm added the wontfix This will not be worked on label May 3, 2022
@1modm 1modm closed this as completed May 4, 2022
@ky0112
Copy link
Author

ky0112 commented May 5, 2022

Hi 1modm,

After setting 'martor_upload_method': 'MEDIA' and 'debug': True in app/config/petereport_config.py it get another error. Following is the traceback
2022-05-05 10_49_10-Window

image

2022-05-05 10_51_10-Window

`Environment:

Request Method: GET
Request URL: http://10.115.8.11:8000/report/download/pdf/2

Django Version: 3.2.5
Python Version: 3.8.10
Installed Applications:
['django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'martor',
'django_bleach',
'preport']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware']

Traceback (most recent call last):
File "/home/admin123/.local/share/virtualenvs/petereport-_1hU1HQ3/lib/python3.8/site-packages/django/core/handlers/exception.py", line 47, in inner
response = get_response(request)
File "/home/admin123/.local/share/virtualenvs/petereport-_1hU1HQ3/lib/python3.8/site-packages/django/core/handlers/base.py", line 181, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/admin123/.local/share/virtualenvs/petereport-_1hU1HQ3/lib/python3.8/site-packages/django/contrib/auth/decorators.py", line 21, in _wrapped_view
return view_func(request, *args, **kwargs)
File "/opt/petereport/app/preport/views.py", line 942, in reportdownloadpdf
output_pypandoc = pypandoc.convert_text(final_markdown_output, to='pdf', outputfile=pdf_file_output, format='md', extra_args=['-H', PDF_HEADER_FILE, '--from', 'markdown+yaml_metadata_block+raw_html', '--template', PETEREPORT_LATEX_FILE, '--table-of-contents', '--toc-depth', '4', '--number-sections', '--highlight-style', 'breezedark', '--filter', 'pandoc-latex-environment', '--listings', '--no-check-certificate'])
File "/home/admin123/.local/share/virtualenvs/petereport-_1hU1HQ3/lib/python3.8/site-packages/pypandoc/init.py", line 100, in convert_text
return _convert_input(source, format, 'string', to, extra_args=extra_args,
File "/home/admin123/.local/share/virtualenvs/petereport-_1hU1HQ3/lib/python3.8/site-packages/pypandoc/init.py", line 321, in _convert_input
raise RuntimeError(

Exception Type: RuntimeError at /report/download/pdf/2
Exception Value: Pandoc died with exitcode "2" during conversion: b'Unknown option --no-check-certificate.\nTry pandoc --help for more information.\n'
`

Thanks

@1modm 1modm removed the wontfix This will not be worked on label May 5, 2022
@1modm
Copy link
Owner

1modm commented May 5, 2022

@ky0112 try to install pandoc > 2.10, for example:

wget https://github.com/jgm/pandoc/releases/download/2.18/pandoc-2.18-1-amd64.deb
dpkg -i pandoc-2.18-1-amd64.deb

@ky0112
Copy link
Author

ky0112 commented May 5, 2022

@1modm it works

Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants