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

Unable to render Print Design #357

Open
nathanso opened this issue Sep 19, 2024 · 3 comments
Open

Unable to render Print Design #357

nathanso opened this issue Sep 19, 2024 · 3 comments

Comments

@nathanso
Copy link

After creating a Purchase Form, I wanted to check the look. But upon rendering, it provided me with this error message.
Screenshot 2024-09-19 at 12 56 49 PM

@maharshivpatel
Copy link
Collaborator

open the error log and share it here. Thank you.

@nathanso
Copy link
Author

Hi Sorry, I actually have another issue where I can't render the PDF:

Traceback with variables (most recent call last):
File "apps/frappe/frappe/app.py", line 114, in application
response = frappe.api.handle(request)
request = <Request 'https://makerich.frappe.cloud/api/method/frappe.utils.print_format.download_pdf?doctype=Purchase+Order&name=MRL-PUR-ORD-2024-00005&format=Purchase+Order+2.0&_lang=en' [GET]>
response = None
rollback = True
e = KeyError('src')
File "apps/frappe/frappe/api/init.py", line 49, in handle
data = endpoint(**arguments)
request = <Request 'https://makerich.frappe.cloud/api/method/frappe.utils.print_format.download_pdf?doctype=Purchase+Order&name=MRL-PUR-ORD-2024-00005&format=Purchase+Order+2.0&_lang=en' [GET]>
endpoint = <function handle_rpc_call at 0x7f8d121f6de0>
arguments = {'method': 'frappe.utils.print_format.download_pdf'}
File "apps/frappe/frappe/api/v1.py", line 36, in handle_rpc_call
return frappe.handler.handle()
method = 'frappe.utils.print_format.download_pdf'
frappe = <module 'frappe' from 'apps/frappe/frappe/init.py'>
File "apps/frappe/frappe/handler.py", line 49, in handle
data = execute_cmd(cmd)
cmd = 'frappe.utils.print_format.download_pdf'
data = None
File "apps/frappe/frappe/handler.py", line 85, in execute_cmd
return frappe.call(method, **frappe.form_dict)
cmd = 'frappe.utils.print_format.download_pdf'
from_async = False
server_script = None
method = <function download_pdf at 0x7f8cfefc31a0>
File "apps/frappe/frappe/init.py", line 1775, in call
return fn(*args, **newargs)
fn = <function download_pdf at 0x7f8cfefc31a0>
args = ()
kwargs = {'doctype': 'Purchase Order', 'name': 'MRL-PUR-ORD-2024-00005', 'format': 'Purchase Order 2.0', '_lang': 'en', 'cmd': 'frappe.utils.print_format.download_pdf'}
newargs = {'doctype': 'Purchase Order', 'name': 'MRL-PUR-ORD-2024-00005', 'format': 'Purchase Order 2.0'}
File "apps/frappe/frappe/utils/typing_validations.py", line 31, in wrapper
return func(args, kwargs)
args = ()
kwargs = {'doctype': 'Purchase Order', 'name': 'MRL-PUR-ORD-2024-00005', 'format': 'Purchase Order 2.0'}
apply_condition = <function whitelist..innerfn.. at 0x7f8cfefc0180>
func = <function download_pdf at 0x7f8cfefc3e20>
File "apps/frappe/frappe/utils/print_format.py", line 234, in download_pdf
pdf_file = frappe.get_print(
doctype = 'Purchase Order'
name = 'MRL-PUR-ORD-2024-00005'
format = 'Purchase Order 2.0'
doc = <PurchaseOrder: MRL-PUR-ORD-2024-00005>
no_letterhead = 0
language = None
letterhead = None
File "apps/frappe/frappe/init.py", line 2191, in get_print
return get_pdf(html, options=pdf_options, output=output) if as_pdf else html
doctype = 'Purchase Order'
name = 'MRL-PUR-ORD-2024-00005'
print_format = 'Purchase Order 2.0'
style = None
as_pdf = True
doc = <PurchaseOrder: MRL-PUR-ORD-2024-00005>
output = None
no_letterhead = 0
password = ********
pdf_options = {}
letterhead = None
get_pdf = <function get_pdf at 0x7f8d0f73e8e0>
get_response_without_exception_handling = <function get_response_without_exception_handling at 0x7f8d10970680>
original_form_dict = {'doctype': 'Purchase Order', 'name': 'MRL-PUR-ORD-2024-00005', 'format': 'Purchase Order 2.0', '_lang': 'en', 'cmd': 'frappe.utils.print_format.download_pdf'}
response = <Response 136971 bytes [200 OK]>
html = '\n\n\n\t\n\t\n\t<title>Yuan Mei </title>\n\t\n\t\n\t\n\t\t<style>\n\t\t@media screen {\n\t.print-format-gutter {\n\t\tbackground-color: #d1d8dd;\n\t\tpadding: 30px 0px;\n\t}\n\t.print-format {\n\t\tbackground-color: white;\n\t\tborder-radius: 8px;\n\t\tmax-width: 8.3in;\n\t\tmin-height: 11.69in;\n\t\tpadding: 0.75in;\n\t\tmargin: auto;\n\t\tcolor: var(--gray-900);\n\t}\n\n\t.print-format.landscape {\n\t\tmax-width: 11.69in;\n\t\tpadding: 0.2in;\n\t}\n\n\t.page-break {\n\t\t/
padding: 15px 0px; /\n\t\tborder-bottom: 1px dashed #888;\n\t}\n\n\t/ .page-break:first-child {\n\t\tpadding-top: 0px;\n\t} /\n\n\t.page-break:last-child {\n\t\tborder-bottom: 0px;\n\t}\n\n\t/ mozilla hack for images in table /\n\tbody:la...
File "apps/frappe/frappe/utils/pdf.py", line 80, in get_pdf
html, options = prepare_options(html, options)
html = '\n\n\n\t\n\t\n\t<title>Yuan Mei </title>\n\t\n\t\n\t\n\t\t<style>\n\t\t@media screen {\n\t.print-format-gutter {\n\t\tbackground-color: #d1d8dd;\n\t\tpadding: 30px 0px;\n\t}\n\t.print-format {\n\t\tbackground-color: white;\n\t\tborder-radius: 8px;\n\t\tmax-width: 8.3in;\n\t\tmin-height: 11.69in;\n\t\tpadding: 0.75in;\n\t\tmargin: auto;\n\t\tcolor: var(--gray-900);\n\t}\n\n\t.print-format.landscape {\n\t\tmax-width: 11.69in;\n\t\tpadding: 0.2in;\n\t}\n\n\t.page-break {\n\t\t/
padding: 15px 0px; /\n\t\tborder-bottom: 1px dashed #888;\n\t}\n\n\t/ .page-break:first-child {\n\t\tpadding-top: 0px;\n\t} /\n\n\t.page-break:last-child {\n\t\tborder-bottom: 0px;\n\t}\n\n\t/ mozilla hack for ...
options = {}
output = None
File "apps/frappe/frappe/utils/pdf.py", line 165, in prepare_options
html = inline_private_images(html)
html = '\n\n\t\n\t\n\t<title>Yuan Mei </title>\n\t\n\t\n\t\n\t\t<style>\n\t\t@media screen {\n\t.print-format-gutter {\n\t\tbackground-color: #d1d8dd;\n\t\tpadding: 30px 0px;\n\t}\n\t.print-format {\n\t\tbackground-color: white;\n\t\tborder-radius: 8px;\n\t\tmax-width: 8.3in;\n\t\tmin-height: 11.69in;\n\t\tpadding: 0.75in;\n\t\tmargin: auto;\n\t\tcolor: var(--gray-900);\n\t}\n\n\t.print-format.landscape {\n\t\tmax-width: 11.69in;\n\t\tpadding: 0.2in;\n\t}\n\n\t.page-break {\n\t\t/
padding: 15px 0px; /\n\t\tborder-bottom: 1px dashed #888;\n\t}\n\n\t/ .page-break:first-child {\n\t\tpadding-top: 0px;\n\t} /\n\n\t.page-break:last-child {\n\t\tborder-bottom: 0px;\n\t}\n\n\t/ mozilla hack fo...
options = {'print-media-type': None, 'background': None, 'images': None, 'quiet': None, 'encoding': 'UTF-8', 'margin-right': '0', 'margin-left': '0', 'header-html': '/tmp/frappe-pdf-65c84477ac580f15366e5c4c1509f9782ea923e5e69334a9b95a04a4.html', 'footer-html': '/tmp/frappe-pdf-8508e345e16bc13cf954d14635aeeee65a4c6c45ba364bd4229f8eae.html', 'page-width': '210mm', 'page-height': '297mm', 'margin-top': '30.6mm', 'margin-bottom': '20mm', 'cookie-jar': '/tmp/832828cf87103d54a1ba11957fc214d1872d85df3b8b7ef3b66d1a00.jar'}
html_options = {'header-html': '/tmp/frappe-pdf-65c84477ac580f15366e5c4c1509f9782ea923e5e69334a9b95a04a4.html', 'footer-html': '/tmp/frappe-pdf-8508e345e16bc13cf954d14635aeeee65a4c6c45ba364bd4229f8eae.html', 'page-width': '210mm', 'page-height': '297mm', 'margin-top': '30.6mm', 'margin-bottom': '20mm', 'margin-left': '0', 'margin-right': '0'}
File "apps/frappe/frappe/utils/pdf.py", line 268, in inline_private_images
if b64 := _get_base64_image(img["src"]):
html = '\n\n\t\n\t\n\t<title>Yuan Mei </title>\n\t\n\t\n\t\n\t\t<style>\n\t\t@media screen {\n\t.print-format-gutter {\n\t\tbackground-color: #d1d8dd;\n\t\tpadding: 30px 0px;\n\t}\n\t.print-format {\n\t\tbackground-color: white;\n\t\tborder-radius: 8px;\n\t\tmax-width: 8.3in;\n\t\tmin-height: 11.69in;\n\t\tpadding: 0.75in;\n\t\tmargin: auto;\n\t\tcolor: var(--gray-900);\n\t}\n\n\t.print-format.landscape {\n\t\tmax-width: 11.69in;\n\t\tpadding: 0.2in;\n\t}\n\n\t.page-break {\n\t\t/
padding: 15px 0px; /\n\t\tborder-bottom: 1px dashed #888;\n\t}\n\n\t/ .page-break:first-child {\n\t\tpadding-top: 0px;\n\t} /\n\n\t.page-break:last-child {\n\t\tborder-bottom: 0px;\n\t}\n\n\t/ mozilla hack fo...
soup =

  <html dir="ltr" lang="en"><head>
  <meta charset="utf-8"/>
  <meta content="width=device-width, initial-scale=1.0" name="viewport"/>
  <title>Yuan Mei </title>
  <meta content="frappe" name="generator"/>
  <link href="https://makerich.frappe.cloud/assets/frappe/dist/css/print.bundle.TD7AP7ZN.css" rel="stylesheet" type="text/css"/>
  <style>
  		@media screen {
  	.print-format-gutter {
  		background-color: #d1d8dd;
  		padding: 30px 0px;
  	}
  	.print-format {
  		background-color: white;
  		border-radius: 8px;
  		max-width: 8.3in;
  		min-height: 11.69in;
  		padding: 0.75in;
  		margin: auto;
  		color: var(--gray-900);
  	}
  
  	.print-format.landscape {
  		max-width: 11.69in;
  		padding: 0.2in;
  	}
  
  	.page-break {
  		/* padding: 15px 0px; */
  		border-bottom: 1px dashed #888;
  	}
  
  	/* .page-break:first-child {
  		padding-top: 0px;
  	} */
  
  	.page-break:last-child {
  		border-bottom: 0px;
  	}
  
  	/* mozilla hack for images in table */
  	body:last-child .print-format td img {
  		width: 100% !important;
  	}
  
  	@media(max-w...
  img = <img/>

File "env/lib/python3.11/site-packages/bs4/element.py", line 1573, in getitem
return self.attrs[key]
self =
key = ********
builtins.KeyError: 'src'

@KushX
Copy link

KushX commented Oct 4, 2024

I'm not above to provide logs unforunately.
To replicate this error, all I have to do is set page margins in the designers. Reverting margins back to 0 does not fix the issue.

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

3 participants