How to get size of a specific page in bytes or KB using activity

Need to get size of a clipboard page using activity

@SriRaj

To get the size of a specific page in bytes or KB using an activity in Pega, you can use the estimatePageDataSize Java method. Here’s a step-by-step guide:

  1. Create a new Activity:

    • In the Pega Designer Studio, create a new activity or open an existing one where you want to calculate the page size.
  2. Add a Java Step:

    • Add a new step in your activity and set the method to Java.
  3. Insert Java Code:

    • Use the following Java code to estimate the size of the page:

      // Import necessary classes
      import com.pega.pegarules.pub.clipboard.ClipboardPage;
      import com.pega.pegarules.pub.clipboard.ClipboardProperty;
      import com.pega.pegarules.pub.runtime.PublicAPI;
      
      // Get the page you want to measure
      ClipboardPage myPage = tools.getPage("YourPageName");
      
      // Estimate the size of the page
      long pageSize = tools.estimatePageDataSize(myPage);
      
      // Convert size to KB
      double pageSizeKB = pageSize / 1024.0;
      
      // Log the size
      oLog.infoForced("Page size in bytes: " + pageSize);
      oLog.infoForced("Page size in KB: " + pageSizeKB);
      
      
  4. Run the Activity:

    • Save and run the activity. The size of the specified page will be logged in the Pega logs.

This method will help you determine the size of a specific page in bytes and convert it to KB for easier readability

@Avinash Swargam

Hi Avinash , will try out the approach thank you for the response

@Avinash Swargam

Hello Avinash ,

I was trying to fetch the size of the page using below code , my page will initially will be in one of the parameters [Param.ClipboardPageName] of type page and mapping it into a string called ClipboardpageName. when trying to save the rule im getting an error as

Error :

The method estimatePageDataSize(String) is undefined for the type PublicAPI

Compile failed.

// Java Code

ParameterPage objParamPage = tools.getParameterPage();

String ClipboardPageName = objParamPage.getString(“ClipboardPageName”);

long size = tools.estimatePageDataSize(ClipboardPageName);

Is there any otherway to get size and i couldnt include import classes steps because its causing below issue

Syntax error on token “import”, yield expected