4D Tech mailing list wrote
> Hi,
>
> We want to print a Write Pro document without printing the contained
> pictures
> Say we print to paper that has corporate identity, we don’t want to print
> the logo that is inside the Pro document
> So we want copy the pro document to a new one, and in this new document
> hide/clear the pictures (logo) and then print
>
> When I set the picture to 0 bytes, the picture is not printed but I see an
> ugly black rectangle around it, so this does not work
> So, is there a way to procedurally hide/clear the pictures
>
> Gr,
> Piotr
Try something like this as a timesaver
// ----------------------------------------------------
// User name (OS): Armin Deeg
// Date and time: 08.04.19, 14:34:23
// ----------------------------------------------------
// Method: WP_ClearPictures
// Description
// Clears the pictures inside a WP document and replace them with a
transparent png
//
// Parameters $1 = WParea, $0 = count of replaced pictures
// ----------------------------------------------------
C_OBJECT($obj;$WP_SourceObject;$1;$obj_section)
C_COLLECTION($collection)
C_LONGINT($i;$n;$posRange;$i_length;$vl_sectinLoop;$vl_Counter;$0)
C_PICTURE($pict)
C_TEXT($text;$vt_expression)
C_REAL($vr_pictSize)
$WP_SourceObject:=$1
READ PICTURE FILE(Tool_GetPath ("4dRes")+"Images"+Folder
separator+"Maske"+Folder separator+"Elemente"+Folder
separator+"transparent.png";$pict)
$collection:=WP Get elements($WP_SourceObject;wk type image inline)
$vl_Counter:=0
$i:=0
$n:=$collection.length
For ($i;0;$n-1)
$obj:=$collection[$i]
$vr_pictSize:=Picture size($obj.image)
If ($vr_pictSize>200)
$vl_Counter:=$vl_Counter+1
$r:=WP Text range($obj;1;2)
$oPicts:=WP Picture range($r)
WP_PictSettings ($oPicts;"Get") //get width and height
WP INSERT PICTURE($oPicts;$pict;wk replace;wk include in range)
WP_PictSettings ($oPicts;"Set") //set width and height
End if
End for
$collection:=WP Get elements($WP_SourceObject;wk type image anchored)
$i:=0
$n:=$collection.length
For ($i;0;$n-1)
$obj:=$collection[$i]
$vr_pictSize:=Picture size($obj.image)
If ($vr_pictSize>200)
$vl_Counter:=$vl_Counter+1
$text:=JSON Stringify($obj)
If (Position("imageExpression\":\"W";$text)>0) // check if
picture comes
from reference
WP_PictSettings ($obj;"Get") //get width and height
//WP GET ATTRIBUTES($obj;wk image
expression;$vt_expression)
WP SET ATTRIBUTES($obj;wk image
expression;"WP_EmptyPicture") // method
returns a transparent png
WP_PictSettings ($obj;"Set") //set width and height
Else
WP_PictSettings ($obj;"Get") //get width and height
WP SET ATTRIBUTES($obj;wk image;$pict)
WP_PictSettings ($obj;"Set") //set width and height
End if
End if
End for
$0:=$vl_Counter
#########
//WP_PictSettings
C_OBJECT($1;$obj)
C_TEXT($2;$what)
C_TEXT(wk_text1;wk_text2)
$obj:=$1
$what:=$2
If ($what="Get")
WP GET ATTRIBUTES($obj;wk width;wk_text1;wk height;wk_text2)
Else
WP SET ATTRIBUTES($obj;wk width;wk_text1)
WP SET ATTRIBUTES($obj;wk height;wk_text2)
End if
Regards Armin
--
Sent from: http://4d.1045681.n5.nabble.com/4D-Tech-f1376241.html
**********************************************************************
4D Internet Users Group (4D iNUG)
Archive: http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub: mailto:[email protected]
**********************************************************************