Creation of printing forms 1s 8.2. Publications. Creating an external printing plate based on the standard one with minor changes

It is carried out in accordance with the standard layout of the printed form built into the application by developers (it is called the "supplied" layout).

If necessary, you can change the standard layout and, in the future, print the document based on your personal ("custom") layout. To edit the layout of the printed form, a mechanism for uploading to a local computer is provided. The layout is edited in the local version of the 1C:Enterprise application (in particular, you can use the free application 1C:Enterprise - Working with files).


Follow the steps below to change the printable layout.




Editing of the printable layout is completed, when the document is printed, the layout to which the changes have been made will be used.

If you would like to return to the previous printable layout, click the button Use Standard Layout. In this case, the edited layout will still be present on the server, and it can be re-enabled by pressing the button Change.

We wish you pleasant work!

How to insert a company logo into the layout of the printed form?

Let's bring specific example editing the printable layout Invoices for payment, namely, consider how to insert an image into it, for example, a company logo (this image must first be prepared and saved as a graphic file, for example, in png or jpg format).


Thus, now the invoices for payment that you prepare for transfer to your counterparties will have your company logo. In order to add the logo to other documents, you will need to repeat the described steps for the corresponding printed forms of these documents.

We wish you pleasant work!

I can only add that for the latest versions of the BSP and, accordingly, configurations on managed forms, there has been a tendency to move printing procedures and functions from the manager module to common modules. Therefore, most often, the VPF created by the constructor will have to be completed, transferring these same procedures and functions from common modules to the VPF module.

Instructions for a managed application

Let's create a WPF, for example, for a document Buyer invoice, printing form Invoice order(I'm doing an example on the platform 8.3.8.1784 BP 3.0.43.247 DEMO base).

Creation of the VPF

I proceed from the fact that the one who creates the VPF knows how to use the configurator, therefore we will not draw pictures from there. The result will be an external form, which is no different from the typical printed form of the document.

So, point by point:

  1. Copy manager module document Buyer account, by opening it in the configurator. copied the whole module , for example by clicking ctrl +A, after Ctrl + C.
  2. Open the constructor in accounting mode, select Document Type Invoice for payment to the buyer and press the button Insert:
  1. Click next button Analysis. We get on the bookmark Commands and functions a list of available print commands, a list of procedures and functions of the manager module, and the text of selected procedures in the right window. In the upper left window, uncheck all the checkboxes (control buttons at the top) and mark the printable we need InvoiceOrder. In the lower left window, the procedures required for printing the selected form will be automatically marked in green. If necessary, you can mark other procedures and functions using the button needed / not needed, they will be transferred to the final processing, but they will not be used automatically by the VPF, so think about it, do you need it? In the right window, you can view the text of the procedures and functions highlighted in the lower left window. The text can be changed, although I never used this opportunity, but who knows who needs it?:

  1. Next button Form. Creates the text of the WPF processing module:

  1. We press Compile- nothing will change on the screen, just the VPF will be created.
  2. Button Save will prompt you to choose the path where to save the created processing and open the created VPF for verification. VPF is created with a built-in processing form, so it can be debugged without resorting to additional tools. When opening the VPF, we immediately check the operability by selecting a document and generating a printed form:

As already mentioned, now it is no different from the standard one, and if you need to change something, you will have to do it by hand, which I will discuss below. I would like to note that the specified procedure for the formation of the VPF is minimal, try the rest yourself ... or don't try it. Here, in fact, the steps for quickly creating a WPF for further refinement are simply listed.

What surprised me is that both the standard and external ones, instead of the amount in words, give the amount in the demo as a number:

Change in received WPF

To correct the situation, and add something of our own to the VPF, let's start making changes:

  1. Let's insert the layout of the account in the VPF (by default, the same one is used as in the standard account form). To do this, let's see which layout is used. In the WPF object module:
IfPrintControl.NeedPrintLayout(PrintFormCollection, "InvoiceOrder") Then InvoiceDetailsTable = GetPayInvoiceDetailsTable(ArrayObjects); ManagePrinting.OutputSpreadsheetDocumentToCollection(PrintableFormCollection, "InvoiceOrder", "Invoice", PrintTrading Documents.PrintInvoice(Table DetailsInvoice,Print Objects),"CommonLayout.PF_MXL_InvoiceOrder"); OutputParameters.Insert("FormED", True); EndIf;

