Amila Thennakoon
Amila Thennakoon

Reputation: 417

Crystal reports barcode shrink when generate pdf from asp.net mvc

I am using following code to generate pdf from crystal report in ASP.NET MVC platform

 [HttpGet]
    public ActionResult ClassCard()
    {

        ReportDocument rd = new ReportDocument();

        rd.Load(Path.Combine(Server.MapPath("~/Reports"), "ClassCard.rpt"));
        rd.SetParameterValue("ClassName", "Kandy");
        rd.SetParameterValue("Type", "Group Theory");
        rd.SetParameterValue("year", "2016");
        rd.SetParameterValue("Student", "KDG0012");




        rd.SetDatabaseLogon("DB_74931_rmsecon_user", "snb123");


        Response.Buffer = false;
        Response.ClearContent();
        Response.ClearHeaders();
        try
        {
            Stream stream = rd.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
            stream.Seek(0, SeekOrigin.Begin);
            return File(stream, "application/pdf", "EverestList11.pdf");
        }
        catch (Exception ex)
        {
            throw ex;
        }



    }

this give me pdf as below

enter image description here

but as you see the barcode is shrinked ,how im solve this problem in ASP.NET MVC enviroment

i saw most people say add registy key ,but i cannot do this coz this is asp.net mvc web application and im going host this app on sheared server

if im Add below regiter keys the problem will solve only for if im generate crystal report in local desktop app

enter image description here

Upvotes: 0

Views: 1630

Answers (2)

Iti Tyagi
Iti Tyagi

Reputation: 3661

I had faced the similar issue of shrinking of the font while exporting the file to PDF, this is actually the default behavior while export. In order to maintain the original font and behavior, you can check the following answers where few registry changes are suggested.

  1. Font Size Problem Crystal Report

  2. Font Issue Details in Crystal Report

Upvotes: 1

reckface
reckface

Reputation: 5858

The problem is that the crystal reports runtime has or had a well known issue that fonts shrink when reports are exported to pdf.

As you noted one (undesirable) option is to modify registry keys as discussed here and here. Another is to compensate by sizing your fonts appropriately to allow for the shrinkage.

I opted for upgrading to Crystal reports for visual studio version 13 which supports dynamic image urls but more importantly I stopped using fonts in favour of a barcode imaging libraries.

Upvotes: 1

Related Questions