DESKTOP EDITION CLOUD EDITION SERVER EDITION GUIDES FORUM

PDF / Email error on custom theme


#1

I understand custom themes are typically not supported here, but I think this could probably be easily answered by someone. I have tweaked the basic theme in a few ways, but I am not embedding any special characters, I am not changing fonts, I am not embedding any images, the only thing I have done is moved some blocks of code around and displayed a couple of custom fields. Here is the error I am getting:

InvalidOperationException: System.InvalidOperationException: Sequence contains no elements
at System.Linq.Enumerable.Max(IEnumerable`1 source)
at ManagerServer.PdfConverter.Table(IHtmlTableElement node, Font font)
at ManagerServer.PdfConverter.ContentElement(INode node, Font font, Boolean nowrap)
at ManagerServer.PdfConverter.ContentElement(INode node, Font font, Boolean nowrap)
at ManagerServer.PdfConverter.Tr(IHtmlTableRowElement node, Font font)
at ManagerServer.PdfConverter.Table(IHtmlTableElement node, Font font)
at ManagerServer.PdfConverter.ContentElement(INode node, Font font, Boolean nowrap)
at ManagerServer.PdfConverter.ContentElement(INode node, Font font, Boolean nowrap)
at ManagerServer.PdfConverter.Tr(IHtmlTableRowElement node, Font font)
at ManagerServer.PdfConverter.ConvertHtmlToPdf(String input, Stream output, PageBoundary pageBoundary)
at ManagerServer.HttpHandlers.Pdf.Post()

This only appears on invoices that are paid / overdue. I removed the code that generates the stamp, and the error goes away. Here is the unmodified code that generates the stamp.

                    {% if emphasis.text != null and emphasis.positive %}
    <tr><td colspan="99"><div style="text-align: center; margin-top: 40px"><span style="color: #006400; border-width: 5px; border-color: #006400; padding: 10px; font-size: 20px">{{ emphasis.text | upcase }}</span></div></td></tr>
    {% endif %}

    {% if emphasis.text != null and emphasis.negative %}
    <tr><td colspan="99"><div style="text-align: center; margin-top: 40px"><span style="color: #FF0000; border-width: 5px; border-color: #FF0000; padding: 10px; font-size: 20px">{{ emphasis.text | upcase }}</span></div></td></tr>
    {% endif %}

I did search the forums and found another topic from march with the same issue, but there was no resolution on that thread. Any help here would be greatly appreciated.


#2

If you get error message like this, it is a bug and needs to be fixed.

Can you post full theme so this error can be reproduced?


#3
<table style="padding: 30px">
    <thead>
        <tr>
            <td colspan="99">
                <table style="margin-bottom: 20px"><tr>
                    <td style="font-weight: bold; font-size: 32px">{{ title }}</td>
                    <td>
                    {% if business.logo != null %}<td style="text-align: right"><img src="{{ business.logo }}" style="max-height: 150px; max-width: 300px" /></td>{% endif %}
                </tr>
                <tr>
        </tr></table>
                
                <table style="margin-bottom: 20px"><tr>
                    <td width="33%">
                        <b>BILL TO:</b>
                        <div>{{ recipient.name }} {{ recipient.code }}</div>
                        <div>{{ recipient.address | newline_to_br }}</div>
                        <div>{{ recipient.identifier }}</div>
                    </td>
                    <td width="33%">
                    <b>SHIP TO:</b><br>
                        {% for field in custom_fields %}
                          {% if field.label == 'Service Location' %}
                            {{ field.text | newline_to_br  }}
                        {% endif %}
                        {% endfor %}
                    </td>
                    <td>
                        <table>{% if emphasis.text != null and emphasis.positive %}
        <tr><td colspan="99"><div style="text-align: center; margin-top: 40px"><span style="color: #006400; border-width: 5px; border-color: #006400; padding: 10px; font-size: 20px">{{ emphasis.text | upcase }}</span></div></td></tr>
        {% endif %}

        {% if emphasis.text != null and emphasis.negative %}
        <tr><td colspan="99"><div style="text-align: center; margin-top: 40px"><span style="color: #FF0000; border-width: 5px; border-color: #FF0000; padding: 10px; font-size: 20px">{{ emphasis.text | upcase }}</span></div></td></tr>
        {% endif %}</table>
        </td>
                </tr></table>
            </td>
        </tr>
        <tr>
            <td>
                <table width="40%">
                    <tr style="background: #E3E3E3;">
                        <td><b>Invoice Number</b></td>
                        <td><b>Invoice Date</b></td>
                        <td><b>Due Date</b></td>
                        <td><b>Sales Rep</b></td>
                    </tr>
                    <tr>
                        <td>{% for field in fields %}
                          {% if field.label == 'Invoice number' %}
                            {{ field.text }}
                        {% endif %}
                        {% endfor %}
                        </td>
                        <td>{% for field in fields %}
                          {% if field.label == 'Invoice date' %}
                            {{ field.text }}
                        {% endif %}
                        {% endfor %}
                        </td>
                        <td>{% for field in fields %}
                          {% if field.label == 'Due date' %}
                            {{ field.text }}
                        {% endif %}
                        {% endfor %}
                        </td> 
                        <td>{% for field in custom_fields %}
                          {% if field.label == 'Sales Rep' %}
                            {{ field.text }}
                        {% endif %}
                        {% endfor %}
                    </tr>
                </table>
        <tr>
            {% for column in table.columns %}            
            <td style="font-weight: bold; padding: 2px 2px 2px 5px; text-align: {{ column.align }}; border-left-width: 1px; border-bottom-width: 1px; border-top-width: 1px{% if forloop.last == true %}; border-right-width: 1px{% endif %}{% if column.nowrap %}; width: 80px{% endif %}">{{ column.label }}</td>
            {% endfor %}
        </tr>
    </thead>
    <tbody>
        {% for row in table.rows %}
        <tr>
            {% for cell in row.cells %}
            <td style="padding: 2px 2px 2px 5px; text-align: {{ table.columns[forloop.index0].align }}; border-left-width: 1px{% if forloop.last == true %}; border-right-width: 1px{% endif %}{% if table.columns[forloop.index0].nowrap %}; white-space: nowrap; width: 80px{% endif %}">{{ cell.text | newline_to_br }}</td>
            {% endfor %}
        </tr>
        {% endfor %}
        <tr>
        {% for column in table.columns %}            
            <td style="border-bottom-width: 1px; border-left-width: 1px{% if forloop.last == true %}; border-right-width: 1px{% endif %}">&nbsp;</td>
        {% endfor %}
        </tr>
        {% for total in table.totals %}
        <tr>
            <td colspan="{{ table.columns | size | minus:1 }}" style="padding: 2px 2px; text-align: right{% if total.emphasis == true %}; font-weight: bold{% endif %}">{{ total.label }}</td>
            <td style="border-left-width: 1px; white-space: nowrap; border-right-width: 1px; border-bottom-width: 1px; padding: 5px 10px; text-align: right{% if total.emphasis == true %}; font-weight: bold{% endif %}">{{ total.text }}</td>
        </tr>
        {% endfor %}



 <tr>
 <td colspan="9999">
                        <div style="font-weight: bold;">Please send payments to:</div>
                        <div>{{ business.name }}</div>
                        <div>{{ business.address | newline_to_br }}</div>
                        <div>{{ business.identifier }}</div>  
                        <div style="text-align: center; font-size: 15px; font-weight: bold; margin-top: 15px; margin-bottom: 15px;">Securely pay your invoice on our website at <a href="www.google.com">www.google.com</a></div>
                        <div style="font-size: 10px;">This invoice includes goods and/or services provided by xxx and/or it's partners. Payment is expected to be received in our office on or before the date listed at the top of this invoice. If you have any questions about this invoice or concerns with the services rendered you must notify us immediately so that we may work together toward a resolution. Failure to pay this invoice does not constitute notification of problems and the invoice will be subject to finance charges.</div>
                        <div style="margin-top: 10px;font-size: 10px;"><b>Finance Charges</b> All invoices left unpaid will be subject to a 2.5% finance charge immediately. Finance charges will continue to be assessed monthly if invoices remain unpaid. Invoices not paid within 15 days of their due date may cause loss of terms, required pre-payment for future work, service disconnection and additional collection costs if necessary. Payments are posted according to the date of the post mark.</div>
                        </td>
                        </tr>
    </tbody>
</table>

Thank you for looking into this. I pasted the theme exactly with two minor redactions. I changed the link to our payment portal to www.google.com but I left the hyperlink code in the theme and I changed the name of my business which is listed in the paragraph toward the bottom to “x”, but it is fundamentally the same as it is on my manager system.

I am running server version 18.5.31 on a Windows server machine.


#4

The latest version (18.7.29) will not produce the error anymore.