From the Print procedure, we see that we need a general layout PF_MXL_AccountOrder. Copy it in the config. Branch General - General Layouts:

Then, in processing, we stand on Layouts and insert, now the layout is in the WPF, you need to change the module code to use it, and not the general layout:

  1. We analyze the text of the printing procedure and add procedures and functions of common modules used in the formation of the printed form:
#Area AddedProceduresAndFunctions //between these lines paste the procedures copied from common modules #EndArea
  • We save what happened (or click on the syntax control). We get an error message:

(ExternalProcessing.Customer Invoice_ExternalPrinted.ObjectModule(371,3)): Procedure or function with specified name is not defined (OutputTitleWarning)

<>OutputTitleWarning(DetailsAboutDocument.Recipient, SpreadsheetDocument, Layout); (Check: Server).

Since the procedure is not defined without specifying through a dot, we conclude that it is in the same common module as the function we copied before PrintInvoicePayment- find it there, and copy it to the VPF module. And try to save again. In this case, we were lucky - there are no more errors. In general, this is a rarity, by and large, this is the most time-consuming moment. It happens that you may need to copy several procedures and functions, and maybe not even from one module. The main thing is not just to copy, but also to call them correctly later. I don't have a universal recipe for this.

  • Remove the line " Printing Trade Documents.» - now this function will be called from the WPF module.
  • We save the VPF, check it in the accounting mode - everything works, only now, everything that is needed for changes is in the VPF. Now you can make the necessary changes.
  1. Change the text of the WPF module:
  • Calling the built-in layout instead of the general one - find the line "GeneralLayout.PF_MXL_AccountOrder", we see that it is in the added function from the common module, and without changing the common module Printing Trade Documents(keeping the typical configuration on full support) we change the function of the VPF module:
//Layout = PrintControl.PrintFormLayout("GeneralLayout.PF_MXL_InvoiceOrder"); //Was Layout = GetLayout("PF_MXL_AccountOrder"); //Became

Attention: After each change, it is better to save the VPF and check the performance, if you change everything, then it may turn out that it will be easier to start from the beginning than to fix what was changed. Another tip, when everything works, and you are going to finish something, create a new version of the VPF, and change it - there will be a working version, and the current one, with an attempt to finish it)))

  • Let's fix the amount in words - now for some reason it is displayed as a number, there are many options, you can, for example, use the format string in the layout cell Suma in cuirsive, but this is ugly, so let's try to find a place in the text of the module where this parameter is filled in and fix it. We see the line:
PrintDataAmount in Words.Amount in Words = General PurposeBPCall Server.Generate Amount in Words(AmountKWords, Document Details.Currency);

We look with a debugger where the dog rummaged. In appearance, everything is Fildipersian, but we see a number instead of a string. We see that when calling the function of the common module General Purpose BP Call Server. Generate Amount In Word in parameter Document Details.Currency empty. There are many options for fixing - you can pull out the procedure GenerateAmountWords into the WPF module, you can see the filling of the line DetailsAbout the document and fill in the currency there, you can check the filling of the currency, and if there is empty use the default currency from the constant. I'm too lazy, so let's take the currency from the contract:

Print DataAmount in Words.Amount in Words = General Purpose BPCall Server.Generate Amount in Words(AmountK in Words, Document Details.Counterparty Agreement.Currency of Mutual Settlements);//Document Details.Currency);

Save and check:

  • Now let's add a new parameter to the layout, for example, a Comment, and display it after the final line (the example is conditional, just as an example)))):

This article will describe in detail how a beginner who does not know 1C 8 well to create a printable. For example, let's take one of the most common 1C 8 configurations - Accounting 2.0. Creating a printable 1C stages of writing:

  • Creating an external printable file;
  • Creation of a printed form layout;
  • Writing a program code for displaying printed form data on the screen;
  • Creation of parameters for auto-registration of a printed form;
  • Connecting an external printing form to the base 1C Enterprises.

Creation of a printed form 1C. Formulation of the problem

