Erpnext v14.2 with hrms

if i set HR employee email Address in Address & Contacts and set Prefered Contact Email Personal Email
in New Payroll if i create salary slip and submit salary slip
i get this error

Salary Slip submission failed. You can resolve the issue and retry submission.
wkhtmltopdf reported an error:
The switch --print-media-type, is not support using unpatched qt, and will be ignored.The switch --header-html, is not support using unpatched qt, and will be ignored.The switch --footer-html, is not support using unpatched qt, and will be ignored.The switch --disable-smart-shrinking, is not support using unpatched qt, and will be ignored.QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-erpnext'
Exit with code 1 due to network error: ConnectionRefusedError
Title
Salary Slip submission failed for Payroll Entry HR-PRUN-2022-00006

Error
Traceback with variables (most recent call last):
  File "apps/hrms/hrms/payroll/doctype/payroll_entry/payroll_entry.py", line 950, in submit_salary_slips_for_employees
    payroll_entry.email_salary_slip(submitted)
      payroll_entry = <PayrollEntry: HR-PRUN-2022-00006 docstatus=1>
      salary_slips = (('Sal Slip/HR-EMP-00001/00006', 'test group'),)
      publish_progress = False
      submitted = [<SalarySlip: Sal Slip/HR-EMP-00001/00006 docstatus=1>]
      unsubmitted = []
      count = 1
      entry = ('Sal Slip/HR-EMP-00001/00006', 'test group')
      salary_slip = <SalarySlip: Sal Slip/HR-EMP-00001/00006 docstatus=1>
      e = OSError("wkhtmltopdf reported an error:\nThe switch --print-media-type, is not support using unpatched qt, and will be ignored.The switch --header-html, is not support using unpatched qt, and will be ignored.The switch --footer-html, is not support using unpatched qt, and will be ignored.The switch --disable-smart-shrinking, is not support using unpatched qt, and will be ignored.QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-erpnext'\nExit with code 1 due to network error: ConnectionRefusedError\n")
  File "apps/hrms/hrms/payroll/doctype/payroll_entry/payroll_entry.py", line 265, in email_salary_slip
    ss.email_salary_slip()
      self = <PayrollEntry: HR-PRUN-2022-00006 docstatus=1>
      submitted_ss = [<SalarySlip: Sal Slip/HR-EMP-00001/00006 docstatus=1>]
      ss = <SalarySlip: Sal Slip/HR-EMP-00001/00006 docstatus=1>
  File "apps/hrms/hrms/payroll/doctype/salary_slip/salary_slip.py", line 1456, in email_salary_slip
    frappe.attach_print(self.doctype, self.name, file_name=self.name, password=password)
      self = <SalarySlip: Sal Slip/HR-EMP-00001/00006 docstatus=1>
      receiver = 'samer@xerotk.com'
      payroll_settings = <PayrollSettings: Payroll Settings>
      message = 'Please see attachment'
      password = None
  File "apps/frappe/frappe/__init__.py", line 2063, in attach_print
    content = get_print(doctype, name, **kwargs)
      doctype = 'Salary Slip'
      name = 'Sal Slip/HR-EMP-00001/00006'
      file_name = 'SalSlip-HR-EMP-00001-00006'
      print_format = None
      style = None
      html = None
      doc = None
      lang = None
      print_letterhead = True
      password = None
      scrub_urls = <function scrub_urls at 0x7f0f00799f30>
      print_settings = {'add_draft_heading': '1', 'allow_page_break_inside_tables': '0', 'allow_print_for_cancelled': '0', 'allow_print_for_draft': '1', 'compact_item_print': '0', 'creation': None, 'docstatus': '0', 'enable_print_server': '0', 'enable_raw_printing': '0', 'font': 'Default', 'font_size': '0', 'idx': '0', 'modified': '2022-08-25 22:08:28.065401', 'modified_by': 'samer@xerotk.com', 'name': 'Print Settings', 'owner': 'Administrator', 'pdf_page_height': '0', 'pdf_page_size': 'A4', 'pdf_page_width': '0', 'print_style': 'Modern', 'print_taxes_with_zero_amount': '1', 'print_uom_after_quantity': '0', 'repeat_header_footer': '1', 'send_print_as_pdf': '1', 'with_letterhead': '1'}
      _lang = 'en'
      no_letterhead = False
      kwargs = {'print_format': None, 'style': None, 'html': None, 'doc': None, 'no_letterhead': False, 'password': None, 'as_pdf': True}
      content = ''
      ext = '.pdf'
  File "apps/frappe/frappe/__init__.py", line 2016, in get_print
    return get_pdf(html, options=pdf_options, output=output)
      doctype = 'Salary Slip'
      name = 'Sal Slip/HR-EMP-00001/00006'
      print_format = None
      style = None
      html = '<!DOCTYPE html>\n<html lang="en" dir="ltr">\n<head>\n\t<meta charset="utf-8">\n\t<meta name="viewport" content="width=device-width, initial-scale=1.0">\n\t<title>XEROTK ERP - test employee</title>\n\t<meta name="generator" content="frappe">\n\t<link type="text/css" rel="stylesheet" href="/assets/frappe/dist/css/print.bundle.N5XLUKRZ.css">\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...
      as_pdf = True
      doc = None
      output = None
      no_letterhead = False
      password = None
      pdf_options = {}
      get_pdf = <function get_pdf at 0x7f0efb13b520>
      get_response_content = <function get_response_content at 0x7f0efd1c6b90>
  File "apps/frappe/frappe/utils/pdf.py", line 38, in get_pdf
    filedata = pdfkit.from_string(html, options=options or {}, verbose=True)
      html = '<!DOCTYPE html>\n<html dir="ltr" lang="en"><head>\n\t<meta charset="utf-8"/>\n\t<meta content="width=device-width, initial-scale=1.0" name="viewport"/>\n\t<title>XEROTK ERP - test employee</title>\n\t<meta content="frappe" name="generator"/>\n\t<link href="http://10.0.0.20:8000/assets/frappe/dist/css/print.bundle.N5XLUKRZ.css" rel="stylesheet" type="text/css"/>\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/* moz...
      options = {'print-media-type': None, 'background': None, 'images': None, 'quiet': None, 'encoding': 'UTF-8', 'margin-right': '15mm', 'margin-left': '15mm', 'header-html': '/tmp/frappe-pdf-18c8217dd98886c7464aeacb32a4e8f3d9999ed6f2bf7c305c88cb53.html', 'footer-html': '/tmp/frappe-pdf-ab1c16d601b25e4500fb9669c8b85d3d49a1221c64851c1eb69b8ef0.html', 'cookie-jar': '/tmp/34a5ac302396d4517692b1afcbce45d4a9ded56446db48df47ecb488.jar', 'page-size': 'A4', 'disable-javascript': '', 'disable-local-file-access': '', 'disable-smart-shrinking': ''}
      output = None
      filedata = ''
  File "env/lib/python3.10/site-packages/pdfkit/api.py", line 75, in from_string
    return r.to_pdf(output_path)
      input = '<!DOCTYPE html>\n<html dir="ltr" lang="en"><head>\n\t<meta charset="utf-8"/>\n\t<meta content="width=device-width, initial-scale=1.0" name="viewport"/>\n\t<title>XEROTK ERP - test employee</title>\n\t<meta content="frappe" name="generator"/>\n\t<link href="http://10.0.0.20:8000/assets/frappe/dist/css/print.bundle.N5XLUKRZ.css" rel="stylesheet" type="text/css"/>\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/* moz...
      output_path = None
      options = {'print-media-type': None, 'background': None, 'images': None, 'quiet': None, 'encoding': 'UTF-8', 'margin-right': '15mm', 'margin-left': '15mm', 'header-html': '/tmp/frappe-pdf-18c8217dd98886c7464aeacb32a4e8f3d9999ed6f2bf7c305c88cb53.html', 'footer-html': '/tmp/frappe-pdf-ab1c16d601b25e4500fb9669c8b85d3d49a1221c64851c1eb69b8ef0.html', 'cookie-jar': '/tmp/34a5ac302396d4517692b1afcbce45d4a9ded56446db48df47ecb488.jar', 'page-size': 'A4', 'disable-javascript': '', 'disable-local-file-access': '', 'disable-smart-shrinking': ''}
      toc = None
      cover = None
      css = None
      configuration = None
      cover_first = False
      verbose = True
      r = <pdfkit.pdfkit.PDFKit object at 0x7f0efbd4f820>
  File "env/lib/python3.10/site-packages/pdfkit/pdfkit.py", line 201, in to_pdf
    self.handle_error(exit_code, stderr)
      self = <pdfkit.pdfkit.PDFKit object at 0x7f0efbd4f820>
      path = None
      args = ['/usr/bin/wkhtmltopdf', '--print-media-type', '--background', '--images', '--quiet', '--encoding', 'UTF-8', '--margin-right', '15mm', '--margin-left', '15mm', '--header-html', '/tmp/frappe-pdf-18c8217dd98886c7464aeacb32a4e8f3d9999ed6f2bf7c305c88cb53.html', '--footer-html', '/tmp/frappe-pdf-ab1c16d601b25e4500fb9669c8b85d3d49a1221c64851c1eb69b8ef0.html', '--cookie-jar', '/tmp/34a5ac302396d4517692b1afcbce45d4a9ded56446db48df47ecb488.jar', '--page-size', 'A4', '--disable-javascript', '--disable-local-file-access', '--disable-smart-shrinking', '-', '-']
      result = <Popen: returncode: 1 args: ['/usr/bin/wkhtmltopdf', '--print-media-type', '...>
      input = b'<!DOCTYPE html>\n<html dir="ltr" lang="en"><head>\n\t<meta charset="utf-8"/>\n\t<meta content="width=device-width, initial-scale=1.0" name="viewport"/>\n\t<title>XEROTK ERP - \xd8\xb3\xd8\xa7\xd9\x85\xd8\xb1 \xd9\x85\xd8\xa7\xd9\x87\xd8\xb1 \xd8\xad\xd9\x84\xd9\x88\xd8\xa7\xd9\x86\xd9\x8a</title>\n\t<meta content="frappe" name="generator"/>\n\t<link href="http://10.0.0.20:8000/assets/frappe/dist/css/print.bundle.N5XLUKRZ.css" rel="stylesheet" type="text/css"/>\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...
      stdout = b'%PDF-1.4\n%\xc3\xa2\xc3\xa3\n1 0 obj\n<<\n/Title ()\n/Creator (\xfe\xff\x00w\x00k\x00h\x00t\x00m\x00l\x00t\x00o\x00p\x00d\x00f\x00 \x000\x00.\x001\x002\x00.\x006)\n/Producer (\xfe\xff\x00Q\x00t\x00 \x005\x00.\x001\x005\x00.\x003)\n/CreationDate (D:20220928141636+03\'00\')\n>>\nendobj\n2 0 obj\n<<\n/Type /Catalog\n/Pages 3 0 R\n>>\nendobj\n4 0 obj\n<<\n/Type /ExtGState\n/SA true\n/SM 0.02\n/ca 1.0\n/CA 1.0\n/AIS false\n/SMask /None>>\nendobj\n5 0 obj\n[/Pattern /DeviceRGB]\nendobj\n10 0 obj\n<<\n/Type /Annot\n/Subtype /Link\n/Rect [40.5000000  816.500000  80.2500000  827.750000 ]\n/Border [0 0 0]\n/A <<\n/Type /Action\n/S /URI\n/URI (http://10.0.0.20:8000/api/method/frappe.utils.print_format.download_pdf?doctype=Salary%20Slip&name=Sal%20Slip/HR-EMP-00001/00006&key=None)\n>>\n>>\nendobj\n6 0 obj\n<<\n/Type /Page\n/Parent 3 0 R\n/Contents 11 0 R\n/Resources 13 0 R\n/Annots 14 0 R\n/MediaBox [0 0 595.000000 842.000000]\n>>\nendobj\n13 0 obj\n<<\n/ColorSpace <<\n/PCSp 5 0 R\n/CSp /DeviceR...
      stderr = "The switch --print-media-type, is not support using unpatched qt, and will be ignored.The switch --header-html, is not support using unpatched qt, and will be ignored.The switch --footer-html, is not support using unpatched qt, and will be ignored.The switch --disable-smart-shrinking, is not support using unpatched qt, and will be ignored.QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-erpnext'\nExit with code 1 due to network error: ConnectionRefusedError\n"
      exit_code = 1
  File "env/lib/python3.10/site-packages/pdfkit/pdfkit.py", line 155, in handle_error
    raise IOError('wkhtmltopdf reported an error:\n' + stderr)
      exit_code = 1
      stderr = "The switch --print-media-type, is not support using unpatched qt, and will be ignored.The switch --header-html, is not support using unpatched qt, and will be ignored.The switch --footer-html, is not support using unpatched qt, and will be ignored.The switch --disable-smart-shrinking, is not support using unpatched qt, and will be ignored.QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-erpnext'\nExit with code 1 due to network error: ConnectionRefusedError\n"
      stderr_lines = ["The switch --print-media-type, is not support using unpatched qt, and will be ignored.The switch --header-html, is not support using unpatched qt, and will be ignored.The switch --footer-html, is not support using unpatched qt, and will be ignored.The switch --disable-smart-shrinking, is not support using unpatched qt, and will be ignored.QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-erpnext'", 'Exit with code 1 due to network error: ConnectionRefusedError']
builtins.OSError: wkhtmltopdf reported an error:
The switch --print-media-type, is not support using unpatched qt, and will be ignored.The switch --header-html, is not support using unpatched qt, and will be ignored.The switch --footer-html, is not support using unpatched qt, and will be ignored.The switch --disable-smart-shrinking, is not support using unpatched qt, and will be ignored.QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-erpnext'
Exit with code 1 due to network error: ConnectionRefusedError

Your problem seems to be wkhtmltopdf.

I hope this solution, which I found in another post that worked for me, helps you.

"After trying many ways, I finally got it to work.

First I removed all my previous installation by

sudo apt-get remove --purge wkhtmltopdf

sudo apt-get remove --automatic removal

Then I opened wkhtmltopdf.org and navigated to their Downloads and chose my distribution.

In the File section I downloaded the 0.12.x .deb version by

wget <copy the website link for the .deb file and paste it into the terminal here>.

sudo dpkg -i .

sudo cp /usr/local/bin/wkhtmltopdf /usr/bin

That’s all. Hope this helps."