locked
Report RDLC problem with the size of image RRS feed

  • Question

  • User-1345489790 posted

    Report RDLC problem with the size of image

    I'm developing a custom dynamic report using rdlc, based on the code of this site : "http://www.gotreportviewer.com/"

    The code i'm using to create the image is below ...

    when I run the report the image is showing up but with width=1 and height=5

    can anyone help me to solve this issue ?

    tanks!

    the output generated for the image is below, note the [ width="1" height="5" ]

    "
    <td class="Ac02edaafe3cf462da64fde7ad21cbc0c25c"><div class="Pb2192df04c1b431c81a2218a01b9f6f1_1_r2" style="min-height: 30.34mm; min-width: 24.4mm;"><img width="1" height="5" title="testing" onload="this.fitproportional=true;this.pv=0;this.ph=0;" alt="testing" src="/Reserved.ReportViewerWebControl.axd?Culture=2070&amp;CultureOverrides=True&amp;UICulture=2070&amp;UICultureOverrides=True&amp;ReportStack=1&amp;ControlID=b2192df04c1b431c81a2218a01b9f6f1&amp;Mode=true&amp;OpType=ReportImage&amp;IterationId=78fc82afa58b4e05b2ab327b2fa7ae31&amp;StreamID=a25a98a9eee44b8bad464cd6ae9a390f"></div></td>
    "


    private Rdl.ReportItemsType CreateTableCellReportItems(string fieldName)
    {
    string aa = m_fields.Find(x => x == fieldName);
    int i = m_fields.FindIndex(x => x == fieldName);
    bool isImage = false;

    if (config.ArrayOfIsImage!= null && i < config.ArrayOfIsImage.Length)
    {
    isImage = config.ArrayOfIsImage[i];
    }

    Rdl.ReportItemsType reportItems = new Rdl.ReportItemsType();

    if (isImage)
    {
    reportItems.Items = new object[] { CreateTableCellImage(fieldName) };
    }
    else
    {
    reportItems.Items = new object[] { CreateTableCellTextbox(fieldName) };
    }

    return reportItems;
    }

    +++++++++++++++++++++++++++++
    private Rdl.ImageType CreateTableCellImage(string fieldName)
    {
    Rdl.ImageType image = new Rdl.ImageType();
    image.Name = fieldName;
    image.Items = new object[]
    {
    //Rdl.ImageTypeSizing.FitProportional,
    Rdl.ImageTypeSizing.FitProportional,
    /* "image/png", */
    Rdl.ImageTypeSource.External,
    "3cm",
    "5cm",
    "=Fields!" + fieldName + ".Value",
    CreateTableCellImageStyle(),

    /* CreateCustomPropertiesImage(), trying to fix: bug with <img=... width="1" ...> */
    "testing",

    };

    image.ItemsElementName = new Rdl.ItemsChoiceType15[]
    {
    Rdl.ItemsChoiceType15.Sizing,

    /* Rdl.ItemsChoiceType15.MIMEType, */

    Rdl.ItemsChoiceType15.Source,

    Rdl.ItemsChoiceType15.Width,
    Rdl.ItemsChoiceType15.Height,


    Rdl.ItemsChoiceType15.Value,

    Rdl.ItemsChoiceType15.Style,

    //Rdl.ItemsChoiceType15.CustomProperties,

    Rdl.ItemsChoiceType15.ToolTip,

    };

    return image;

    }


    private Rdl.CustomPropertiesType CreateCustomPropertiesImage()
    {
    Rdl.CustomPropertyType customPropertyType = new Rdl.CustomPropertyType();

    customPropertyType.Items = new object[]
    {
    "Width",
    "123pt",
    //"img",
    };

    customPropertyType.ItemsElementName = new Rdl.ItemsChoiceType10[]
    {
    Rdl.ItemsChoiceType10.Name,
    Rdl.ItemsChoiceType10.Value,
    //Rdl.ItemsChoiceType10.Item,
    };

    //XmlChoiceIdentifierAttribute

    Rdl.CustomPropertiesType xxx = new Rdl.CustomPropertiesType();
    xxx.CustomProperty = new Rdl.CustomPropertyType[]{ customPropertyType};

    return xxx;
    }

    Thursday, October 20, 2016 1:17 PM

All replies

  • User-2057865890 posted

    Hi Cealex,

    When I try the above code, errors occur. Could you provide your source code? You could upload to OneDrive.

    Best Regards,

    Chris

    Friday, October 21, 2016 9:00 AM
  • User-1345489790 posted

    Hi Chris,

    thank you!

    You can download the code from " https://1drv.ms/f/s!AsoSUcBBePJChXjaL51pAcXSg5if "

    Inside the reportviewer folder do you have a  zip file with all the code to generate the report, plus 2 images (print-screen) showing the problem and a file  with a call example code (HOW-TO-CALL.cs.txt).

    best regards,

    Ca.

    Friday, October 21, 2016 10:10 AM