Write Pro Hide/clear pictures when printing

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

: Piotr CHABOT STADHOUDERS

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

The only known way is to step through the pictures and replace them with a transparent png (same size)

Armin Deeg

Hi Armin,

Thanks for the tip!
I don’t get it that there until now is not a simple 4D command to hide/delete a picture

Gr,
Piotr

Hi,

I am sure you know of a best way to create such a trnasparent dummy picture :slight_smile:

With 4D Write it was possible to use a picture field directly and so you can have a record with the picture or an empty record and the picture was display or not like this. Is this technics always possible in Write Pro :?:

Try this, works offline

<code 4D>
// ----------------------------------------------------
// 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
</code 4D>

<code 4D>
//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

</code 4D>

Regards Armin

Hello Piotr

(i though I had answer this previously, sorry)

  • If your pictures are “inline” you can replace them by empty strings

  • If they are anchored you can “hide” them by giving them negative coordinates (for instance)

Have a look on attributes here

https://doc.4d.com/4Dv17/4D/17/4D-Write-Pro-Attributes.300-3726323.en.html
Then find : “wk anchor horizontal offset”

  • Finaly, If you use background pictures (for document, paragraphs… or even pictures), just use “WP reset attribute”

And, good news : “WP Delete picture” will be available soon :slight_smile:

Roland Lannuzel

Thanks Armin!

Thanks Roland

You can get width & height of the original then call :

<code 4D>
C_PICTURE($p)
CREATE THUMBNAIL($p;$p; width; height)
</code 4D>

Thanks again!