We are required in the configuration Accounting 2.0 create a printable for a document Receipt of goods and services. In the header of the printed form, display the following data:

  • Organization;
  • Counterparty;
  • counterparty agreement;
  • Date of receipt.

Display table data in tabular form Products document. The table should include the following columns:

  • Nomenclature;
  • Quantity;
  • Price;
  • Sum;
  • As well as the price of the item for the current date (by type of prices from the document).

External processing file

Let's move on to solving the problem. To get started, open 1C 8 in mode Configurator. It is in this mode that all developments are carried out on the 1C 8 platform. Now we need to create an external processing file. To do this, click on the menu File -> New... or by the icon of the new file.

In the window that opens, select the item External processing.

Further into the field Name you must enter the name of the external processing. In our case, let's call it simply: "Printing Form", the synonym field will be filled in automatically. Please note that in the field Name, external processing, the name should be written without spaces and punctuation marks.

Add an external processing attribute ObjectReference and select for him type DocumentReference.Receipt of GoodsServices. To do this, in the metadata tree of external processing 1C, select the item Requisites and press the button Add(green plus button). In the right part of the screen, the attribute properties window will open, in the field Name write - LinkToObject. AT field Type press the button with three dots.

Expand the branch in the type tree DocumentLink, and find the item Receipt of Goods and Services there, check the box next to it and click OK.

Let's save the external processing file to the hard drive, for this we will use the menu File -> Save, icon Save(blue floppy disk) or a keyboard shortcut ctrl+s. Let's name the saved file "PrintForm".

Create a printable layout

Let's start creating a 1C printable layout. The layout serves as a template for the output of the printable, so if you want your printable to look good, you should pay attention to it.

Let's add a new layout in the external processing metadata tree, we won't change anything in the layout designer window and press the button Ready.

In the new layout that opens, let's create several areas needed to display the printed form. All the layout areas we need will be horizontal, so to create a new area, select the required number of layout lines and go to the menu Table -> Names -> Assign Name or use keyboard shortcut Ctrl+Shift+N then enter the name of the region in the box. When creating a layout area, do not be afraid to make a mistake with the number of lines; you can always add or remove them. To delete a 1C layout row, select the desired row and select the item in the context menu Delete. To add a new line to the layout, select any line of the layout and select the item in the context menu push apart.

Adding a Layout Header

Let's create an area first. A cap, it will display the data for the header of the printed form. For this area, we need seven layout lines. Select them and, as I wrote above, press the keyboard shortcut Ctrl+Shift+N, in field Name write "Hat" and press the button OK.

Let's fill the layout area with the data we need. Usually, no printed form is complete without a header, so we will create it in our layout header as well. Since in the header, in addition to the name of the printed form, we will also display the number of the document from which it was printed, we will set the text of the header in the layout as a parameter. A layout parameter is a specially designated layout cell into which various data can be displayed using the built-in 1C 8 language. The title should be displayed on the entire width of the printed form, so let's decide how many layout cells will be enough for us to print on the standard landscape orientation of the sheet.

Usually thirteen or fourteen layout cells are enough, select them in the first line of the area A cap and merge into one cell ( Context Menu -> Merge). After that, double-click on the resulting large cell and write the name of the parameter, in our case "HeaderText". In order for the entered text to become a full-fledged parameter, right-click on the cell and select the item in the context menu Properties. Bookmark Layout find a field filling and choose the value Parameter. The parameters in the 1C layout are indicated by brackets "<>».

The title of the printed form should stand out among other text, so once again select the cell and use the icons on the layout formatting panel to set the text alignment Centered and font size 14.

After the title text, we will display in the area A cap data on the organization, counterparty, counterparty agreement and the date of receipt of the goods. Since all this data is also taken from the document, we will also decorate them with parameters. In addition, before each parameter, you should write an explanatory text so that the user can easily understand where the organization is, and where the counterparty is, etc. All these actions are similar to creating a header, so I will not dwell on them in detail, I will only give a picture with what should turn out in the end.

The figure shows how the layout options differ from plain text.

Adding a Layout Table Header

The last thing we need to create in this layout area is the table header, in which the data of the tabular part will be displayed. Products. The columns required for the table were described in the "Problem Statement" section. We will also create a table header using the merging of cells and writing text (column names). Select the borders of the table header using the tool Frame, which is located in the layout formatting bar.

Adding a table to a layout

Let's create another area in the layout - Data. It will display the data table of the tabular part Products. We only need one layout line for this area. To display all the lines of the tabular part in a printed form, we will fill in and display this area the required number of times. Speakers in the area Data must match the columns of the table header, so filling it out will not be difficult. The only difference is in the area Data we need options, not just text. Also note that by default numeric parameters are formatted on the right margin and text parameters on the left. To select columns, you also need to use the tool Frame.

Adding a Footer to a Layout

The last area of ​​the layout we need is Basement. It will display totals by quantity and amount. Creation is similar to creation of an area Data, but in addition, the results should be highlighted in bold.

The result should be a layout that looks like this:

Creation of a printed form 1C. Programming

Let's start programming - this is the most important stage in creating a printed form. First of all, let's go to the module of the external printing plate object, this is where we will program. To do this, in the main window of external processing, press Actions -> Open object module.

In the external printing form object module, you need to create an export function Seal().

Function Print() Export EndFunction

Please note that this feature is required for external printables in configurations using a regular application. We will write all subsequent program code necessary to display the printed form inside this function.

Initializing Basic Variables

Let's create a variable TabDoc, which will contain a spreadsheet document - it is he who is the printed form into which we will display the filled areas of the layout.

TabDoc = new SpreadsheetDocument;

into a variable Layout we will receive the printed form layout created by us. To do this, we use the built-in function GetLayout(<ИмяМакета>).

Layout = GetLayout("Layout");

We will get all areas of the layout into variables. To do this, we use the layout method GetRegion(<ИмяОбласти>) .

Header Area = Layout. GetArea("Header"); AreaData = Layout.GetArea("Data"); AreaFooter = Layout.GetArea("Basement");

Displaying the printable header in a spreadsheet document

All necessary variables are initialized. Let's start filling and displaying layout areas in a spreadsheet document. First of all, let's fill in the title of the printed form, for this we need to pass in the parameter Title Text, which we created in the layout, the text we need. To fill in the parameter values, the layout area has a special collection, which is called - Options. From which through the "." you can get any parameter. In the title text we will pass the text: “Printing form”, as well as the document number.

Header Area.Parameters.HeaderText = "Printing Form"+ReferenceToObject.Number;

The remaining parameters of the header will be filled in a similar way, all the values ​​​​required for them will be obtained from the props ReferenceToObject, which contains a link to the document to be printed.

Header Area.Parameters.Organization = LinkToObject.Organization; Header area.Parameters.Account = LinkToObject.Account; Header Area.Parameters.IncomingDate = ObjectReference.Date; Header Area.Parameters.Counterparty Agreement = LinkToObject.Counterparty Agreement;

All header parameters are filled in, we will display it in the spreadsheet document we created, for this we use the method output(<Область>) .

TabDoc.Output(HeaderArea);

Writing a request for a printed handicap

Let's start filling and displaying the area Data. Creating a 1C printable also implies writing a query, we need it to get the data of the tabular part Products and prices Nomenclatures for the current date we will use Request. The 1C 8 query language is similar to SQL, or rather, practically copies the capabilities of its SELECT statement, but the entire query is written in Russian. Therefore, if you are at least remotely familiar with SQL, then you will easily understand the 1C 8 query language.

In this printed form, the request will be quite simple and many will say that one could do without it, but knowledge of the query language and the ability to use it correctly is one of the main skills of a 1C programmer. Queries allow using fewer resources to obtain the most complex data samples, and it is also much easier to understand the text of the query than in the program code written without using the query (or with minimal use of it). In addition, 1C 8 has a very good query builder that allows you to interactively collect a query from the necessary tables.

Let's create a variable that will contain the request.

Request = New Request;

The text of the request will be composed using the query builder. Let's start by writing:

Request.Text = "";

Put the mouse cursor between the quotes, press the right mouse button. In the context menu that opens, select the item Request constructor, it will help us a lot in creating a 1C printable. After that, the query designer window will open, it contains many tabs, but our query will only need four: "Tables and Fields", "Relationships", "Conditions", "Joins / Aliases".

For our query, we need two tables: the tabular part Products document Receipt of goods and services and a slice of the latest information on the current date of the register Item prices.

In the left part of the designer window, find the column Database. It contains a tree of all metadata objects, let's find the ones we need. To do this, open the branch Documentation and find the document Incoming Goods Services, expand it and find the tabular part Products, drag it to the column of the query designer tables. There are three ways to drag and drop: by dragging, by double-clicking on the table, or by selecting it and clicking the ">" button. Let's open a branch RegistersInformation and find a table there PricesItems.SliceLast, also drag it to the column tables. These two tables are enough for our query.

Let's select the fields we need from the resulting tables. To do this, in the column tables open the table and find the fields: Nomenclature, Amount, Price, Quantity and drag them to the third column of the constructor - fields. Let's open the table , find the field Price and also drag it to fields.

The structure of the tables and fields of our request is ready, now let's deal with the conditions. We need the data of the tabular part Products were not taken from all receipts, but only from the one that we print. To do this, we impose a condition on the table Incoming Goods Services Goods. Let's go to the "Conditions" tab of the query builder. In a collumn fields the tables we selected earlier are located, for the condition we need the field Link from the table Receipt of Goods, Services, Goods, drag it to the Conditions window.

In 1C queries, you can use parameters, they are needed in order to transfer data to the query. For example, if we want to limit the selection of documents to a specific document, then we can use a parameter to pass a link to this document to the request and use this parameter in the condition. This is exactly what we will do in our request.

Once out the window Conditions we added a field Link, the query builder will create a parameter with the same name and place it after the "=" sign. This parameter can be renamed if desired. In the text of the request, the parameters are marked with the "&" sign, but in this case this is not necessary, since it is assumed that the second part of the condition contains a parameter, you just need to remember it. How to pass a value to a 1C request parameter will be discussed below.

Since in the query we do not use the full price table of the item, but a virtual one (a slice of the latter in this case), we need to set the conditions for the formation of this virtual table, in our case this is the date of the cut and a condition for the type of prices (prices must be selected that have a strictly defined price type - the one that is specified in the receipt document that we print).

To fill in the parameters of the virtual table, go to the tab Tables and fields query constructor, in the column tables select the table PricesItemsSliceLatest and press the button Virtual Table Options located at the top. In the window that opens, in the field Period you should set the parameter to which the date for which the price cut will be made will be passed. In our case, this will be the current date (that is, today), so we will name the parameter "&CurrentDate". In the condition field, we will write the conditions for the price type, we will also pass it in the parameter, which we will call “&PriceType”. The resulting condition will look like this (where Price Type- register measurement Item prices):

PriceType = &PriceType

The parameters of the virtual table are filled, click the button OK.

Now that we have limited the selection to only the document we need, let's create relationships between the query tables. If this is not done, then the prices from the table PricesItemsSliceLast will not be associated with the item from the receipt. Let's go to the tab Connections query builder. Let's create a link by field Nomenclature between our two tables. To do this, press the button Add, in field Table 1 choose a table Incoming Goods Services Goods, and in the field Table 2 - PricesItemsSliceLast. In the connection conditions, select the fields Nomenclature from both tables.

It should also be noted that in the query selection we need to get all the rows from the tab-part Products and prices only if they are available for the current date by document price type. Thus, these tabparts Products are mandatory, but price cutoff data is not. Therefore, in the links between these tables, it is necessary to use the so-called LEFT JOIN, and the left (or mandatory) table will be Incoming Goods Services Goods, and the right (or optional) PriceItemSliceLast. In order for the left join of the query tables to work as I described above, you need to check the box All after the field Table 1.


The request is almost ready, it remains only to work a little on the field aliases. Go to bookmark Unions / Aliases and set an alias for the field PricesItemsSliceLast.Price. The alias name will be − PriceForToday, it is needed so that the names of the query selection fields and the names of the parameters in the layout of the printed form match.

The work in the query designer is over, let's press the OK button. After the constructor window closes, you will see that the line with the request text is filled in and looks like this:

Request. Text = "Choose | receipt of services. Nomenclators, | receipt of services. Summary goods, | receipt of services. Crouping goods. Products, | Investigation services. Complexities, | prices of the prisoners of the next day. (| &CurrentDate, PriceType = &PriceType) AS PricesItemsSliceLast | By Incoming GoodsServicesGoods.Nomenclature | = PricesItemsSliceLast.Nomenclature |WHERE | Incoming GoodsServicesGoods.Reference = &Reference";

Execution of a request

We will pass the necessary parameters to the request, for this we will use the request method setParameter(<ИмяПараметра>,<Значение>). To get the current date, use the built-in function The current date(), it returns the date and time of the computer.

Let's execute a query to get a selection with the data we need. To do this, we first use the query method Execute(), and then the method Choose().

Selection = Query.Execute().Select();

Filling out the printable table

As a result, in the variable Sample will contain a selection of query results, you can navigate through it using the method Next(), and to bypass the whole one will need a loop Till. The structure will look like this:

While Selection.Next() Loop EndCycle;

It is in this cycle that we will fill and display the layout area Data. But first, let's initialize two variables of a numeric type. In them we will collect the totals by the number and amount that we need to display in the area Basement.

TotalSum = 0; TotalNumber = 0;

Inside the loop, we will fill the area Data data from the current selection element into variables TotalSum and TotalNumber add sum and quantity values, and finally, display the area in a spreadsheet document using the method already familiar to us output(). Since the field names of our request are exactly the same as the field parameter names Data, then for filling we will use the built-in procedure FillPropertyValues(<Приемник>, <Источник>) that copies the property values<Источника>to properties<Приемника>.

While Selection.Next() Loop FillPropertyValues(DataArea.Parameters, Selection); TotalSum = TotalSum + Sample.Sum; TotalQuantity = TotalQuantity + Sample.Quantity; TabDoc.Output(DataArea); EndCycle;

Output of the footer of the printing form into a spreadsheet document

It remains to fill and display the last area of ​​the layout - Basement. We have already prepared the data for filling, filling and output are carried out according to the same scheme.

AreaBasement.Parameters.TotalQuantity = TotalQuantity; RegionBasement.Parameters.TotalAmount = TotalAmount; TabDoc.Output(RegionFooter);

The spreadsheet document is completely filled out, it remains to display it on the screen so that the user can view the printed form and, if necessary, print it. But in typical 1C 8 configurations, the procedures of special modules are responsible for the output of external printing forms. Therefore, it is enough to return from the function Seal() completed spreadsheet.

Return TabDoc;

At this stage, the programming is completed and the creation of the printable form 1c is almost complete. Full text of the function Seal() I won’t give it here, you can see it in a printable file, which you can download at the bottom of the article.

Creation of a printed form 1C. Auto-registration options

When connecting an external printable to the database, the system does not automatically determine for which particular document or directory the printable is intended, you have to select it manually. And if another person wrote the printed form, and you are only instructed to connect it, then the choice can become ambiguous. In order to avoid such problems, in all external printables it is necessary to create a layout with auto-registration parameters. If it is created and correctly formatted, the system automatically determines which document or directory the printed form is intended for.

It is done as follows:

  • In external processing, we create a new layout. We call it “Parameters_Autoregistration” (important not to be mistaken!).
  • In the first cell of the layout we write Documentation.(or Reference books.) and the name of the document to which you want to connect the printable.

Connecting to the base of an external printing form

  • Run 1C 8 in mode Company;
  • Go to menu Service -> Additional reports and processing -> Additional external printing forms;
  • Click the button Add;
  • In the window that opens, click the icon Replace external processing file;
  • If you have created auto-registration parameters, then we agree to use them;
  • If you have not created auto-registration parameters, then in the tabular section Accessory of the printing plate add the required document or directory;
  • We press the button OK.

After that, the external printable will be available in the menu Seal document Delivery of goods and services. The creation of a 1C printable on this can be considered complete.

2016-12-01T12:56:42+00:00

In 1C: Accounting 8.3 (version 3.0), a wonderful opportunity has appeared. Now a user in 1C:Enterprise mode can edit printable layouts quite easily.

When can it be helpful? Well, for example, there is some printing form, say, "Demand-invoice" in which you make some changes every time after printing it. Change the font, print out the margins, remove the excess.

So why do it every time?! If we can make these changes to the layout of the printed form once, the program will always display the printed form as we need.

