1. Stephen BIppen
  2. PowerBuilder
  3. Thursday, 18 April 2024 19:01 PM UTC

I have been tasked with adding a watermark to printed documents. 

Before printing, I copy the dataobject into a local datastore, copy the data (RowsCopy), add the watermark to the background (Modify("CREATE...")), and then make the background for each of the objects transparent (Modify("<name>.Background.Transparency='100'")), so the watermark is visible.

My problem is nested reports. I need to reach into those reports and make the background of each of those objects transparent as well.

As an example, I have a nested report object, dw_1, and an object on that report, last_name, that needs a transparent background.

These all work:

lds_print.Object.dw_1.Object.last_name.Background.Transparency="100"

lds_print.Object.dw_1[1].Object.last_name.Background.Transparency="100"

DWbject ldwo
ldwo = lds_print.Object.dw_1[1]
ldwo.Object.last_name.Background.Transparency="100"

But I need to be able to do this dynamically, I am not going to know the names of the objects in the nested reports.

None of these work:

lds_print.Modify("dw_1[1].Object.last_name.Background.Transparency='100'") >>> Line 1 Column 5: incorrect syntax.

lds_print.Modify("Object.dw_1[1].Object.last_name.Background.Transparency='100'") >>> Line 1 Column 12: incorrect syntax.

lds_print.Modify("Object.dw_1.Object.last_name.Background.Transparency='100'") >>> Line 1 Column 47: incorrect syntax.

lds_print.Modify("dw_1.Object.last_name.Background.Transparency='100'") >>> Line 1 Column 41: incorrect syntax.

lds_print.Modify("dw_1[1].last_name.Background.Transparency='100'") >>> Line 1 Column 5: incorrect syntax.

lds_print.Modify("dw_1.last_name.Background.Transparency='100'") >>> Line 1 Column 34: incorrect syntax.

Am I missing something, am I not going to be able to do this dynamically?

Any input is appreciated.

Mark Goldsmith Accepted Answer Pending Moderation
  1. Thursday, 18 April 2024 21:09 PM UTC
  2. PowerBuilder
  3. # 1

Hi Stephen,

I agree with Chris that it seems like a lot of work to accomplish something that could be done more simply. For future reference though, should you need to cycle through the columns on a datawindow you can find out how many columns there are using dw_1.Object.DataWindow.Column.Count and then pull the name with something like dw_1.Describe("#" + String(column_number) +".Name") and then change the background property as you were doing before. If you want all the objects in a datawindow (since there is no Control[] array like there is for a window object) you can also pull all the objects in the datawindow control into a string using dw_1.Object.DataWindow.Objects.

That said, I've done this before with a datawindow (no datastore required, but maybe you need it for other reasons too) as well as when I integrate with MS Word but that's a different approach. Not sure specifically how you're inserting your watermark, meaning what kind of object, but I have a DRAFT bmp file that I attach to a picture control that's placed in the background layer of the datawindow and then make the control visible when required. The BMP is created in such a way with the appropriate colour and transparency that there is no changing of the background transparancy setting on any of the datawindow's objects required...it just works as is.  Depending upon the colours used in your report you may need to use different settings than what I use but maybe you can make something like that work for you.

HTH...regards,

Mark

Comment
  1. Stephen BIppen
  2. Thursday, 18 April 2024 21:21 PM UTC
Mark,

If I was starting with a new dataobject, that is exactly what I would do. But unfortunately these are existing, years old, objects and I am trying avoid touching every one of them. Or at least those with nested reports.

Thanks for the suggestion.
  1. Helpful
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Thursday, 18 April 2024 19:42 PM UTC
  2. PowerBuilder
  3. # 2

Hi Stephen ;

  This seems like a lot work to copy & use the Modify() commands to make this work.

What about ( Food for thought ) ...

  1. Make all text & column objects transparent (no colour) but the DW background colour white in the DW Painter
  2. Add the Watermark image in the background layer of the DWO but mark it as invisible.
  3. Then at print time, use the Modify to make the DW Background transparent & make the Watermark visible (use the same DC)
  4. After printing, perform the reverse steps as in #3 (simple)

HTH

Regards .. Chris

Comment
  1. Stephen BIppen
  2. Thursday, 18 April 2024 21:12 PM UTC
Chris,

Thanks for the suggestion, that may ultimately be my only option.

The problem is this involves dozens (and dozens) of potential objects (reports, lists, details, etc.) and I was hoping to avoid modifying each of them. I created my own print function to slap the watermark on the provided Datawindow/Datastore and it's working great - except for anything with a nested report . I may wind up touching those nested dataobjects.
  1. Helpful
  1. Chris Pollach @Appeon
  2. Thursday, 18 April 2024 21:22 PM UTC
Another real easy approach with no Modify's required...

1) Create 2 DWO's - one for user viewing and a duplicate DWO setup for printing.

2) Load the print DWO into a DS

3) Use a ShareData() command to share the buffer from DC's DWO to the DS's DWO.

4) Print the DWO in the DS

5) Turn the ShareData OFF

Food for thought. ;-)

  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.