KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Add gridlines to 4D Write Pro document
PRODUCT: 4D | VERSION: 16R6 | PLATFORM: Mac & Win
Published On: December 6, 2018

Gridlines in a document can help align text and other objects as a reference. Here is a utility method to add gridlines to your 4D Write Pro document:

// ----------------------------------------------------------------------
// Name: WP_SHOW_GRID_LINES
// Description: Draws gridlines with SVG that will be the background
// image of a 4D Write Pro document.
//
// Parameters:
// $1 (POINTER) - Pointer to the 4D Write Pro object
// $2 (BOOLEAN) - True - Gridlines, False - No gridlines
// ----------------------------------------------------------------------
C_POINTER($1;$wpPtr)
C_BOOLEAN($2;$choice)
C_TEXT($svgID;$objRef)
C_LONGINT($i;$j)
C_PICTURE($pic)

If (Count parameters=2)

 $wpPtr:=$1
 $choice:=$2

 If ($choice)
  $svgID:=SVG_New
  For ($i;0;900;14)
   For ($j;0;900;14)
    $objRef:=SVG_New_rect ($svgID;$i;$j;14;14;0;0;"grey";"white";0.2)
   End for
  End for

  SVG EXPORT TO PICTURE($svgID;$pic;Copy XML data source)
  SVG_CLEAR ($svgID)
 End if

 WP SET ATTRIBUTES($wpPtr->;wk background image;$pic)
End if



Here is a sample code when there are not gridlines on 4D Write Pro:

WP_SHOW_GRID_LINES (->WriteProArea;False)





Here is a sample code when there are gridlines on 4D Write Pro:

WP_SHOW_GRID_LINES (->WriteProArea;True)