I've used a crystal report in winform p.o.s project the problem is that when i try to save or print the report as pdf it gives an error "Attempted to divide by zero" but the preview is working just fine
Here is the code snippet for the print method
public void PrintReceipt(int id)
{
pagesTab.SetPage(7);
receipt_Template1.SetDataSource(_productService._orderDetails.Where(ol => ol.OrderId == id).ToList());
var order = _productService._orderList.Where(ol => ol.Id == id).FirstOrDefault();
var mop = order.ModeOfPayment;
var amountpaid = order.AmountPaid;
var totalamount = order.Total;
var change = order.Change;
var customerName = order.CustomerName;
var dateOfPurchase = order.DateOfPurchase;
var orderId = order.Id;
receipt_Template1.SetParameterValue("pMop", mop);
receipt_Template1.SetParameterValue("pAmountPaid", amountpaid);
receipt_Template1.SetParameterValue("pTotal", totalamount);
receipt_Template1.SetParameterValue("pChange", change);
receipt_Template1.SetParameterValue("pCustomerName", customerName);
receipt_Template1.SetParameterValue("pDateOfPurchase", dateOfPurchase);
receipt_Template1.SetParameterValue("pOrderId", orderId);
crystalReportViewer1.ReportSource = receipt_Template1;
}
}
Here are the section properties
What seems to be causing it ?
I've tried switching some properties like "Suppress" but still it did not work, tried looking at my formula fields but none of them perform any mathematical operations that may result in dividing by zero.






I've already found the problem turns out "Microsoft to PDF" does not allow small receipt sizes but i still managed to export it as pdf using Crystal Report export to disk " receipt_Template1.ExportToDisk(ExportFormatType.PortableDocFormat, pdfFilePath); "