{"title":"OnAfterDocumentPrintReady Event","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/devenv-onafterdocumentprintready-event/","by":"JOP-AL","license":"Copyright (c) Microsoft Corporation. CC BY 4.0, https://creativecommons.org/licenses/by/4.0/; code samples MIT. From https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/devenv-onafterdocumentprintready-event, MicrosoftDocs/dynamics365smb-devitpro-pb at 828b6ee (2026-11-19). Changed: includes filled in, links to this site, and for agents shortened without dropping a fact.","credit":"Microsoft Corporation, CC BY 4.0","origin":"https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/devenv-onafterdocumentprintready-event","source":{"name":"Business Central developer and IT pro docs","repo":"https://github.com/MicrosoftDocs/dynamics365smb-devitpro-pb","commit":"828b6ee72fcd75755627cd6011f3d20899217ab2","date":"2026-11-19"},"checked":"2026-11-19","description":"Describe the OnAfterDocumentPrintReady Event in Business Central.","date":"2021-04-01","meta":{"topic":"article"},"outline":[{"level":2,"title":"Usage","slug":"usage","at":115,"chars":356},{"level":2,"title":"Publisher","slug":"publisher","at":471,"chars":43},{"level":2,"title":"Raised","slug":"raised","at":514,"chars":72},{"level":2,"title":"Syntax","slug":"syntax","at":586,"chars":224},{"level":2,"title":"Parameters","slug":"parameters","at":810,"chars":612},{"level":2,"title":"Report payload","slug":"report-payload","at":1422,"chars":4858},{"level":3,"title":"Attributes","slug":"attributes","at":2825,"chars":3455},{"level":4,"title":"objectname","slug":"objectname","at":2840,"chars":50},{"level":4,"title":"objectid","slug":"objectid","at":2890,"chars":46},{"level":4,"title":"documenttype","slug":"documenttype","at":2936,"chars":217},{"level":4,"title":"invokedby","slug":"invokedby","at":3153,"chars":74},{"level":4,"title":"invokeddatetime","slug":"invokeddatetime","at":3227,"chars":184},{"level":4,"title":"companyname","slug":"companyname","at":3411,"chars":57},{"level":4,"title":"version","slug":"version","at":3468,"chars":120},{"level":4,"title":"duplex","slug":"duplex","at":3588,"chars":175},{"level":4,"title":"color","slug":"color","at":3763,"chars":161},{"level":4,"title":"defaultcopies","slug":"defaultcopies","at":3924,"chars":160},{"level":4,"title":"filterviews","slug":"filterviews","at":4084,"chars":64},{"level":4,"title":"name","slug":"name","at":4148,"chars":75},{"level":4,"title":"tableid","slug":"tableid","at":4223,"chars":57},{"level":4,"title":"view","slug":"view","at":4280,"chars":42},{"level":4,"title":"papertray","slug":"papertray","at":4322,"chars":123},{"level":4,"title":"papersourcekind","slug":"papersourcekind","at":4445,"chars":190},{"level":4,"title":"paperkind","slug":"paperkind","at":4635,"chars":145},{"level":4,"title":"landscape","slug":"landscape","at":4780,"chars":119},{"level":4,"title":"units","slug":"units","at":4899,"chars":279},{"level":4,"title":"height","slug":"height","at":5178,"chars":105},{"level":4,"title":"width","slug":"width","at":5283,"chars":103},{"level":4,"title":"intent","slug":"intent","at":5386,"chars":169},{"level":4,"title":"layoutmodel","slug":"layoutmodel","at":5555,"chars":157},{"level":4,"title":"layoutname","slug":"layoutname","at":5712,"chars":77},{"level":4,"title":"layoutmimetype","slug":"layoutmimetype","at":5789,"chars":210},{"level":4,"title":"layoutapplicationid","slug":"layoutapplicationid","at":5999,"chars":96},{"level":4,"title":"reportrunid","slug":"reportrunid","at":6095,"chars":185},{"level":2,"title":"Related information","slug":"related-information","at":6280,"chars":332}],"text":"This article describes the syntax of the OnAfterDocumentPrintReady event and the attributes of the report payload.\n## Usage\nUse the OnAfterDocumentSetupPrinters event to specify what happens when the user selects the Print action on a report request page. The OnAfterDocumentPrintReady event is used to send a report to a target extension printer. For more information about subscribing to this event, see Developing Printer Extensions Overview<devenv-reports-printing>.\n## Publisher\nCodeunit 44 ReportManagement.\n## Raised\nWhen a user selects the print action on a report request page\n## Syntax\n```al\nIntegrationEvent(false, false)]\nlocal procedure OnAfterDocumentPrintReady(ObjectType: Option \"Report\",\"Page\"; ObjectId: Integer; ObjectPayload: JsonObject; DocumentStream: InStream; var Success: Boolean)\n```\n## Parameters\nObjectType\nType: methods-auto/enum/enum-data-type\nThe object to run. Currently only report is supported.\nObjectID\nType: methods-auto/integer/integer-data-type\nThe ID of the report object to be run.\nObjectPayload\nType: methods-auto/jsonobject/jsonobject-data-type\nInstance of the report payload. See Report payload structure<#reportpayload>.\nDocumentStream\nType: methods-auto/instream/instream-data-type\nA stream object that contains a .pdf file of the report to be printed.\nSuccess\nType: methods-auto/boolean/boolean-data-type\nSpecifies whether the extension handled the print action successfully.\n## Report payload\nThe report payload contains metadata for the report object and a list of attributes that identifies that current invocation. The payload consists of several attributes and has the following structure.\n```json\n{\n    \"filterviews\":\n    [\n        {\"name\":\"Header\",\"tableid\":112,\"view\":\"VERSION(1) SORTING(Field3) WHERE(Field3=1(103027))\"},\n        {\"name\":\"Line\",\"tableid\":113,\"view\":\"VERSION(1) SORTING(Field3,Field4) WHERE(Field4=1(0..10000))\"},\n        {\"name\":\"ShipmentLine\",\"tableid\":7190,\"view\":\"VERSION(1) SORTING(Field1,Field2,Field3) WHERE(Field2=1(10000))\"}\n    ],\n    \"version\":1,\n    \"objectname\":\"Standard Sales - Invoice\",\n    \"objectid\":1306,\n    \"documenttype\":\"application/pdf\",\n    \"invokedby\":\"00000000-0000-0000-0000-000000000001\",\n    \"invokeddatetime\":\"2020-01-17T15:33:52.48+01:00\",\n    \"companyname\":\"CRONUS International Ltd.\",\n    \"printername\":\"My Printer\",\n    \"duplex\":false,\n    \"color\":false,\n    \"defaultcopies\":1,\n    \"papertray\":\n    {\n        \"papersourcekind\":257,\n        \"paperkind\":0,\n        \"landscape\":false,\n        \"units\":0,\n        \"height\":1268,\n        \"width\":929\n    },\n    \"intent\":\"Print\",\n    \"layoutmodel\": \"Rdlc\",\n    \"layoutname\": \"RDLCLayout\",\n    \"layoutmimetype\": \"Application/ReportLayout/Rdlc\",\n    \"layoutapplicationid\": \"00001111-aaaa-2222-bbbb-3333cccc4444\",\n    \"reportrunid\": \"6a3742c1-65ef-44a6-af58-3ef4a902932b\"\n}\n\n```\n### Attributes\n#### objectname\nSpecifies the name of the object.\n#### objectid\nSpecifies the ID of the object.\n#### documenttype\nSpecifies the MIME type of the document. Currently only `application/pdf` is supported for printing, other intents can have types specific to the report layout model and selected output target type.\n#### invokedby\nSpecifies the ID of the user who invoked the print action.\n#### invokeddatetime\nSpecifies the date and time that the print action was invoked, for example, `2019-10-22T22:25:54.338+02:00`. The value is the date and time on the client machine.\n#### companyname\nSpecifies the Business Central company.\n#### version\nSpecifies the version of the report payload. Currently, the only supported version for the payload is `1`.\n#### duplex\nSpecifies whether to use duplex (2-sided) printing. true specifies duplex printing; otherwise false.\n> NOTE\n> duplex is currently not used and ignored at runtime.\n#### color\nSpecifies whether color printing is set. true specifies color printing; otherwise false.\n> NOTE\n> color is currently not used and ignored at runtime.\n#### defaultcopies\nSpecifies the number of copies to print by default. The default is `1`.\n> NOTE\n> defaultcopies is currently not used and ignored at runtime.\n#### filterviews\nSpecifies views that are used on the document.\n#### name\nSpecifies the name of data item that the filter view applies to.\n#### tableid\nSpecifies the ID of the table for the view.\n#### view\nSpecifies the name of the view.\n#### papertray\nSpecifies the paper tray settings from the printer payload<devenv-onaftersetupprinters-event#printpayload>.\n#### papersourcekind\nSpecifies a standard paper source for the paper tray. The value can be either the text representation (such as AutomaticFeed) or the corresponding number (such as `7`).\n#### paperkind\nSpecifies the paper size. The value can be either the text representation (such as A4) or the corresponding number (such as `9`).\n#### landscape\nSpecifies whether landscape orientation is used. true specifies landscape orientation; otherwise false.\n#### units\nSpecifies the units of measurement for values in height and width attributes. Valid values include:\n HI for hundredths of an inch (default value).\n TI for thousandths of an inch.\n IN for inches.\n CM for centimeters.\n MM for millimeters.\n PC for picas.\n PT for points.\n#### height\nSpecifies the height of the paper. The values include positive integers up to 2,147,483,647.\n#### width\nSpecifies the width of the paper. The values include positive integers up to 2,147,483,647.\n#### intent\nSpecifies the intent of the current report invocation, which can be one of the following values.\n None\n Print\n Preview\n Save\n Schedule\n Download\n Parameters\n#### layoutmodel\nSpecifies the layout model selected for the current report invocation, which can be one of the following values.\n Rdlc\n Word\n Excel\n Custom\n#### layoutname\nSpecifies the layout name for the currently selected layout.\n#### layoutmimetype\nSpecifies the layout mimetype for the currently selected layout. The built-in layout types are:\n Application/ReportLayout/Rdlc\n Application/ReportLayout/Word\n Application/ReportLayout/Excel\n#### layoutapplicationid\nSpecifies the ID of the application that provides the selected layout.\n#### reportrunid\nSpecifies a unique ID of type Guid that identifies the current report invocation. This value can be used to correlate calls to report event that support json payloads.\n## Related information\nWorking With and Troubleshooting Payloads<devenv-reports-troubleshoot-printing>\nDeveloping Printer Extensions Overview<devenv-reports-printing>\nCreating a Printer Extension<devenv-reports-create-printer-extension>\ndevenv-events-in-al\ndevenv-publishing-events\ndevenv-raising-events\ndevenv-subscribing-to-events"}