diff --git a/docs/FormEditor/forms.md b/docs/FormEditor/forms.md index f1baf1fedab113..360518bda2d52d 100644 --- a/docs/FormEditor/forms.md +++ b/docs/FormEditor/forms.md @@ -67,13 +67,14 @@ You can add or modify 4D forms using the following elements: } ``` + ## Using forms Forms are called using specific commands of the 4D Language. In your 4D desktop applications, forms can be used in various ways, depending on their status within your interface needs. A form can be: - used in its own window for data viewing, processing, editing, or to display on-screen information to the user, -- used as template for printing, - used embedded in another form (subform), +- used as template for printing, - or called by specific features like the Label editor. @@ -154,6 +155,10 @@ In the same way that you pass an object to a form with the [`DIALOG`](../command ### Using forms to be printed +In 4D desktop applications, forms can be printed using the various [commands of the **Printing** theme](../commands/theme/Printing). + +#### Examples + You can use forms to print data, either as page or as list. - To simply print some part of a form, use the [`Print form`](../commands/print-form) command. For example: @@ -190,6 +195,46 @@ var $h:=Print form("Request_var";$formData;Form detail) FORM UNLOAD CLOSE PRINTING JOB ``` + + +#### Print rendering engine + +4D uses a dedicated print rendering engine to generate outputs with a design adapted for printing. It includes the following main features: + +- Interactive widgets such as buttons, toggles, dropdowns, etc. and modern UI effects such as glass, blur, transparency, or shadow effects are converted into adapted static representations and flattened into printable styles, so that the document remains readable and professional once printed. +- Layout structure, spacing, and alignment, are preserved so that the printed document reflects the logical structure of the on-screen form. +- The same output is produced, whether the form is printed from macOS or Windows. + +For example, the following form: + +![](../assets/en/FormEditor/screen_rendering.png) + +... will be printed with this rendering: + +![](../assets/en/FormEditor/print_rendering.png) + + +:::tip Related blog post + +[Printing Modern Interfaces with Clean, Consistent Output](https://blog.4d.com/printing-modern-interfaces-with-clean-consistent-output) + +::: + +#### Legacy print renderer + +In releases prior to 4D 21 R3, another print renderer was used. This legacy renderer simply draws widgets as they appear on the screen. For compatibility, the legacy renderer is **enabled by default** in projects or databases converted from versions prior to 4D 21 R3, so that forms designed with this renderer continue to be printed as expected. + +You can however enable the modern print rendering engine at any moment by: + +- unchecking the **Use legacy print rendering** option in the [Compatibility page of the Settings dialog box](../settings/compatibility.md) (permanent setting), +- or executing [`SET DATABASE PARAMETER`](../commands/set-database-parameter) command with `Use legacy print rendering` selector set to 1 (volatile setting). + +:::warning Limitation + +For technical reasons, the legacy print renderer is not available with forms displayed with [Fluent UI](#fluent-ui-rendering) on Windows or [Liquid Glass](../Notes/updates.md#support-of-liquid-glass-on-macos) on macOS. In these contexts, forms are **always printed with the modern print rendering engine**, whatever the compatibility option. + +::: + ### Other form usages @@ -213,7 +258,7 @@ Typically, you select the form category when you create the form, but you can ch ## Form pages -Each form has is made of at least two pages: +Each form is made of at least two pages: - a page 1: a main page, displayed by default - a page 0: a background page, whose contents is displayed on every other page. @@ -232,6 +277,8 @@ There are no restrictions on the number of pages a form can have. The same field A multi-page form has both a background page and several display pages. Objects that are placed on the background page may be visible on all display pages, but can be selected and edited only on the background page. In multi-page forms, you should put your button palette on the background page. You also need to include one or more objects on the background page that provide page navigation tools for the user. + + ## Fluent UI rendering :::caution Developer Preview diff --git a/docs/FormEditor/properties_Print.md b/docs/FormEditor/properties_Print.md index c20aa5d482156b..e620e35724bc5d 100644 --- a/docs/FormEditor/properties_Print.md +++ b/docs/FormEditor/properties_Print.md @@ -8,7 +8,7 @@ title: Print Allows defining specific print settings for the form. This feature is useful to view printing page limits in the form editor. -> **Compatibility:** Even if these settings are taken into account when the form is printed in Application mode, it is discouraged to rely on this feature to store print settings for the form, due to limitations regarding the platform and driver dependency. It is highly recommended to use the 4D commands `Print settings to BLOB`/`BLOB to print settings` which are more powerful. +> **Compatibility:** Even if these settings are taken into account when the form is printed in Application mode, it is discouraged to rely on this feature to store print settings for the form, due to limitations regarding the platform and driver dependency. It is highly recommended to use the 4D commands [`Print settings to BLOB`](../commands/print-settings-to-blob)/[`BLOB to print settings`](../commands/blob-to-print-settings) which are more powerful. You can modify the following print settings: diff --git a/docs/Notes/updates.md b/docs/Notes/updates.md index 95ae76d4fac791..d559cde17643c6 100644 --- a/docs/Notes/updates.md +++ b/docs/Notes/updates.md @@ -18,6 +18,7 @@ Read [**What’s new in 4D 21 R3**](https://blog.4d.com/whats-new-in-4d-21-r3/), - New [**AI** page in Settings](../settings/ai.md), allowing to configure [Provider model aliases](../aikit/provider-model-aliases.md) that can be called in the code using 4D AIKit component. - 4D AIKit component: new [Providers](../aikit/Classes/OpenAIProviders.md) class to instantiate and handle [Provider and model aliases](../aikit/provider-model-aliases.md). - Support of [`server` keyword](../Concepts/classes.md#server) for ORDA data model functions and shared/session singleton functions. +- New [printing renderer](../FormEditor/forms.md#print-rendering-engine) for forms on Liquid glass and Fluent UI interfaces. New compatibility options to [enable the renderer on Classic interfaces](../FormEditor/forms.md#legacy-print-renderer). - Dependencies: support of [components stored on GitLab repositories](../Project/components.md#configuring-a-gitlab-repository). - [**Fixed bug list**](https://bugs.4d.fr/fixedbugslist?version=21_R3): list of all bugs that have been fixed in 4D 21 R3. diff --git a/docs/assets/en/FormEditor/print_rendering.png b/docs/assets/en/FormEditor/print_rendering.png new file mode 100644 index 00000000000000..d2a28e9dda474d Binary files /dev/null and b/docs/assets/en/FormEditor/print_rendering.png differ diff --git a/docs/assets/en/FormEditor/screen_rendering.png b/docs/assets/en/FormEditor/screen_rendering.png new file mode 100644 index 00000000000000..b219623b061d96 Binary files /dev/null and b/docs/assets/en/FormEditor/screen_rendering.png differ diff --git a/docs/assets/en/commands/form-print1.png b/docs/assets/en/commands/form-print1.png new file mode 100644 index 00000000000000..7cbec84055b1d3 Binary files /dev/null and b/docs/assets/en/commands/form-print1.png differ diff --git a/docs/assets/en/commands/form-print2.png b/docs/assets/en/commands/form-print2.png new file mode 100644 index 00000000000000..d78a6f5f3c1a48 Binary files /dev/null and b/docs/assets/en/commands/form-print2.png differ diff --git a/docs/assets/en/commands/print-selection1.png b/docs/assets/en/commands/print-selection1.png new file mode 100644 index 00000000000000..95e6603575d8a3 Binary files /dev/null and b/docs/assets/en/commands/print-selection1.png differ diff --git a/docs/assets/en/commands/print-selection2.png b/docs/assets/en/commands/print-selection2.png new file mode 100644 index 00000000000000..5b09f52d9fa16c Binary files /dev/null and b/docs/assets/en/commands/print-selection2.png differ diff --git a/docs/language-legacy/4D Environment/get-database-parameter.md b/docs/language-legacy/4D Environment/get-database-parameter.md index 504871add223f1..e0e6a41d8d2626 100644 --- a/docs/language-legacy/4D Environment/get-database-parameter.md +++ b/docs/language-legacy/4D Environment/get-database-parameter.md @@ -23,7 +23,7 @@ displayed_sidebar: docs |Release|Changes| |---|---| -|21 R3|Removed support of *Use legacy network layer*| +|21 R3|Removed support of *Use legacy network layer*, added *Use legacy print rendering*| |20 R6|Modified| |19 R5|Modified| |16 R4|Modified| @@ -1428,6 +1428,15 @@ In previous releases, time values were converted and stored as number of millise Note that this parameter sets all 4D tips, i.e. form help messages and Design mode editor's tips. +### Use legacy print rendering (136) + +**Scope:** 4D application + +**Kept between two sessions:** No + +**Possible values:** 0 = legacy print rendering disabled, 1 = legacy print rendering enabled + +**Description:** Sets or gets the current status of the [legacy print renderer](../../FormEditor/forms.md#legacy-print-rendering) on macOS or Windows. When the legacy print renderer is *disabled*, 4D’s [modern print rendering engine](../../FormEditor/forms.md) is used. Note that when forms are rendered under Liquid Glass (macOS) or Fluent UI (Windows) interfaces, this selector is ignored (in such contexts forms are always printed using the modern print renderer, see [this section](../../FormEditor/forms.md#legacy-print-rendering)). In converted projects, this parameter can also be set permanently using a [compatibility setting](../../settings/compatibility.md). diff --git a/docs/language-legacy/4D Environment/set-database-parameter.md b/docs/language-legacy/4D Environment/set-database-parameter.md index 643a6609541ec3..8123a5d0ca4297 100644 --- a/docs/language-legacy/4D Environment/set-database-parameter.md +++ b/docs/language-legacy/4D Environment/set-database-parameter.md @@ -22,7 +22,7 @@ displayed_sidebar: docs |Release|Changes| |---|---| -|21 R3|Removed support of *Use legacy network layer*| +|21 R3|Removed support of *Use legacy network layer*, added *Use legacy print rendering* | |20 R6|Modified| |20 R3|Modified| |19 R5|Modified| @@ -1035,6 +1035,15 @@ In previous releases, time values were converted and stored as number of millise Note that this parameter sets all 4D tips, i.e. form help messages and Design mode editor's tips. +### Use legacy print rendering (136) + +**Scope:** 4D application + +**Kept between two sessions:** No + +**Possible values:** 0 = legacy print rendering disabled, 1 = legacy print rendering enabled + +**Description:** Sets or gets the current status of the [legacy print renderer](../../FormEditor/forms.md#legacy-print-rendering) on macOS or Windows. When the legacy print renderer is *disabled*, 4D’s [modern print rendering engine](../../FormEditor/forms.md) is used. Note that when forms are rendered under Liquid Glass (macOS) or Fluent UI (Windows) interfaces, this selector is ignored (in such contexts forms are always printed using the modern print renderer, see [this section](../../FormEditor/forms.md#legacy-print-rendering)). In converted projects, this parameter can also be set permanently using a [compatibility setting](../../settings/compatibility.md). ### User param value (108) @@ -1047,7 +1056,9 @@ In previous releases, time values were converted and stored as number of millise **Description:** Custom string passed from one session to the next one when the 4D application is restarted. This selector is useful in the context of automated unit tests that require applications to restart with different parameters. -When used with [SET DATABASE PARAMETER](../commands/set-database-parameter), defines a new value that will be available within the next opened database after 4D is restarted manually or using the [OPEN DATABASE](../commands/open-database)(\*), [OPEN DATA FILE](../commands/open-data-file), or [RESTART 4D](../commands/restart-4d) commands. When used with [Get database parameter](../commands/get-database-parameter), gets the currently available user parameter value, defined using a command line (see *Command Line Interface*), the .4DLink file (see *Using a 4DLink file*), or a call to [SET DATABASE PARAMETER](../commands/set-database-parameter) during the previous session. (\*) If [SET DATABASE PARAMETER](../commands/set-database-parameter) sets a User param value before a call to [OPEN DATABASE](../commands/open-database) with a .4DLink file that also contains a user-param xml attribute, 4D takes into account only the parameter provided by [SET DATABASE PARAMETER](../commands/set-database-parameter). +When used with [SET DATABASE PARAMETER](../commands/set-database-parameter), defines a new value that will be available within the next opened database after 4D is restarted manually or using the [OPEN DATABASE](../commands/open-database)(\*), [OPEN DATA FILE](../commands/open-data-file), or [RESTART 4D](../commands/restart-4d) commands. When used with [Get database parameter](../commands/get-database-parameter), gets the currently available user parameter value, defined using a command line (see [Command Line Interface](../../Admin/cli.md)), the .4DLink file (see [Using a 4DLink file](../../GettingStarted/creating.md#opening-a-project-with-a-4dlink-file)), or a call to [SET DATABASE PARAMETER](../commands/set-database-parameter) during the previous session. + +(\*) If [SET DATABASE PARAMETER](../commands/set-database-parameter) sets a User param value before a call to [OPEN DATABASE](../commands/open-database) with a .4DLink file that also contains a user-param xml attribute, 4D takes into account only the parameter provided by [SET DATABASE PARAMETER](../commands/set-database-parameter). diff --git a/docs/language-legacy/Printing/print-form.md b/docs/language-legacy/Printing/print-form.md index 9bca02115665c2..17539ff363293f 100644 --- a/docs/language-legacy/Printing/print-form.md +++ b/docs/language-legacy/Printing/print-form.md @@ -34,7 +34,9 @@ displayed_sidebar: docs ## Description -The **Print form** command simply prints *form* with the current values of fields and variables of *aTable*. It is usually used to print very complex reports that require complete control over the printing process. **Print form** does not do any record processing, break processing or page breaks. These operations are your responsibility. **Print form** prints fields and variables in a fixed size frame only. +The **Print form** command simply prints *form* with the current values of fields and variables of *aTable*. It is usually used to print very complex reports that require complete control over the printing process. + +**Print form** does not do any record processing, break processing or page breaks. These operations are your responsibility. In the *form* parameter, you can pass: @@ -44,9 +46,11 @@ In the *form* parameter, you can pass: Since **Print form** does not issue a page break after printing the form, it is easy to combine different forms on the same page. Thus, **Print form** is perfect for complex printing tasks that involve different tables and different forms. To force a page break between forms, use the [PAGE BREAK](../commands/page-break) command. In order to carry printing over to the next page for a form whose height is greater than the available space, call the [CANCEL](../commands/cancel) command before the [PAGE BREAK](../commands/page-break) command. +### Syntaxes + Three different syntaxes may be used: -* **Detail area printing** +#### Detail area printing Syntax: @@ -56,7 +60,7 @@ Syntax: In this case, **Print form** only prints the Detail area (the area between the Header line and the Detail line) of the form. -* **Form area printing** +#### Form area printing Syntax: @@ -92,7 +96,7 @@ In this case, the command will print the section designated by the *marker*. Pas | Form header8 | Integer | 208 | | Form header9 | Integer | 209 | -* **Section printing** +#### Section printing Syntax: @@ -102,37 +106,50 @@ Syntax: In this case, the command will print the section included between the *areaStart* and *areaEnd* parameters. The values entered must be expressed in pixels. -**formData** +#### formData Optionally, you can pass parameters to the *form* using either the *formData* object or the form class object automatically instantiated by 4D if you have [associated a user class to the form](../../FormEditor/properties_FormProperties.md#form-class). Any properties of the form data object will then be available from within the form context through the [Form](../commands/form) command. The form data object is available in the [`On Printing Detail` form event](../../Events/onPrintingDetail.md). For detailed information on the form data object, please refer to the [`DIALOG`](../commands/dialog) command. -**Return value** +#### Return value The value returned by **Print form** indicates the height of the printable area. This value will be automatically taken into account by the [Get printed height](../commands/get-printed-height) command. + +### Print settings + The printer dialog boxes do not appear when you use **Print form**. The report does not use the print settings that were assigned to the form in the Design environment. There are two ways to specify the print settings before issuing a series of calls to **Print form**: * Call [PRINT SETTINGS](../commands/print-settings). In this case, you let the user choose the settings. * Call [SET PRINT OPTION](../commands/set-print-option) and [GET PRINT OPTION](../commands/get-print-option). In this case, print settings are specified programmatically. +### Page breaks + **Print form** builds each printed page in memory. Each page is printed when the page in memory is full or when you call [PAGE BREAK](../commands/page-break). To ensure the printing of the last page after any use of **Print form**, you must conclude with the [PAGE BREAK](../commands/page-break) command (except in the context of an [OPEN PRINTING JOB](../commands/open-printing-job), see note). Otherwise, if the last page is not full, it stays in memory and is not printed. **Warning:** If the command is called in the context of a printing job opened with [OPEN PRINTING JOB](../commands/open-printing-job), you must NOT call [PAGE BREAK](../commands/page-break) for the last page because it is automatically printed by the [CLOSE PRINTING JOB](../commands/close-printing-job) command. If you call [PAGE BREAK](../commands/page-break) in this case, a blank page is printed. -This command prints external areas and objects (for example, 4D Write or 4D View areas). The area is reset for each execution of the command. +### Support of form events and form objects -**Warning:** Subforms are not printed with **Print form**. To print only one form with such objects, use [PRINT RECORD](../commands/print-record) instead. +**Print form** only generates the [`On Printing Detail` event](../../Events/onPrintingDetail.md) in the form method. -**Print form** generates only one [`On Printing Detail` event](../../Events/onPrintingDetail.md) for the form method. +**Print form** prints fields and variables in a [fixed size frame](../../FormObjects/properties_Print.md#print-frame) only. -**4D Server:** This command can be executed on 4D Server within the framework of a stored procedure. In this context: +**Print form** prints external areas and objects (for example, 4D Write or 4D View areas). The area is reset for each execution of the command. + +[Subforms](../../FormObjects/subform_overview.md) are not printed with **Print form**. To print only one form with such objects, use [PRINT RECORD](../commands/print-record) instead. + +:::note 4D Server + +This command can be executed on 4D Server within the framework of a stored procedure. In this context: * Make sure that no dialog box appears on the server machine (except for a specific requirement). * In the case of a problem concerning the printer (out of paper, printer disconnected, etc.), no error message is generated. +::: + ## Example 1 The following example performs as a [PRINT SELECTION](../commands/print-selection) command would. However, the report uses one of two different forms, depending on whether the record is for a check or a deposit: @@ -190,6 +207,78 @@ The code that calls the dialog then prints its body:  $h:=Print form("Request_var";$formData;Form detail) ``` +## Example 4 + +You want to print a report with data coming from an entity selection (ORDA) in a project form, using breaks and subtotals. + +The form template is the following: + +![](../../assets/en/commands/form-print1.png) + +The method that calls the form: + +```4d +var $es : cs.SalesSelection +var $e : cs.SalesEntity + +$es:=ds.Sales.all().orderBy("Region asc, Seller asc") +$breakRegion:="" +$breakSeller:="" + + +// Global report header (printed once) +Print form("testPrintForm1"; $e; Form header) +For each ($e; $es) + + // Region break (level 1): close previous seller and region totals, then open new region + If ($breakRegion#$e.Region) + If ($breakRegion#"") + Print form("testPrintForm1"; {totalQuantity: $filteredSeller.sum("Quantity"); totalPrice: $filteredSeller.sum("UnitPrice")}; Form break2) + Print form("testPrintForm1"; {totalQuantity: $filtered.sum("Quantity"); totalPrice: $filtered.sum("UnitPrice")}; Form break1) + End if + $breakRegion:=$e.Region + // Reset seller break so header2 is printed for first seller in this region + $breakSeller:="" + $filtered:=$es.query("Region=:1"; $breakRegion) + Print form("testPrintForm1"; {Region: $e.Region}; Form header1) + End if + + // Seller break (level 2) inside current region + If (($breakSeller#$e.Seller)) + If ($breakSeller#"") + Print form("testPrintForm1"; {totalQuantity: $filteredSeller.sum("Quantity"); totalPrice: $filteredSeller.sum("UnitPrice")}; Form break2) + End if + $breakSeller:=$e.Seller + // Seller subtotal must be scoped by Region + Seller + $filteredSeller:=$es.query("Region=:1 and Seller=:2"; $breakRegion; $breakSeller) + Print form("testPrintForm1"; {Seller: $e.Seller}; Form header2) + End if + + + // Detail line + Print form("testPrintForm1"; $e; Form detail) +End for each + +// Close the last seller and region groups after loop +Print form("testPrintForm1"; {totalQuantity: $filteredSeller.sum("Quantity"); totalPrice: $filteredSeller.sum("UnitPrice")}; Form break2) +Print form("testPrintForm1"; {totalQuantity: $filtered.sum("Quantity"); totalPrice: $filtered.sum("UnitPrice")}; Form break1) + +// Grand totals for the full selection +Print form("testPrintForm1"; \ +{totalQuantity: $es.sum("Quantity"); totalPrice: $es.sum("UnitPrice"); \ +minQuantity: $es.min("Quantity"); minPrice: $es.min("UnitPrice"); \ +maxQuantity: $es.max("Quantity"); maxPrice: $es.max("UnitPrice")}; \ +Form break0) + +// Global report footer (printed once) +Print form("testPrintForm1"; $e; Form footer) +``` + +The resulting printed report: + +![](../../assets/en/commands/form-print2.png) + + ## See also [CANCEL](../commands/cancel) diff --git a/docs/language-legacy/Printing/print-selection.md b/docs/language-legacy/Printing/print-selection.md index 21d9038a0823e1..cdb67cdb61b56e 100644 --- a/docs/language-legacy/Printing/print-selection.md +++ b/docs/language-legacy/Printing/print-selection.md @@ -49,16 +49,25 @@ You can check whether **PRINT SELECTION** is printing the first header by testin To print a sorted selection with subtotals or breaks using **PRINT SELECTION**, you must first sort the selection. Then, in each Break area of the report, include a variable with an object method that assigns the subtotal to the variable. You can also use statistical and arithmetical functions like [Sum](../commands/sum) and [Average](../commands/average) to assign values to variables. For more information, see the descriptions of [Subtotal](../commands/subtotal), [BREAK LEVEL](../commands/break-level) and [ACCUMULATE](../commands/accumulate). -**Warning:** Do not use the [PAGE BREAK](../commands/page-break) command with the **PRINT SELECTION** command. [PAGE BREAK](../commands/page-break) is to be used with the [Print form](../commands/print-form) command. +:::warning + + Do not use the [PAGE BREAK](../commands/page-break) command with the **PRINT SELECTION** command. [PAGE BREAK](../commands/page-break) is to be used with the [Print form](../commands/print-form) command. + +::: After a call to **PRINT SELECTION**, the OK variable is set to 1 if the printing has been completed. If the printing was interrupted, the OK variable is set to 0 (zero) (i.e., the user clicked Cancel in the printing dialog box). -**4D Server:** This command can be executed on 4D Server in a stored procedure. In this context: +:::note 4D Server + +This command can be executed on 4D Server in a stored procedure. In this context: * Make sure that no dialog box appears on the server machine (except for a specific requirement). To do this, it is necessary to call the command with the *\** or *\>* parameter. * In the case of a problem concerning the printer (out of paper, printer disconnected, etc.), no error message is generated. -## Example +::: + + +## Example 1 The following example selects all the records in the \[People\] table. It then uses the [DISPLAY SELECTION](../commands/display-selection) command to display the records and allows the user to highlight the records to print. Finally, it uses the selected records with the [USE SET](../commands/use-set) command, and prints them with **PRINT SELECTION**: @@ -69,11 +78,54 @@ The following example selects all the records in the \[People\] table. It then u  PRINT SELECTION([People]) // Print the records that the user picked ``` +## Example 2 + +You want to print a report with breaks and subtotals, using the following form template: + +![](../../assets/en/commands/print-selection1.png) + +The method called to build the report: + +```4d +ALL RECORDS([Sales]) +ORDER BY([Sales]Region; <; [Sales]Seller; <) +BREAK LEVEL(2) +ACCUMULATE([Sales]Quantity; [Sales]UnitPrice) +PRINT SELECTION([Sales]) +``` + +In the form method, you calculate the subtotal values thanks to the built-in **PRINT SELECTION** command features, i.e. values processed in the `On printing break` event can be directly evaluated by [`Subtotal`](../commands/subtotal): + +```4d + //form method +Case of + : (FORM Event.code=On Printing Break) + vBreak:=[Sales]Region + //Subtotal uses currently processed values + //it can be used in break variables + vTotalQuantity:=Subtotal([Sales]Quantity) + vTotalPrice:=Subtotal([Sales]UnitPrice) + + //Min and Max use current selection + //they are valid at the final break + vMinQuantity:=Min([Sales]Quantity) + vMinPrice:=Min([Sales]UnitPrice) + vMaxQuantity:=Max([Sales]Quantity) + vMaxPrice:=Max([Sales]UnitPrice) +End case +``` + +The resulting printed report: + +![](../../assets/en/commands/print-selection2.png) + + ## See also [ACCUMULATE](../commands/accumulate) [BREAK LEVEL](../commands/break-level) [Level](../commands/level) +[Print form](../commands/print-form) [Subtotal](../commands/subtotal) ## Properties diff --git a/docs/settings/compatibility.md b/docs/settings/compatibility.md index 2706580697dde2..97911b86883795 100644 --- a/docs/settings/compatibility.md +++ b/docs/settings/compatibility.md @@ -5,23 +5,29 @@ title: Compatibility page The Compatibility page groups together parameters related to maintaining compatibility with previous versions of 4D. -> The number of options displayed depends on the version of 4D with which the original database/project was created, as well as the settings modified in this database/project. -> This page lists the compatibility options available for database/projects converted from 4D v18 onwards. For older compatibility options, refer to the [Compatibility page](https://doc.4d.com/4Dv20/4D/20.2/Compatibility-page.300-6750362.en.html) on **doc.4d.com**. +:::note +- The number of options displayed depends on the version of 4D with which the original database/project was created, as well as the settings modified in this database/project. +- This page lists the compatibility options available for database/projects converted from 4D 18 onwards. For older compatibility options, refer to the [Compatibility page](https://doc.4d.com/4Dv20/4D/20.2/Compatibility-page.300-6750362.en.html) on **doc.4d.com**. -- **Use standard XPath:** By default this option is unchecked for databases converted from a 4D version prior to v18 R3, and checked for databases created with 4D v18 R3 and higher. Starting with v18 R3, the XPath implementation in 4D has been modified to be more compliant and to support more predicates. As a consequence, non-standard features of the previous implementation no longer work. They include: +::: + + +- **Use standard XPath:** By default this option is unchecked for databases converted from a 4D version prior to 18 R3, and checked for databases created with 4D 18 R3 and higher. Starting with 18 R3, the XPath implementation in 4D has been modified to be more compliant and to support more predicates. As a consequence, non-standard features of the previous implementation no longer work. They include: * initial "/" is not the root node only - using a / as first character in a XPath expression does not declare an absolute path from the root node * no implicit current node - the current node has to be included in the XPath expression * no recursive searches in repeated structures - only the first element is parsed.\ Although not standard, you might want to keep using these features so that your code continues to work as before -- in this case, just set the option *unchecked*. On the other hand, if your code does not rely on the non-standard implementation and if you want to benefit from the extended XPath features in your databases (as described in the [`DOM Find XML element`](../commands/dom-find-xml-element) command), make sure the **Use standard XPath** option is *checked*. -- **Use LF for end of line on macOS:** Starting with 4D v19 R2 (and 4D v19 R3 for XML files), 4D writes text files with line feed (LF) as default end of line (EOL) character instead of CR (CRLF for xml SAX) on macOS in new projects. If you want to benefit from this new behavior on projects converted from previous 4D versions, check this option. See [`TEXT TO DOCUMENT`](../commands/text-to-document), [`Document to text`](../commands/document-to-text), and [XML SET OPTIONS](../commands/xml-set-options). +- **Use LF for end of line on macOS:** Starting with 4D 19 R2 (and 4D 19 R3 for XML files), 4D writes text files with line feed (LF) as default end of line (EOL) character instead of CR (CRLF for xml SAX) on macOS in new projects. If you want to benefit from this new behavior on projects converted from previous 4D versions, check this option. See [`TEXT TO DOCUMENT`](../commands/text-to-document), [`Document to text`](../commands/document-to-text), and [XML SET OPTIONS](../commands/xml-set-options). + +- **Don't add a BOM when writing a unicode text file by default:** Starting with 4D 19 R2 (and 4D 19 R3 for XML files), 4D writes text files without a byte order mark (BOM) by default. In previous versions, text files were written with a BOM by default. Select this option if you want to enable the new behavior in converted projects. See [`TEXT TO DOCUMENT`](../commands/text-to-document), [`Document to text`](../commands/document-to-text), and [XML SET OPTIONS](../commands/xml-set-options). -- **Don't add a BOM when writing a unicode text file by default:** Starting with 4D v19 R2 (and 4D v19 R3 for XML files), 4D writes text files without a byte order mark (BOM) by default. In previous versions, text files were written with a BOM by default. Select this option if you want to enable the new behavior in converted projects. See [`TEXT TO DOCUMENT`](../commands/text-to-document), [`Document to text`](../commands/document-to-text), and [XML SET OPTIONS](../commands/xml-set-options). +- **Map NULL values to blank values unchecked by default at field creation**: For better compliance with ORDA specifications, in databases created with 4D 19 R4 and higher the **Map NULL values to blank values** field property is unchecked by default when you create fields. You can apply this default behavior to your converted databases by checking this option (working with Null values is recommended since they are fully supported by [ORDA](../ORDA/overview.md). -- **Map NULL values to blank values unchecked by default a field creation**: For better compliance with ORDA specifications, in databases created with 4D v19 R4 and higher the **Map NULL values to blank values** field property is unchecked by default when you create fields. You can apply this default behavior to your converted databases by checking this option (working with Null values is recommended since they are fully supported by [ORDA](../ORDA/overview.md). +- **Non-blocking printing**: Starting with 4D 20 R4, each process has its own printing settings (print options, current printer, etc.), thus allowing you to run multiple printing jobs simultaneously. Check this option if you want to benefit from this new implementation in your converted 4D projects or your databases converted from binary mode to project mode. **When left unchecked**, the previous implementation is applied: the current 4D printing settings are applied globally, the printer is placed in "busy" mode when one printing job is running, you must call [`CLOSE PRINTING JOB`](../commands/close-printing-job) for the printer to be available for the next print job (check previous 4D documentations for more information). -- **Non-blocking printing**: Starting with 4D v20 R4, each process has its own printing settings (print options, current printer, etc.), thus allowing you to run multiple printing jobs simultaneously. Check this option if you want to benefit from this new implementation in your converted 4D projects or databases converted from binary mode to project mode. **When left unchecked**, the previous implementation is applied: the current 4D printing settings are applied globally, the printer is placed in "busy" mode when one printing job is running, you must call `CLOSE PRINTING JOB` for the printer to be available for the next print job (check previous 4D documentations for more information). +- **Save structure color and coordinates in separate catalog_editor.json file**: Starting with 4D 20 R5, changes made in the Structure editor regarding graphical appearance of tables and fields (color, position, order...) are saved in a separate file named `catalog_editor.json`, stored in the project's [Sources folder](../Project/architecture.md#sources). This new file architecture makes it easier to manage merge conflicts in VCS applications since the `catalog.4DCatalog` file now contains only crucial database structure changes. For compatibility reasons, this feature is not enabled by default in projects converted from previous 4D versions, you need to check this option. When the feature is enabled, the `catalog_editor.json` file is created at the first modification in the Structure editor. -- **Save structure color and coordinates in separate catalog_editor.json file**: Starting with 4D v20 R5, changes made in the Structure editor regarding graphical appearance of tables and fields (color, position, order...) are saved in a separate file named `catalog_editor.json`, stored in the project's [Sources folder](../Project/architecture.md#sources). This new file architecture makes it easier to manage merge conflicts in VCS applications since the `catalog.4DCatalog` file now contains only crucial database structure changes. For compatibility reasons, this feature is not enabled by default in projects converted from previous 4D versions, you need to check this option. When the feature is enabled, the `catalog_editor.json` file is created at the first modification in the Structure editor. +- **Use legacy print rendering**: Starting with 4D 21 R3, 4D uses a new, unified print rendering engine to print forms on macOS and Windows. To make sure forms designed with the [legacy screen-based print renderer](../FormEditor/forms.md#legacy-print-renderer) continue to be printed as expected, this option is checked by default in converted projects or databases created with 4D 21 R2 and before. You can uncheck this option to benefit from the [modern print rendering engine](../FormEditor/forms.md#print-rendering-engine). Note that when forms are rendered under Liquid Glass (macOS) or Fluent UI (Windows) interfaces, this option is ignored: in such contexts forms are always printed using the modern print renderer (see [this section](../../FormEditor/forms.md#legacy-print-rendering)). \ No newline at end of file diff --git a/versioned_docs/version-21-R3/FormEditor/forms.md b/versioned_docs/version-21-R3/FormEditor/forms.md index 22df991dd74b48..b756749a41d5a6 100644 --- a/versioned_docs/version-21-R3/FormEditor/forms.md +++ b/versioned_docs/version-21-R3/FormEditor/forms.md @@ -67,6 +67,50 @@ You can add or modify 4D forms using the following elements: } ``` +## Printing forms + +In 4D desktop applications, forms can be printed using the various [commands of the **Printing** theme](../commands/theme/Printing). + +### Print rendering engine + +4D uses a dedicated print rendering engine to generate outputs with a design adapted for printing. It includes the following main features: + +- Interactive widgets such as buttons, toggles, dropdowns, etc. and modern UI effects such as glass, blur, transparency, or shadow effects are converted into adapted static representations and flattened into printable styles, so that the document remains readable and professional once printed. +- Layout structure, spacing, and alignment, are preserved so that the printed document reflects the logical structure of the on-screen form. +- The same output is produced, whether the form is printed from macOS or Windows. + +For example, the following form: + +![](../assets/en/FormEditor/screen_rendering.png) + +... will be printed with this rendering: + +![](../assets/en/FormEditor/print_rendering.png) + + +:::tip Related blog post + +[Printing Modern Interfaces with Clean, Consistent Output](https://blog.4d.com/printing-modern-interfaces-with-clean-consistent-output) + +::: + +### Legacy print renderer + +In releases prior to 4D 21 R3, another print renderer was used. This legacy renderer simply draws widgets as they appear on the screen. For compatibility, the legacy renderer is **enabled by default** in projects or databases converted from versions prior to 4D 21 R3, so that forms designed with this renderer continue to be printed as expected. + +You can however enable the modern print rendering engine at any moment by: + +- unchecking the **Use legacy print rendering** option in the [Compatibility page of the Settings dialog box](../settings/compatibility.md) (permanent setting), +- or executing [`SET DATABASE PARAMETER`](../commands/set-database-parameter) command with `Use legacy print rendering` selector set to 1 (volatile setting). + +:::warning Limitation + +For technical reasons, the legacy print renderer is not available with forms displayed with [Fluent UI](#fluent-ui-rendering) on Windows or [Liquid Glass](../Notes/updates.md#support-of-liquid-glass-on-macos) on macOS. In these contexts, forms are **always printed with the modern print rendering engine**, whatever the compatibility option. + +::: + + + ## Project form and Table form There are two categories of forms: @@ -79,7 +123,7 @@ Typically, you select the form category when you create the form, but you can ch ## Form pages -Each form has is made of at least two pages: +Each form is made of at least two pages: - a page 1: a main page, displayed by default - a page 0: a background page, whose contents is displayed on every other page. @@ -98,6 +142,8 @@ There are no restrictions on the number of pages a form can have. The same field A multi-page form has both a background page and several display pages. Objects that are placed on the background page may be visible on all display pages, but can be selected and edited only on the background page. In multi-page forms, you should put your button palette on the background page. You also need to include one or more objects on the background page that provide page navigation tools for the user. + + ## Fluent UI rendering :::caution Developer Preview diff --git a/versioned_docs/version-21-R3/Notes/updates.md b/versioned_docs/version-21-R3/Notes/updates.md index 6cb1588fc85486..d559cde17643c6 100644 --- a/versioned_docs/version-21-R3/Notes/updates.md +++ b/versioned_docs/version-21-R3/Notes/updates.md @@ -18,6 +18,7 @@ Read [**What’s new in 4D 21 R3**](https://blog.4d.com/whats-new-in-4d-21-r3/), - New [**AI** page in Settings](../settings/ai.md), allowing to configure [Provider model aliases](../aikit/provider-model-aliases.md) that can be called in the code using 4D AIKit component. - 4D AIKit component: new [Providers](../aikit/Classes/OpenAIProviders.md) class to instantiate and handle [Provider and model aliases](../aikit/provider-model-aliases.md). - Support of [`server` keyword](../Concepts/classes.md#server) for ORDA data model functions and shared/session singleton functions. +- New [printing renderer](../FormEditor/forms.md#print-rendering-engine) for forms on Liquid glass and Fluent UI interfaces. New compatibility options to [enable the renderer on Classic interfaces](../FormEditor/forms.md#legacy-print-renderer). - Dependencies: support of [components stored on GitLab repositories](../Project/components.md#configuring-a-gitlab-repository). - [**Fixed bug list**](https://bugs.4d.fr/fixedbugslist?version=21_R3): list of all bugs that have been fixed in 4D 21 R3. @@ -39,6 +40,7 @@ Read [**What’s new in 4D 21 R3**](https://blog.4d.com/whats-new-in-4d-21-r3/), - The **Legacy** network layer is no longer supported. Projects and binary databases that were using the Legacy network layer are automatically set to [**ServerNet**](../settings/client-server.md#network-layer) when upgraded to 4D 21 R3 and higher. + ## 4D 21 R2 Read [**What’s new in 4D 21 R2**](https://blog.4d.com/whats-new-in-4d-21-r2/), the blog post that lists all new features and enhancements in 4D 21 R2. diff --git a/versioned_docs/version-21-R3/assets/en/FormEditor/print_rendering.png b/versioned_docs/version-21-R3/assets/en/FormEditor/print_rendering.png new file mode 100644 index 00000000000000..d2a28e9dda474d Binary files /dev/null and b/versioned_docs/version-21-R3/assets/en/FormEditor/print_rendering.png differ diff --git a/versioned_docs/version-21-R3/assets/en/FormEditor/screen_rendering.png b/versioned_docs/version-21-R3/assets/en/FormEditor/screen_rendering.png new file mode 100644 index 00000000000000..b219623b061d96 Binary files /dev/null and b/versioned_docs/version-21-R3/assets/en/FormEditor/screen_rendering.png differ diff --git a/versioned_docs/version-21-R3/language-legacy/4D Environment/get-database-parameter.md b/versioned_docs/version-21-R3/language-legacy/4D Environment/get-database-parameter.md index 504871add223f1..e0e6a41d8d2626 100644 --- a/versioned_docs/version-21-R3/language-legacy/4D Environment/get-database-parameter.md +++ b/versioned_docs/version-21-R3/language-legacy/4D Environment/get-database-parameter.md @@ -23,7 +23,7 @@ displayed_sidebar: docs |Release|Changes| |---|---| -|21 R3|Removed support of *Use legacy network layer*| +|21 R3|Removed support of *Use legacy network layer*, added *Use legacy print rendering*| |20 R6|Modified| |19 R5|Modified| |16 R4|Modified| @@ -1428,6 +1428,15 @@ In previous releases, time values were converted and stored as number of millise Note that this parameter sets all 4D tips, i.e. form help messages and Design mode editor's tips. +### Use legacy print rendering (136) + +**Scope:** 4D application + +**Kept between two sessions:** No + +**Possible values:** 0 = legacy print rendering disabled, 1 = legacy print rendering enabled + +**Description:** Sets or gets the current status of the [legacy print renderer](../../FormEditor/forms.md#legacy-print-rendering) on macOS or Windows. When the legacy print renderer is *disabled*, 4D’s [modern print rendering engine](../../FormEditor/forms.md) is used. Note that when forms are rendered under Liquid Glass (macOS) or Fluent UI (Windows) interfaces, this selector is ignored (in such contexts forms are always printed using the modern print renderer, see [this section](../../FormEditor/forms.md#legacy-print-rendering)). In converted projects, this parameter can also be set permanently using a [compatibility setting](../../settings/compatibility.md). diff --git a/versioned_docs/version-21-R3/language-legacy/4D Environment/set-database-parameter.md b/versioned_docs/version-21-R3/language-legacy/4D Environment/set-database-parameter.md index 643a6609541ec3..8123a5d0ca4297 100644 --- a/versioned_docs/version-21-R3/language-legacy/4D Environment/set-database-parameter.md +++ b/versioned_docs/version-21-R3/language-legacy/4D Environment/set-database-parameter.md @@ -22,7 +22,7 @@ displayed_sidebar: docs |Release|Changes| |---|---| -|21 R3|Removed support of *Use legacy network layer*| +|21 R3|Removed support of *Use legacy network layer*, added *Use legacy print rendering* | |20 R6|Modified| |20 R3|Modified| |19 R5|Modified| @@ -1035,6 +1035,15 @@ In previous releases, time values were converted and stored as number of millise Note that this parameter sets all 4D tips, i.e. form help messages and Design mode editor's tips. +### Use legacy print rendering (136) + +**Scope:** 4D application + +**Kept between two sessions:** No + +**Possible values:** 0 = legacy print rendering disabled, 1 = legacy print rendering enabled + +**Description:** Sets or gets the current status of the [legacy print renderer](../../FormEditor/forms.md#legacy-print-rendering) on macOS or Windows. When the legacy print renderer is *disabled*, 4D’s [modern print rendering engine](../../FormEditor/forms.md) is used. Note that when forms are rendered under Liquid Glass (macOS) or Fluent UI (Windows) interfaces, this selector is ignored (in such contexts forms are always printed using the modern print renderer, see [this section](../../FormEditor/forms.md#legacy-print-rendering)). In converted projects, this parameter can also be set permanently using a [compatibility setting](../../settings/compatibility.md). ### User param value (108) @@ -1047,7 +1056,9 @@ In previous releases, time values were converted and stored as number of millise **Description:** Custom string passed from one session to the next one when the 4D application is restarted. This selector is useful in the context of automated unit tests that require applications to restart with different parameters. -When used with [SET DATABASE PARAMETER](../commands/set-database-parameter), defines a new value that will be available within the next opened database after 4D is restarted manually or using the [OPEN DATABASE](../commands/open-database)(\*), [OPEN DATA FILE](../commands/open-data-file), or [RESTART 4D](../commands/restart-4d) commands. When used with [Get database parameter](../commands/get-database-parameter), gets the currently available user parameter value, defined using a command line (see *Command Line Interface*), the .4DLink file (see *Using a 4DLink file*), or a call to [SET DATABASE PARAMETER](../commands/set-database-parameter) during the previous session. (\*) If [SET DATABASE PARAMETER](../commands/set-database-parameter) sets a User param value before a call to [OPEN DATABASE](../commands/open-database) with a .4DLink file that also contains a user-param xml attribute, 4D takes into account only the parameter provided by [SET DATABASE PARAMETER](../commands/set-database-parameter). +When used with [SET DATABASE PARAMETER](../commands/set-database-parameter), defines a new value that will be available within the next opened database after 4D is restarted manually or using the [OPEN DATABASE](../commands/open-database)(\*), [OPEN DATA FILE](../commands/open-data-file), or [RESTART 4D](../commands/restart-4d) commands. When used with [Get database parameter](../commands/get-database-parameter), gets the currently available user parameter value, defined using a command line (see [Command Line Interface](../../Admin/cli.md)), the .4DLink file (see [Using a 4DLink file](../../GettingStarted/creating.md#opening-a-project-with-a-4dlink-file)), or a call to [SET DATABASE PARAMETER](../commands/set-database-parameter) during the previous session. + +(\*) If [SET DATABASE PARAMETER](../commands/set-database-parameter) sets a User param value before a call to [OPEN DATABASE](../commands/open-database) with a .4DLink file that also contains a user-param xml attribute, 4D takes into account only the parameter provided by [SET DATABASE PARAMETER](../commands/set-database-parameter). diff --git a/versioned_docs/version-21-R3/language-legacy/Printing/print-form.md b/versioned_docs/version-21-R3/language-legacy/Printing/print-form.md index 9bca02115665c2..17539ff363293f 100644 --- a/versioned_docs/version-21-R3/language-legacy/Printing/print-form.md +++ b/versioned_docs/version-21-R3/language-legacy/Printing/print-form.md @@ -34,7 +34,9 @@ displayed_sidebar: docs ## Description -The **Print form** command simply prints *form* with the current values of fields and variables of *aTable*. It is usually used to print very complex reports that require complete control over the printing process. **Print form** does not do any record processing, break processing or page breaks. These operations are your responsibility. **Print form** prints fields and variables in a fixed size frame only. +The **Print form** command simply prints *form* with the current values of fields and variables of *aTable*. It is usually used to print very complex reports that require complete control over the printing process. + +**Print form** does not do any record processing, break processing or page breaks. These operations are your responsibility. In the *form* parameter, you can pass: @@ -44,9 +46,11 @@ In the *form* parameter, you can pass: Since **Print form** does not issue a page break after printing the form, it is easy to combine different forms on the same page. Thus, **Print form** is perfect for complex printing tasks that involve different tables and different forms. To force a page break between forms, use the [PAGE BREAK](../commands/page-break) command. In order to carry printing over to the next page for a form whose height is greater than the available space, call the [CANCEL](../commands/cancel) command before the [PAGE BREAK](../commands/page-break) command. +### Syntaxes + Three different syntaxes may be used: -* **Detail area printing** +#### Detail area printing Syntax: @@ -56,7 +60,7 @@ Syntax: In this case, **Print form** only prints the Detail area (the area between the Header line and the Detail line) of the form. -* **Form area printing** +#### Form area printing Syntax: @@ -92,7 +96,7 @@ In this case, the command will print the section designated by the *marker*. Pas | Form header8 | Integer | 208 | | Form header9 | Integer | 209 | -* **Section printing** +#### Section printing Syntax: @@ -102,37 +106,50 @@ Syntax: In this case, the command will print the section included between the *areaStart* and *areaEnd* parameters. The values entered must be expressed in pixels. -**formData** +#### formData Optionally, you can pass parameters to the *form* using either the *formData* object or the form class object automatically instantiated by 4D if you have [associated a user class to the form](../../FormEditor/properties_FormProperties.md#form-class). Any properties of the form data object will then be available from within the form context through the [Form](../commands/form) command. The form data object is available in the [`On Printing Detail` form event](../../Events/onPrintingDetail.md). For detailed information on the form data object, please refer to the [`DIALOG`](../commands/dialog) command. -**Return value** +#### Return value The value returned by **Print form** indicates the height of the printable area. This value will be automatically taken into account by the [Get printed height](../commands/get-printed-height) command. + +### Print settings + The printer dialog boxes do not appear when you use **Print form**. The report does not use the print settings that were assigned to the form in the Design environment. There are two ways to specify the print settings before issuing a series of calls to **Print form**: * Call [PRINT SETTINGS](../commands/print-settings). In this case, you let the user choose the settings. * Call [SET PRINT OPTION](../commands/set-print-option) and [GET PRINT OPTION](../commands/get-print-option). In this case, print settings are specified programmatically. +### Page breaks + **Print form** builds each printed page in memory. Each page is printed when the page in memory is full or when you call [PAGE BREAK](../commands/page-break). To ensure the printing of the last page after any use of **Print form**, you must conclude with the [PAGE BREAK](../commands/page-break) command (except in the context of an [OPEN PRINTING JOB](../commands/open-printing-job), see note). Otherwise, if the last page is not full, it stays in memory and is not printed. **Warning:** If the command is called in the context of a printing job opened with [OPEN PRINTING JOB](../commands/open-printing-job), you must NOT call [PAGE BREAK](../commands/page-break) for the last page because it is automatically printed by the [CLOSE PRINTING JOB](../commands/close-printing-job) command. If you call [PAGE BREAK](../commands/page-break) in this case, a blank page is printed. -This command prints external areas and objects (for example, 4D Write or 4D View areas). The area is reset for each execution of the command. +### Support of form events and form objects -**Warning:** Subforms are not printed with **Print form**. To print only one form with such objects, use [PRINT RECORD](../commands/print-record) instead. +**Print form** only generates the [`On Printing Detail` event](../../Events/onPrintingDetail.md) in the form method. -**Print form** generates only one [`On Printing Detail` event](../../Events/onPrintingDetail.md) for the form method. +**Print form** prints fields and variables in a [fixed size frame](../../FormObjects/properties_Print.md#print-frame) only. -**4D Server:** This command can be executed on 4D Server within the framework of a stored procedure. In this context: +**Print form** prints external areas and objects (for example, 4D Write or 4D View areas). The area is reset for each execution of the command. + +[Subforms](../../FormObjects/subform_overview.md) are not printed with **Print form**. To print only one form with such objects, use [PRINT RECORD](../commands/print-record) instead. + +:::note 4D Server + +This command can be executed on 4D Server within the framework of a stored procedure. In this context: * Make sure that no dialog box appears on the server machine (except for a specific requirement). * In the case of a problem concerning the printer (out of paper, printer disconnected, etc.), no error message is generated. +::: + ## Example 1 The following example performs as a [PRINT SELECTION](../commands/print-selection) command would. However, the report uses one of two different forms, depending on whether the record is for a check or a deposit: @@ -190,6 +207,78 @@ The code that calls the dialog then prints its body:  $h:=Print form("Request_var";$formData;Form detail) ``` +## Example 4 + +You want to print a report with data coming from an entity selection (ORDA) in a project form, using breaks and subtotals. + +The form template is the following: + +![](../../assets/en/commands/form-print1.png) + +The method that calls the form: + +```4d +var $es : cs.SalesSelection +var $e : cs.SalesEntity + +$es:=ds.Sales.all().orderBy("Region asc, Seller asc") +$breakRegion:="" +$breakSeller:="" + + +// Global report header (printed once) +Print form("testPrintForm1"; $e; Form header) +For each ($e; $es) + + // Region break (level 1): close previous seller and region totals, then open new region + If ($breakRegion#$e.Region) + If ($breakRegion#"") + Print form("testPrintForm1"; {totalQuantity: $filteredSeller.sum("Quantity"); totalPrice: $filteredSeller.sum("UnitPrice")}; Form break2) + Print form("testPrintForm1"; {totalQuantity: $filtered.sum("Quantity"); totalPrice: $filtered.sum("UnitPrice")}; Form break1) + End if + $breakRegion:=$e.Region + // Reset seller break so header2 is printed for first seller in this region + $breakSeller:="" + $filtered:=$es.query("Region=:1"; $breakRegion) + Print form("testPrintForm1"; {Region: $e.Region}; Form header1) + End if + + // Seller break (level 2) inside current region + If (($breakSeller#$e.Seller)) + If ($breakSeller#"") + Print form("testPrintForm1"; {totalQuantity: $filteredSeller.sum("Quantity"); totalPrice: $filteredSeller.sum("UnitPrice")}; Form break2) + End if + $breakSeller:=$e.Seller + // Seller subtotal must be scoped by Region + Seller + $filteredSeller:=$es.query("Region=:1 and Seller=:2"; $breakRegion; $breakSeller) + Print form("testPrintForm1"; {Seller: $e.Seller}; Form header2) + End if + + + // Detail line + Print form("testPrintForm1"; $e; Form detail) +End for each + +// Close the last seller and region groups after loop +Print form("testPrintForm1"; {totalQuantity: $filteredSeller.sum("Quantity"); totalPrice: $filteredSeller.sum("UnitPrice")}; Form break2) +Print form("testPrintForm1"; {totalQuantity: $filtered.sum("Quantity"); totalPrice: $filtered.sum("UnitPrice")}; Form break1) + +// Grand totals for the full selection +Print form("testPrintForm1"; \ +{totalQuantity: $es.sum("Quantity"); totalPrice: $es.sum("UnitPrice"); \ +minQuantity: $es.min("Quantity"); minPrice: $es.min("UnitPrice"); \ +maxQuantity: $es.max("Quantity"); maxPrice: $es.max("UnitPrice")}; \ +Form break0) + +// Global report footer (printed once) +Print form("testPrintForm1"; $e; Form footer) +``` + +The resulting printed report: + +![](../../assets/en/commands/form-print2.png) + + ## See also [CANCEL](../commands/cancel) diff --git a/versioned_docs/version-21-R3/language-legacy/Printing/print-selection.md b/versioned_docs/version-21-R3/language-legacy/Printing/print-selection.md index 21d9038a0823e1..cdb67cdb61b56e 100644 --- a/versioned_docs/version-21-R3/language-legacy/Printing/print-selection.md +++ b/versioned_docs/version-21-R3/language-legacy/Printing/print-selection.md @@ -49,16 +49,25 @@ You can check whether **PRINT SELECTION** is printing the first header by testin To print a sorted selection with subtotals or breaks using **PRINT SELECTION**, you must first sort the selection. Then, in each Break area of the report, include a variable with an object method that assigns the subtotal to the variable. You can also use statistical and arithmetical functions like [Sum](../commands/sum) and [Average](../commands/average) to assign values to variables. For more information, see the descriptions of [Subtotal](../commands/subtotal), [BREAK LEVEL](../commands/break-level) and [ACCUMULATE](../commands/accumulate). -**Warning:** Do not use the [PAGE BREAK](../commands/page-break) command with the **PRINT SELECTION** command. [PAGE BREAK](../commands/page-break) is to be used with the [Print form](../commands/print-form) command. +:::warning + + Do not use the [PAGE BREAK](../commands/page-break) command with the **PRINT SELECTION** command. [PAGE BREAK](../commands/page-break) is to be used with the [Print form](../commands/print-form) command. + +::: After a call to **PRINT SELECTION**, the OK variable is set to 1 if the printing has been completed. If the printing was interrupted, the OK variable is set to 0 (zero) (i.e., the user clicked Cancel in the printing dialog box). -**4D Server:** This command can be executed on 4D Server in a stored procedure. In this context: +:::note 4D Server + +This command can be executed on 4D Server in a stored procedure. In this context: * Make sure that no dialog box appears on the server machine (except for a specific requirement). To do this, it is necessary to call the command with the *\** or *\>* parameter. * In the case of a problem concerning the printer (out of paper, printer disconnected, etc.), no error message is generated. -## Example +::: + + +## Example 1 The following example selects all the records in the \[People\] table. It then uses the [DISPLAY SELECTION](../commands/display-selection) command to display the records and allows the user to highlight the records to print. Finally, it uses the selected records with the [USE SET](../commands/use-set) command, and prints them with **PRINT SELECTION**: @@ -69,11 +78,54 @@ The following example selects all the records in the \[People\] table. It then u  PRINT SELECTION([People]) // Print the records that the user picked ``` +## Example 2 + +You want to print a report with breaks and subtotals, using the following form template: + +![](../../assets/en/commands/print-selection1.png) + +The method called to build the report: + +```4d +ALL RECORDS([Sales]) +ORDER BY([Sales]Region; <; [Sales]Seller; <) +BREAK LEVEL(2) +ACCUMULATE([Sales]Quantity; [Sales]UnitPrice) +PRINT SELECTION([Sales]) +``` + +In the form method, you calculate the subtotal values thanks to the built-in **PRINT SELECTION** command features, i.e. values processed in the `On printing break` event can be directly evaluated by [`Subtotal`](../commands/subtotal): + +```4d + //form method +Case of + : (FORM Event.code=On Printing Break) + vBreak:=[Sales]Region + //Subtotal uses currently processed values + //it can be used in break variables + vTotalQuantity:=Subtotal([Sales]Quantity) + vTotalPrice:=Subtotal([Sales]UnitPrice) + + //Min and Max use current selection + //they are valid at the final break + vMinQuantity:=Min([Sales]Quantity) + vMinPrice:=Min([Sales]UnitPrice) + vMaxQuantity:=Max([Sales]Quantity) + vMaxPrice:=Max([Sales]UnitPrice) +End case +``` + +The resulting printed report: + +![](../../assets/en/commands/print-selection2.png) + + ## See also [ACCUMULATE](../commands/accumulate) [BREAK LEVEL](../commands/break-level) [Level](../commands/level) +[Print form](../commands/print-form) [Subtotal](../commands/subtotal) ## Properties diff --git a/versioned_docs/version-21-R3/settings/compatibility.md b/versioned_docs/version-21-R3/settings/compatibility.md index 2706580697dde2..97911b86883795 100644 --- a/versioned_docs/version-21-R3/settings/compatibility.md +++ b/versioned_docs/version-21-R3/settings/compatibility.md @@ -5,23 +5,29 @@ title: Compatibility page The Compatibility page groups together parameters related to maintaining compatibility with previous versions of 4D. -> The number of options displayed depends on the version of 4D with which the original database/project was created, as well as the settings modified in this database/project. -> This page lists the compatibility options available for database/projects converted from 4D v18 onwards. For older compatibility options, refer to the [Compatibility page](https://doc.4d.com/4Dv20/4D/20.2/Compatibility-page.300-6750362.en.html) on **doc.4d.com**. +:::note +- The number of options displayed depends on the version of 4D with which the original database/project was created, as well as the settings modified in this database/project. +- This page lists the compatibility options available for database/projects converted from 4D 18 onwards. For older compatibility options, refer to the [Compatibility page](https://doc.4d.com/4Dv20/4D/20.2/Compatibility-page.300-6750362.en.html) on **doc.4d.com**. -- **Use standard XPath:** By default this option is unchecked for databases converted from a 4D version prior to v18 R3, and checked for databases created with 4D v18 R3 and higher. Starting with v18 R3, the XPath implementation in 4D has been modified to be more compliant and to support more predicates. As a consequence, non-standard features of the previous implementation no longer work. They include: +::: + + +- **Use standard XPath:** By default this option is unchecked for databases converted from a 4D version prior to 18 R3, and checked for databases created with 4D 18 R3 and higher. Starting with 18 R3, the XPath implementation in 4D has been modified to be more compliant and to support more predicates. As a consequence, non-standard features of the previous implementation no longer work. They include: * initial "/" is not the root node only - using a / as first character in a XPath expression does not declare an absolute path from the root node * no implicit current node - the current node has to be included in the XPath expression * no recursive searches in repeated structures - only the first element is parsed.\ Although not standard, you might want to keep using these features so that your code continues to work as before -- in this case, just set the option *unchecked*. On the other hand, if your code does not rely on the non-standard implementation and if you want to benefit from the extended XPath features in your databases (as described in the [`DOM Find XML element`](../commands/dom-find-xml-element) command), make sure the **Use standard XPath** option is *checked*. -- **Use LF for end of line on macOS:** Starting with 4D v19 R2 (and 4D v19 R3 for XML files), 4D writes text files with line feed (LF) as default end of line (EOL) character instead of CR (CRLF for xml SAX) on macOS in new projects. If you want to benefit from this new behavior on projects converted from previous 4D versions, check this option. See [`TEXT TO DOCUMENT`](../commands/text-to-document), [`Document to text`](../commands/document-to-text), and [XML SET OPTIONS](../commands/xml-set-options). +- **Use LF for end of line on macOS:** Starting with 4D 19 R2 (and 4D 19 R3 for XML files), 4D writes text files with line feed (LF) as default end of line (EOL) character instead of CR (CRLF for xml SAX) on macOS in new projects. If you want to benefit from this new behavior on projects converted from previous 4D versions, check this option. See [`TEXT TO DOCUMENT`](../commands/text-to-document), [`Document to text`](../commands/document-to-text), and [XML SET OPTIONS](../commands/xml-set-options). + +- **Don't add a BOM when writing a unicode text file by default:** Starting with 4D 19 R2 (and 4D 19 R3 for XML files), 4D writes text files without a byte order mark (BOM) by default. In previous versions, text files were written with a BOM by default. Select this option if you want to enable the new behavior in converted projects. See [`TEXT TO DOCUMENT`](../commands/text-to-document), [`Document to text`](../commands/document-to-text), and [XML SET OPTIONS](../commands/xml-set-options). -- **Don't add a BOM when writing a unicode text file by default:** Starting with 4D v19 R2 (and 4D v19 R3 for XML files), 4D writes text files without a byte order mark (BOM) by default. In previous versions, text files were written with a BOM by default. Select this option if you want to enable the new behavior in converted projects. See [`TEXT TO DOCUMENT`](../commands/text-to-document), [`Document to text`](../commands/document-to-text), and [XML SET OPTIONS](../commands/xml-set-options). +- **Map NULL values to blank values unchecked by default at field creation**: For better compliance with ORDA specifications, in databases created with 4D 19 R4 and higher the **Map NULL values to blank values** field property is unchecked by default when you create fields. You can apply this default behavior to your converted databases by checking this option (working with Null values is recommended since they are fully supported by [ORDA](../ORDA/overview.md). -- **Map NULL values to blank values unchecked by default a field creation**: For better compliance with ORDA specifications, in databases created with 4D v19 R4 and higher the **Map NULL values to blank values** field property is unchecked by default when you create fields. You can apply this default behavior to your converted databases by checking this option (working with Null values is recommended since they are fully supported by [ORDA](../ORDA/overview.md). +- **Non-blocking printing**: Starting with 4D 20 R4, each process has its own printing settings (print options, current printer, etc.), thus allowing you to run multiple printing jobs simultaneously. Check this option if you want to benefit from this new implementation in your converted 4D projects or your databases converted from binary mode to project mode. **When left unchecked**, the previous implementation is applied: the current 4D printing settings are applied globally, the printer is placed in "busy" mode when one printing job is running, you must call [`CLOSE PRINTING JOB`](../commands/close-printing-job) for the printer to be available for the next print job (check previous 4D documentations for more information). -- **Non-blocking printing**: Starting with 4D v20 R4, each process has its own printing settings (print options, current printer, etc.), thus allowing you to run multiple printing jobs simultaneously. Check this option if you want to benefit from this new implementation in your converted 4D projects or databases converted from binary mode to project mode. **When left unchecked**, the previous implementation is applied: the current 4D printing settings are applied globally, the printer is placed in "busy" mode when one printing job is running, you must call `CLOSE PRINTING JOB` for the printer to be available for the next print job (check previous 4D documentations for more information). +- **Save structure color and coordinates in separate catalog_editor.json file**: Starting with 4D 20 R5, changes made in the Structure editor regarding graphical appearance of tables and fields (color, position, order...) are saved in a separate file named `catalog_editor.json`, stored in the project's [Sources folder](../Project/architecture.md#sources). This new file architecture makes it easier to manage merge conflicts in VCS applications since the `catalog.4DCatalog` file now contains only crucial database structure changes. For compatibility reasons, this feature is not enabled by default in projects converted from previous 4D versions, you need to check this option. When the feature is enabled, the `catalog_editor.json` file is created at the first modification in the Structure editor. -- **Save structure color and coordinates in separate catalog_editor.json file**: Starting with 4D v20 R5, changes made in the Structure editor regarding graphical appearance of tables and fields (color, position, order...) are saved in a separate file named `catalog_editor.json`, stored in the project's [Sources folder](../Project/architecture.md#sources). This new file architecture makes it easier to manage merge conflicts in VCS applications since the `catalog.4DCatalog` file now contains only crucial database structure changes. For compatibility reasons, this feature is not enabled by default in projects converted from previous 4D versions, you need to check this option. When the feature is enabled, the `catalog_editor.json` file is created at the first modification in the Structure editor. +- **Use legacy print rendering**: Starting with 4D 21 R3, 4D uses a new, unified print rendering engine to print forms on macOS and Windows. To make sure forms designed with the [legacy screen-based print renderer](../FormEditor/forms.md#legacy-print-renderer) continue to be printed as expected, this option is checked by default in converted projects or databases created with 4D 21 R2 and before. You can uncheck this option to benefit from the [modern print rendering engine](../FormEditor/forms.md#print-rendering-engine). Note that when forms are rendered under Liquid Glass (macOS) or Fluent UI (Windows) interfaces, this option is ignored: in such contexts forms are always printed using the modern print renderer (see [this section](../../FormEditor/forms.md#legacy-print-rendering)). \ No newline at end of file