how to create report in pdf format

how to create report in pdf format

erumerum Posts: 9Questions: 4Answers: 0
edited January 2018 in Free community support

Can any one share me how to print report in pdf format when button click ,mvc view just have single button which shows report ?? i do not want to bind data in view,just want in action method .

@model CallCenterCRM.TBL_CustomerMaster

<script>

    $(document).ready(function () {
        $('#example').DataTable({
            dom: 'Bfrtip',
            buttons: [
                //'copyHtml5',
                //'excelHtml5',
                //'csvHtml5',
                'pdfHtml5'
            ]
        });
    });
</script>
@using (Html.BeginForm())
{
    @Html.AntiForgeryToken()

    
    
    <div class="form-group">
      
        <div class="col-md-10">
            @Html.ActionLink("Show All Customer", "ShowReport", "Customer")
          
        </div>
    </div>
}


  public ActionResult ShowReport()
        {
            return View();
        }

Answers

  • allanallan Posts: 63,552Questions: 1Answers: 10,477 Site admin

    DataTables' Buttons extension doesn't have a print pdf option. It has a print view option and a pdf export option. If you want to print a pdf with a single click you'd need to add that ability - I'm not sure how you'd do that since you can't write Javascript for the pdf viewer from the browser...

    Allan

  • erumerum Posts: 9Questions: 4Answers: 0

    Allan ,u r not getting me ,
    let me rephrase problem ,suppose i have view where two calendar exist ,one for start and second is for end date .

    when user select dates ,it print between two dates on button click.

    what is best possible way to do so.

  • allanallan Posts: 63,552Questions: 1Answers: 10,477 Site admin

    You can create a custom filtering plug-in if you need to filter a table over a range of data. This example shows how it can be done with simple integers, but you could extend that to work with dates if you need.

    Then when you use Buttons to export the data, it will (by default) only export the filtered data.

    Allan

  • erumerum Posts: 9Questions: 4Answers: 0

    how can extend

  • allanallan Posts: 63,552Questions: 1Answers: 10,477 Site admin

    If you need an example of that written, it would be covered by the quick support options.

    Allan

  • erumerum Posts: 9Questions: 4Answers: 0

    i change my code to print report ,but its not creating pdf

    @model IEnumerable<CallCenterCRM.Models.ViewModel.EmpDeptDesignationModel>

    EmpDeptDesignationModel


    @foreach (var item in Model) { }
    @Html.DisplayNameFor(model => model.Emp_Name) @Html.DisplayNameFor(model => model.Department) @Html.DisplayNameFor(model => model.DesignationName) @Html.DisplayNameFor(model => model.Emp_DOJ)
    @Html.DisplayFor(modelItem => item.Emp_Name) @Html.DisplayFor(modelItem => item.Department) @Html.DisplayFor(modelItem => item.DesignationName) @Html.DisplayFor(modelItem => item.Emp_DOJ)
    $(document).ready(function () { $('#table_id').dataTable({ dom: 'Bfrtip', buttons: [ { extend: 'pdfHtml5', download: 'open' } ], "pagingType": "full_numbers", "scrollY": "400px", "scrollX": true }); });
This discussion has been closed.