KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Preview the 4D Write offscreen area into pictures
PRODUCT: 4D | VERSION: 15.1 | PLATFORM: Mac & Win
Published On: April 20, 2016

Ever want to preview your 4D write offscreen area without opening the document? Here is a method PREVIEW_WR_OS_AREA_AS_PICTURES to preview the area that exports a picture for each page:

// --------------------------------------------------------------------------------
// Name: PREVIEW_WR_OS_AREA_AS_PICTURES
// Description: Method will preview the 4D Write offscreen Area to a picture for
// each page of the document.
// Input:
// $1 (POINTER) - 4D Write offscreen Area pointer
// $2 (TEXT) - Location of the file to be created with the name.
// $3 (TEXT) - Picture file extension to be converted.
// --------------------------------------------------------------------------------
C_POINTER($1;$wrArea)
C_PICTURE($pic)
C_TEXT($2;$loc;$tempLoc)
C_TEXT($3;$picType)
C_LONGINT($i;$page;$column;$line;$position)

If (Count parameters=3)
   $wrArea:=$1
   $loc:=$2
   $picType:=$3

   WR GET CURSOR POSITION ($wrArea->;$page;$column;$line;$position)

   For ($i;1;$page)
      $pic:=WR Build preview ($wrArea->;$i)
      $tempLoc:=$loc+string($i)+$picType
      WRITE PICTURE FILE($tempLoc;$pic;$picType)
   End For
End if


Here is an example using the command:

C_TEXT($loc;$type)

$type:=".jpg"
$loc:=Get 4D folder(Database folder)+"previewJPEG"

PREVIEW_WR_OS_AREA_AS_PICTURES(->wrArea;$loc;$type)

// Will generate the number pictures on the number of pages

WR DELETE OFFSCREEN AREA (wrArea)