Hello folks,
I've been trying to get some simple info shown in a job+metadata submit point, in a read-only text field. All I want to do is list the dimensions of all the defined page boxes within the PDF, so the user can then use a dropdown to pick a page box to use as the basis for prepress/preflight.
Of course, I tried using Switch's built-in variables like [Stats.MediaBoxHeight] - these evaluate to an empty string. I'm guessing Switch doesn't look inside the PDF at the submit point stage?
Is there any way to access this info without breaking the workflow into a 2-step submit point → checkpoint process? Possibly through a script expression in the metadata field? I tried a few functions from the scripting guide, but script expressions within fields are quite poorly documented. I'm guessing there aren't any entry points, and trying to use PdfDocument.getPageMediaBoxHeight in a calculateScriptExpression function gives a very helpful nonspecific syntax error.
Any info about this kind of scripting would be appreciated!
View PDF file info within submit point
-
- Newbie
- Posts: 7
- Joined: Mon Mar 13, 2023 6:24 pm
Re: View PDF file info within submit point
Looking at the Switch Reference Guide regarding Defining metadata fields in Submit Points it states:
As to whether Script expressions work, I think that is a no as well. You mentioned using PdfDocument.getPageMediaBoxHeight in a calculateScriptExpression function but those are from Node.js scripting. Node.js Script expression aren't supported in Checkpoints and Submit points.
In Legacy scripting to get the first page of a jobs media box height would look like this:
But similar to when you tried the built-in variables nothing is returned and an error is logged to the Switch messages "The requested statistics are not available for the job '': the job does not exist".
So I think you will need 2-step submit point workflow for this.
So I'm guessing that will be why you aren't getting values returned for built-in variables like [Stats.MediaBoxHeight].Using variables:
It is possible to use variables to define the default value for your metadata field (Single-line text with variables, Condition with variables). However, most variables (e.g. doc author, page height, number of pages, ...) are not suited, as the requested information is only available after the job has been submitted to the Switch Server. At the time of submitting the job, only the variables of the Switch variables group (e.g. date, flow name, server name, ...) are available and can be displayed to the user.
Some examples:
[Job.Size] as default value is invalid; this will result in see "0 bytes" as the job size is unknown as long as the job hasn't been submitted to the Switch Server.
[Switch.Date:TimeZone="UTC"] is valid and will show the current date and time (= the date/time you're using the Switch Web Portal to submit the file).
As to whether Script expressions work, I think that is a no as well. You mentioned using PdfDocument.getPageMediaBoxHeight in a calculateScriptExpression function but those are from Node.js scripting. Node.js Script expression aren't supported in Checkpoints and Submit points.
In Legacy scripting to get the first page of a jobs media box height would look like this:
Code: Select all
(new FileStatistics(job.getPath())).getString("MediaBoxHeight");
So I think you will need 2-step submit point workflow for this.
Re: View PDF file info within submit point
With the Switch API you can create a webpage using different methods that can "see" your PDF file and get the info you ask for before it is sent to the Switch flow.
The values the web page finds can be sent to switch as a Webhook together with the file.
This way you can accomplish what you want and send data to Switch but it is in this case a custom made solution for your webserver.
The values the web page finds can be sent to switch as a Webhook together with the file.
This way you can accomplish what you want and send data to Switch but it is in this case a custom made solution for your webserver.
-
- Newbie
- Posts: 7
- Joined: Mon Mar 13, 2023 6:24 pm
Re: View PDF file info within submit point
Ah well, sounds like I'll need a different solution for this. Thank you mkayyyy and jan_suhr!
- magnussandstrom
- Advanced member
- Posts: 487
- Joined: Thu Jul 30, 2020 6:34 pm
- Location: Sweden
- Contact:
Re: View PDF file info within submit point
This could be a good feature request: https://my2.enfocus.com/en/switch/featurerequeststhepkglab_greg wrote: ↑Tue Mar 11, 2025 9:11 pm Ah well, sounds like I'll need a different solution for this. Thank you mkayyyy and jan_suhr!
We also have flows were this would be useful. Maybe a setting in the Submit point: "Fetch metadata from files before vieweing Checkpoint form".