When working with Pres Connect designer, in my standard script is there a way I can detect through scripting if the current window tab is design or preview mode?
Another follow up question: Does standard script runs on design mode or only in preview mode?
I noticed when I try add a background in the standard script like so
var sourceImg = BackgroundResource.RESOURCE_PDF;
var background = merge.template.contexts.PRINT.sections["Notice"].background;
background.source = sourceImg;
background.allPages = true;
background.url = artwork;
I can see this triggers on design but not in preview. Which is bizarre
Thank in advanced.
Cheers
E
Hi,
why do you need to detect whether you are in design or preview mode? The design and preview modes are only for the user in front of the Designer to work on design or view the result.
As far as I know scripts are only executed in preview mode, so what you describe can actually not happen.
Do you have set a static background pdf to your section? Maybe it only looks like the script result in design mode and in preview mode you cant see anything because your script does not work as expected (cant find the dynamic image/pdf resource)?
I ask this because it has happened to me as well and it took me a while to solve the problem.
Scripts only run in Preview mode (and when generating output). I guess you already have a background image set via the Background property of the respective Section (choose: Section > Background… or right click the section in the Resources panel and choose Background…). This background image is shown in Design mode as it is static resource.
At first thats what I initially thought ,that the script only runs on preview mode. For some reason, that code above is what I have in the standard script… Mind you I dont have any static background set, and surprise that it displayed the background in design but not in preview. Then I commented out the code , the background disappeared. I toggled back and forth to make sure that Im not seeing things.
Feels like its the other way around, might be a bug? The rest works as normal though.
As to why I wanted to detect it in design mode you ask? The gist of it is , Im migrating a job from another system to Pres Connect. I already have finished samples. The job Im doing require variable background PDF for each record. I wanted to set the sample pdf as a background with 30% transparency so I can place each elements to their right position easily. Since the background is dynamic in design I want it to change as I change to another record. But in preview mode I want it to remove that sample background but be replaced with the real artwork.
Strange behavior but I was able to recreate it. You have to use the code in a control script not in a standard script.
I’m very surprised that the code in the standard script produces this behavior, and I’m pretty sure it didn’t behave this way in older Connect versions.
So after changing the script type it should work as you need it. In design mode the static background pdf is displayed (only with the placeholders not the data field contents) and in preview mode the dynamic pdf will be shown.
@edanting, @thomasweber, Could you let us know please in which version of PReS Connect (or PlanetPress Connect) you are facing this issue?
Hereby I would like to inform you that I was able to reproduce the issue in the latest version of PReS Connect and that I have shared the issue internally [internal reference: SHARED-88811].