File size issue

Posted by: ricardo.pereira on 14 February 2020, 3:37 am EST

    • Post Options:
    • Link

    Posted 14 February 2020, 3:37 am EST

    Hi,

    I’m experiencing a weird report file size issue which after exploring noticed it was due to the usage of “.substring()” inside of the textbox value tag.

    On my report I have 96 textboxes all with code similar to this:

    
                            <Textbox Name="TextBox33">
                              <DataElementOutput>NoOutput</DataElementOutput>
                              <Height>0.1653646cm</Height>
                              <Left>2.54615cm</Left>
    [b]                          <Value>=iif(ReportItems![TextBox179].Value.substring(5,1)="1","N")</Value>[/b]
                              <Style>
                                <BackgroundColor>=iif(ReportItems![TextBox178].Value.substring(5,1)="1","DarkGray")</BackgroundColor>
                                <FontFamily>Arial</FontFamily>
                                <FontSize>4pt</FontSize>
                                <FontStyle>Normal</FontStyle>
                                <FontWeight>700</FontWeight>
                                <PaddingBottom>0pt</PaddingBottom>
                                <PaddingLeft>0pt</PaddingLeft>
                                <PaddingRight>0pt</PaddingRight>
                                <PaddingTop>0pt</PaddingTop>
                                <TextAlign>Center</TextAlign>
                                <VerticalAlign>Middle</VerticalAlign>
                                <BorderColor>
                                  <Default>LightGray</Default>
                                </BorderColor>
                                <BorderStyle>
                                  <Bottom>Solid</Bottom>
                                  <Left>Solid</Left>
                                  <Right>Solid</Right>
                                </BorderStyle>
                                <BorderWidth>
                                  <Default>0.5pt</Default>
                                </BorderWidth>
                              </Style>
                              <Top>0.1653646cm</Top>
                              <Width>0.2272cm</Width>
                              <ZIndex>112</ZIndex>
                            </Textbox>
    

    Both TextBox179 and TextBox178 represent 2 different bitarrays of 96 values.

    The logic is simple:

    If TextBox178 bit at position x is 1 use DarkGray as background color.

    If TextBox179 bit at position x is 1 use N as a value (text).

    If I replace the code and instead of =iif(ReportItems![TextBox179].Value.substring(5,1)=“1”,“N”) I use [b][b] or even [b]N[b] (to display Ns in all 96 text boxs) I get a ~3mb file for a report with 47 pages.

    But If I use that substring which is inside of the tag I still get the same 47 pages report but with a file size of ~52mb.

    Is there a .substring() replacement like .findAtChar(index, value)? What could be the cause of this massively increase in size?

    Thanks in advance.

    Best Regards,

    Ricardo Pereira

  • Posted 16 February 2020, 11:28 pm EST

    Hello Ricardo,

    Could you please try with the following lines of code:

    =iif(ReportItems![TextBox179].Value.substring(5,1)="1","N","")
    =iif(ReportItems![TextBox178].Value.substring(5,1)="1","DarkGray", "White")
    

    Thanks,

    Mohit

  • Posted 17 February 2020, 2:02 am EST

    Hello Mohit,

    Thanks for your response, unfortunately that solution didn’t work.

    Just to clarify the report runs fine, a bit slow, but the data is correct.

    I also would like to add that that I previously ran some tests, and I think that the issue might be with the substring function even though it doesn’t make much sense to me how a function like that could massively increase the pdf file size.

    Here are some tests I ran:

    Original report (with the substring):

    1:53m generate
    1:44m export
    52.797mb - 47 pages
    

    Test 1 - Removed the substring functions from the values, leaving the substring functions on the BackgroundColor tag only (empty value tags):

    41s generate
    17s export
    2.205mb - 47 pages
    

    Test 2 - Replaced the substring functions from the values with N’s on every textbox, leaving the substring functions on the BackgroundColor tag only (N on every value tag):

    45s generate
    32s export
    3.149mb - 47 pages
    

    Thank you again.

  • Posted 17 February 2020, 3:05 am EST

  • Posted 17 February 2020, 4:53 am EST

    This is causing us massive problems. Simple use of a substring function should not massively inflate the PDF like this. Customer’s can’t run long reports, because they take so long.

    Please can you escalate this if possible. Thanks

    Regards

    John Butler (CTO)

  • Posted 17 February 2020, 5:40 pm EST

    Hello Ricardo,

    I have analyzed this issue and there is no issue with SubString Method. The main issue when we try to access the report item value then it increases the size of the PDF.

    As a workaround, you can use the following steps:

    1: Create a hidden parameter

    2: Set the default value of the parameter to the same value as in TextBox179.

    3: Use the following syntax:

    =IIF(ToString(Parameters!ReportParameter1.Value).SubString(5,1)=“1”,“N”)

    Hope it helps.

    Please let me know if the workaround is suitable for you.

    Thanks,

    Mohit

  • Posted 17 February 2020, 10:26 pm EST

    Hello Mohit,

    Thanks for your explanation.

    I’ve tried to implement your workaround but unfortunately was unsuccessful. Probably I’m doing something incorrectly but from what I analyzed, it seems that the default value of the ReportParameter can only be a static value instead of another ReportItem (which is our aim).

    I’m using this syntax:

                              <Value>=iif(ToString(Parameters!Array.Value).substring(5,1)="1","N")</Value>
    
    

    And added a new hidden param called Array with the default value pointing at TextBox179:

        <ReportParameter Name="Array">
          <DataType>String</DataType>
          <Prompt>Array</Prompt>
          <Hidden>true</Hidden>
          <DefaultValue>
            <Values>
              <Value>=ReportItems![TextBox179].Value</Value>
            </Values>
          </DefaultValue>
        </ReportParameter>
    

    But this isn’t working.

    If I change that param value to a static value it works (but doesn’t help in our case):

    <ReportParameter Name="Array">
          <DataType>String</DataType>
          <Prompt>Array</Prompt>
          <Hidden>true</Hidden>
          <DefaultValue>
            <Values>
              <Value>000000000000000000011111111111100000000000000000000000000000000000000000000000000000000000000000</Value>
            </Values>
          </DefaultValue>
        </ReportParameter>
    

    What could be the issue?

    Thank you very much!

    Best Regards,

    Ricardo Pereira

  • Posted 17 February 2020, 10:41 pm EST

    Hello Ricardo,

    Parameter value is evaluated before report rendering that’s why you can not set the “ReportItems![TextBox179].Value” in the default value.

    If you are binding TextBox179 with some database field. You can bind the same database field with the parameter.

    Please let me know if you have still some issues regarding this. Also, please share the exact version of AR that you are using.

    Thanks,

    Mohit

  • Posted 18 February 2020, 12:55 am EST

    We are using ActiveReports v12.3.17127.0.

    “If you are binding TextBox179 with some database field. You can bind the same database field with the parameter.”

    We are using Server Data Sets instead of Data Sources to feed our RDLX reports. Would that bind also work for those data set fields? Because I tried

    		<ReportParameter Name="Array">
    			<DataType>String</DataType>
    			<Prompt>Array</Prompt>
    			<Hidden>true</Hidden>
    			<DefaultValue>
    				<Values>
    					<Value>=Fields!Field1.Value</Value>
    				</Values>
    			</DefaultValue>
    		</ReportParameter>
    

    And it didn’t work either.

    Also our TextBox179 is using a Custom Assembly (https://help.grapecity.com/activereports/webhelp/AR12/webframe.html#CustomCode.html) to generate it’s value.

    <Textbox Name="TextBox179">
    													<CanGrow>true</CanGrow>
    													<Height>0.32cm</Height>
    													<Left>0.4862613cm</Left>
    													<Value>=ClassName.ParseJSONToBitArray(Fields!Field1.Value)</Value>
    													<Style>
    														<PaddingBottom>2pt</PaddingBottom>
    														<PaddingLeft>2pt</PaddingLeft>
    														<PaddingRight>2pt</PaddingRight>
    														<PaddingTop>2pt</PaddingTop>
    													</Style>
    													<Visibility>
    														<Hidden>true</Hidden>
    													</Visibility>
    													<Width>0.6cm</Width>
    													<ZIndex>232</ZIndex>
    												</Textbox>
    

    This custom code takes a JSON that came from the database and then produces a bitarray.

    Can we use custom code on that ReportParameter workaround?

  • Posted 18 February 2020, 1:06 am EST

    Hello Ricardo,

    Would that bind also work for those data set fields?

    You need to assign the value as follow:

    <ReportParameter Name="ReportParameter1">
    			<DataType>String</DataType>
    			<Prompt>ReportParameter1</Prompt>
    			<DefaultValue>
    				<DataSetReference>
    					<DataSetName>DataSet1</DataSetName>
    					<ValueField>Cell1</ValueField>
    				</DataSetReference>
    			</DefaultValue>
    		</ReportParameter>
    
    

    I have checked at my end. Custom code works fine with the parameter. Please refer to the attached report.

    Thanks,

    Mohit

    Untitled.zip

  • Posted 18 February 2020, 4:14 am EST

    Hello Mohit,

    I did the following:

    <ReportParameter Name="Array">
      <DataType>String</DataType>
      <Nullable>true</Nullable>
      <Prompt>Array</Prompt>
      <Hidden>true</Hidden>
      <DefaultValue>
    	<Values>
    	  <Value>=ClassName.ParseJSONToBitArray(Parameters!Json.Value)</Value>
    	</Values>
      </DefaultValue>
    </ReportParameter>
    <ReportParameter Name="Json">
      <DataType>String</DataType>
      <Nullable>true</Nullable>
      <Prompt>Json</Prompt>
      <Hidden>true</Hidden>
      <DefaultValue>
    	<DataSetReference>
    	  <DataSetName>MyDataSetName</DataSetName>
    	  <LabelField>Json</LabelField>
    	  <ValueField>Json</ValueField>
    	</DataSetReference>
      </DefaultValue>
    </ReportParameter>
    

    And it worked, but only for the first row of my data set.

    Basically for each row of my data set I want to take the JSON and pass it as a parameter to the ClassName.ParseJSONToBitArray function.

    My data is all grouped using a BandedList and the previous TextBox179 was inside of the BandedList_Details and looking at the JSON param.

    How can I achieve that? I tried the Multiline option on those two new ReportParameters but I still didn’t get the result I was expecting for.

    Thank you once again.

    Best Regards,

    Ricardo Pereira

  • Posted 18 February 2020, 5:48 pm EST

    Hello,

    Unfornutaly this workaround does not work in this case. Can’t you use the expression directly on all other textboxes as follow:

    =IIF(ToString(ClassName.ParseJSONToBitArray(Fields!Json.Value)).SubString(5,1)=“1”,“N”)

    If no, then I will escalate the case to our development for further research.

    Thanks,

    Mohit

  • Posted 19 February 2020, 3:54 am EST

    Hello,

    There’s no need to escalate this issue. That workaround works for us. It improved the timings of the report generation and exportation as well as the pdf file size which was the main issue.

    Thank you very much for all your help.

    Best Regards,

    Ricardo Pereira

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels