Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CREATE PROCEDURE [dbo].[fm_tst-pdf_saveItem]
- @username nvarchar(256),
- @itemID int,
- @parameters ExtendedDictionaryParameter READONLY
- -- либо перечислить все поля в форме (@fieldcode и т.д.)
- AS
- BEGIN
- -- сохраняем форму (добавление/обновление некой сущности)
- declare @pname nvarchar(max)
- select @pname = Value2 from @parameters where [key]='name'
- declare @url nvarchar(128) = '/uploads/pdf/'+convert(nvarchar(50), newid())+'.pdf'
- -- SELECT 1 (Result, Msg, SuccessUrl, HideFormAfterSubmit, RefreshContainer)
- select 1 Result, 'OK <a href="'+@url+'">Download PDF</a>' Msg, '' SuccessUrl, 1 HideFormAfterSubmit, '' RefreshContainer
- --select 1 Result, 'Сохранено'
- declare @options nvarchar(max) = N'
- {
- "options": {
- "title": "Test Document"
- },
- "pages": [
- {
- "elements": [
- {
- "type": "text",
- "value": "'+isnull(@pname, 'No name')+N'",
- "alignment": "center",
- "marginTop": "6cm",
- "marginBottom": "0",
- "marginLeft": "0",
- "marginRight": "0",
- "paddingTop": "0cm",
- "paddingBottom": "0",
- "paddingLeft": "0",
- "paddingRight": "0",
- "firstLineIndent": "0cm", //красная строка для абзацев
- "color": "#000000",
- "backgroundColor": "#FFFFFF",
- "font": {
- "size": 30,
- "bold": false,
- "italic": false
- }
- },
- {
- "type": "text",
- "value": "PDF Generator test",
- "alignment": "center",
- "font": {
- "size": 16,
- "italic": true
- }
- }
- ]
- },
- {
- "elements": [
- {
- "type": "image",
- "path": "/uploads/land/finance.jpg",
- "width": "10cm", //соотношение сторон сохраняется, можно указывать либо ширину, либо высоту
- "height": "10cm",
- "alignment": "left",
- //"wrapStyle": "through" //при значении through картинка становится фоном для последующих элементов. По идее здесь же настраиваниется обтекание текста вокруг картинки, пока это не работает
- },
- {
- "type": "text",
- "value": "Text below the image",
- "alignment": "left",
- "font": {
- "size": 14,
- "italic": true
- }
- },
- {
- "type": "line",
- "color": "#333399",
- "thickness": "0.1cm"
- },
- {
- "type": "text",
- "value": "This is a line test",
- "alignment": "right",
- "font": {
- "size": 12,
- "bold": true
- }
- }
- ]
- },
- {
- "elements": [
- {
- "type": "table",
- "border": {
- "width": "0.02cm",
- "color": "#000000"
- },
- "columnWidths": ["4cm", "4cm", "2cm"],
- "headers": ["Column ", "Column 2", "Column 3"],
- "values": [
- ["value 1_1", "value 1_2", "value 1_3"],
- ["value 2_1", "value 2_2", "value 2_3"],
- ["value 3_1", "value 3_2", "value 3_3"],
- ["result", "", ""]
- ],
- "styleOptions": [
- {
- "position": [4, 0], //координаты ячейки, которую правим. [X, Y] - где X - строка, Y - столбец, начиная с нуля, строка 0 - шапка
- "alignment": "right",
- "font": { "bold": true, "italic": false, "family": "Arial", "size": 12 },
- "mergeRight": 2, //объединить n ячеек справа с этой
- "mergeDown": 0 //объединить n ячеек ниже с этой
- }
- ]
- },
- {
- "type": "text",
- "value": "This is a table",
- "color": "#ff3333",
- "backgroundColor": "#ddddff",
- "paddingBottom": "0.2cm",
- "marginTop": "0.1cm"
- },
- {
- "type": "text",
- "value": "Some lists:",
- "marginTop": "1cm"
- },
- {
- "type": "list",
- "listStyle": "ul",
- "items": [
- "item1",
- "item2",
- "item3"
- ]
- },
- {
- "type": "list",
- "listStyle": "ol",
- "items": [
- "item1",
- "item2",
- "item3"
- ]
- },
- {
- "type": "list",
- "listStyle": "ol2",
- "items": [
- "item1",
- "item2",
- "item3"
- ]
- },
- {
- "type": "list",
- "listStyle": "ol3",
- "items": [
- "item1",
- "item2",
- "item3"
- ]
- },
- {
- "type": "text",
- "value": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
- "marginBottom": "0.5cm",
- "firstLineIndent": "1.5cm"
- },
- {
- "type": "text",
- "value": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
- "marginBottom": "0.5cm",
- "firstLineIndent": "1.5cm"
- },
- {
- "type": "text",
- "value": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
- "marginBottom": "0.5cm",
- "firstLineIndent": "1.5cm"
- }
- ]
- }
- ]
- }
- '
- select 'generatepdf' type,
- @url url,
- @options options
- END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement