Merge documents in Write Pro and "background" pictures

Dear,

I try to merge 2 different Write Pro documents,
but background pictures do not get merged.

Is this possible?

If so, how do I do it.

In v18.1 client server, I have tried
with making sections break, but haven’t been successful.

The central code of merging is in principal like this.
The if is just to convince me that I have the complete content in $template

// =====================
$template:= WP New (wp_template) // wp_template is a Write Pro Object field from templates table.

If ( Not(Option )) // testing 2 different cases

$rangeTarget:= WP Text range ( WPArea;wk end text;wk end text)WP INSERT BREAK ($rangeTarget;wk section break;wk append)
$rangeTarget:= WP Text range ( WPArea;wk end text;wk end text)
WP INSERT DOCUMENT** ($rangeTarget;$template;wk append)

Else

WPArea:=$template
End if

// =====================

The 2 branches is to see the result if I just copy the content using WP New.
This works fine with background pictures (and everything)

My aim is to build the final documents from existing “parts” (WPDocs). As example one “part” could be a maintenance scheme that I want to add inte an existing chapter of maintenance. Normally the maintenance document is portrait, but this scheme is landscape and has some background pictures and is ready made to merge into other docs.

Best Regards

Magnus

I might be wrong, but according to the documentation, you can apply distinct background attributes to each section, so it seems like you should create multiple sections.

To my knowledge, DOCX does not support multiple background attributes for a single document, so your Write Pro will not fully convert to Microsoft Word.

Thanks Miyako,

If I understand you correctly You say that having anchored pictures in a single document that are placed in different sections (and originates from different wp docs), may cause incompatibility with exporting to docx format.

  • Good to know and be aware of, but I think I can live with that for now.

Second you confirm that it should be possible to insert anchored pictures to different sections.

  • I think I can see that parsing the template for anchored pictures and then inserting them one by one with code and dealing with the positioning could be possible, but I think very tricky and difficult.

My hope was that schematically:
-WP Insert Break (targetRange;section break;wk append)
-WP Insert Document (target; template;append)
should do the job also with anchored pictures, but all my tries seems to prove it is not possible. I may also very well do something wrong when creating the “ranges”
and even though I do not think so, I mistakenly insert the document in the same section.

So the question is if the WP Insert Document can handle anchored images OR are there other commands that may do the job?

/Magnus

My post was specifically about background attributes, such as wk background image wk background image url or wk background color.

For anchored images, the following link might help:

https://discuss.4d.com/t/insert-an-anchored-image-attached-of-wp-document-using-wp-insert-document/12569

Dear Miyako,

Looks interesting, but the link resolves as privat and a search on the topic
does not find it. I am logged in and a partner.

Best
Magnus

Try this as a starter

Regards Armin


vt_MacPDFPage1:="Macintosh HD:Users:armindeeg:Desktop:brief1.pdf"
vt_MacPDFPage2:="Macintosh HD:Users:armindeeg:Desktop:brief2.pdf"

if(OB Get(WParea;"MarkusLogos";Is text)#"Drin")
$section:=WP Get section(WParea;1)


$subsection:=WP Get subsection($section;wk first page)
If($subsection=Null)
$subsection:=WP New subsection($section;wk first page)
end if
$wprange:=WP Add picture(WParea;vt_MacPDFPage1)
WP SET ATTRIBUTES($wprange;wk anchor layout;wk behind text)
WP SET ATTRIBUTES($wprange;wk anchor page;wk anchor first page)
WP SET ATTRIBUTES($wprange;wk anchor origin;wk paper box)
WP SET ATTRIBUTES($wprange;wk width;WParea.pageWidth)
WP SET ATTRIBUTES($wprange;wk height;WParea.pageHeight)
WP SET ATTRIBUTES($wprange;wk anchor section;1)

$subsection:=WP Get subsection($section;wk left page)
If($subsection=Null)
$subsection:=WP New subsection($section;wk left page)
end if
$wprange:=WP Add picture(WParea;vt_MacPDFPage2)
WP SET ATTRIBUTES($wprange;wk anchor layout;wk behind text)
WP SET ATTRIBUTES($wprange;wk anchor page;wk anchor left page)
WP SET ATTRIBUTES($wprange;wk anchor origin;wk paper box)
WP SET ATTRIBUTES($wprange;wk width;WParea.pageWidth)
WP SET ATTRIBUTES($wprange;wk height;WParea.pageHeight)
WP SET ATTRIBUTES($wprange;wk anchor section;1)

$subsection:=WP Get subsection($section;wk right page)
If($subsection=Null)
$subsection:=WP New subsection($section;wk right page)
end if
$wprange:=WP Add picture(WParea;vt_MacPDFPage2)
WP SET ATTRIBUTES($wprange;wk anchor layout;wk behind text)
WP SET ATTRIBUTES($wprange;wk anchor page;wk anchor right page)
WP SET ATTRIBUTES($wprange;wk anchor origin;wk paper box)
WP SET ATTRIBUTES($wprange;wk width;WParea.pageWidth)
WP SET ATTRIBUTES($wprange;wk height;WParea.pageHeight)
WP SET ATTRIBUTES($wprange;wk anchor section;1)

//Marker damit das nicht doppelt gemacht wird
OB SET(WParea;"MarkusLogos";"Drin")
end if