Below, step by step, I will show you how to change the layout of the "Demand-Invoice" printable form. We will add a new field there: "Responsible".

1. Create a printed form (by clicking the "Print" button) and click the button (on the right) "More" -> "Change layout" in the form that opens:

2. The printable layout will open. Make the necessary changes to it, but be careful that it doesn't work here. I will say right away that fonts and field sizes can be changed exactly, but to delete existing fields (especially those in<угловых скобках>) is not worth it. If you want to hide a field in<угловых скобках>, just make it invisible (color or size), but it should remain on the form, as it is required by the 1C program code.

3. We will add the "Owner" field and click the "Save and close" button.

4. The printing plate was reshaped in a new form as we wanted.

If, after changing the printing form, it stopped working, then you.

Sincerely, Vladimir Milkin(teacher and developer).

So! There is a configuration (for example, "Trade Management", edition 10.3), and for it it is necessary to develop an external printable. For example, let's take a standard document "Invoice for payment to the buyer" (although external printing forms can be created not only for documents, but also for directories).

Example for 1C 8.3 (Managed Forms)

An example of developing an external printable for a managed application can be viewed.

Task

Develop an external printed form that will be available from the "Invoice for payment to the buyer" document, and which will contain the name of the organization, counterparty and a list of goods with price, amount and quantity.

Go!

The first thing to do is to create an external processing file. Processing should contain three main points:
  1. Attribute "ReferenceToObject" with type "DocumentReference.InvoiceForPaymentToBuyer"
  2. Layout to be printed
  3. Export Function "Print()" which returns a spreadsheet document
These actions are visible in Figure 1.

"Drawing a Layout"

Our layout will contain two areas:
  1. The title (header) of the document (the names of the organization and the counterparty will be placed in this area), and the header of the table (with the names of the columns)
  2. Table with goods (columns, with name, quantity and amount)
Figure 2 shows the layout of the external printing plate. Note that the table and header cells contain options, not just text.

Function "Print()"

Here is the form almost ready. It remains to write the programmatic filling of the fields of the spreadsheet document. These actions are performed in the processing object module, in a function called "Print", which MUST be exportable.
Stage number 1. Getting data for the header, filling in the header parameters, and outputting it to a spreadsheet document SpreadsheetDocument = New SpreadsheetDocument; Layout = GetLayout("OurLayout"); DataQuery = New Query("SELECT | PRESENT(Invoice To Buyer.Contractor) AS Counterparty, | REPRESENTATION(InvoiceToPayToBuyer.Organization) AS Organization |FROM | Document.InvoiceToPurchaser AS InvoiceToPayToPurchaser |WHERE | InvoiceToPayToPurchaser.Reference = &Reference"); QueryData.SetParameter("Reference", ReferenceToObject); Header = RequestData.Run().Select(); Header.Next(); Area = Layout.GetArea("Header"); Area.Parameters.Fill(Header); SpreadsheetDocument.Output(Region); Stage number 2. Receiving tabular data, and line-by-line output of goods
DataQuery.Text = "SELECT | _Products.LineNumber, | REPRESENTATION(_Products.Nomenclature) AS Nomenclature, | _Products.Quantity, | _Products.Price, | _Products.Amount |FROM | Document.InvoiceFor Buyer.Products AS _Products |WHERE | _Products. Link = &Link"; Selection = RequestData.Execute().Select(); Region = Layout.GetRegion("Data"); While Selection.Next() Loop Area.Parameters.Fill(Selection); SpreadsheetDocument.Output(Region); EndCycle; Stage number 3. Spreadsheet document return and print function Return SpreadsheetDocument;

Adding our external printing form to 1C

Go to the menu "Tools - External printing forms and processing - External printing forms"

In the element creation window that opens, perform the following actions:

  1. Loading the external processing file
  2. We indicate for which document (or directory) the configuration, the printed form is intended
  3. Writing down the changes

Printing!

Open any document "Invoice for payment to the buyer" (with the tabular section "Products" filled in, because it is from there that we take the data to fill in), click the "Print" button, in the window that opens, select OUR printable form, and click "Print"


ATTENTION! This development algorithm is ONLY suitable for "Normal application". Printables for configurations in Managed Application mode are different!

The printable file shown in the example can be

 

It might be useful to read: