<% grid = @page.forms.grid @props.gh = @addForm('grid').gridHelper() gridWidth = @props.gh.width() horizontalGrid = (grid.modelId == 'horizontal-grid') verticalGrid = (grid.modelId == 'vertical-grid') columnsGrid = (grid.modelId == 'columns-grid') reportGrid = (grid.modelId == 'report-grid') formWidth = "{$formwidth_grid}" formWidth = grid.recsPerRow if verticalGrid formWidth = grid.pdfFormWidth( @self() ) if reportGrid formWidth = 1 if columnsGrid gridHeaderRows = 0 gridHeaderRows = grid.getSectionHeight("head") if horizontalGrid borderWidth = 0.1 borderWidth = 0 if verticalGrid || columnsGrid if verticalGrid || columnsGrid columnWidths = [] columnWidths.push '*' for col in [1..(formWidth)] else if reportGrid columnWidths = [] columnWidths.push '%' for col in [1..(formWidth)] else columnWidths = grid.pdfColumnWidths( @props.gh ) rowHeights = [] if !verticalGrid && !columnsGrid && !reportGrid rowHeights = @page.forms.grid.pdfRowHeights( @props.gh ) %> pdfDocument = { {BEGIN backgroundImage} background: { image: {$backgroundImage}, {BEGIN bgWidth} imgWidth: {$bgWidth}, imgHeight: {$bgHeight}, {END bgWidth} }, {END backgroundImage} styles: { <% include "pdf/style.htm", @self() %> <% if @page.type == 'rprint' : %> <% include "pdf/report-style.htm", @self() %> <% end %> }, defaultStyle: { <% include "pdf/default-style.htm", @self() %> }, "content": [ {BEGIN body} {BEGIN embedded_grid_caption} { text: '{$jscaption <%- @goodFieldName( this.th.get.name ) %>}', }, {END embedded_grid_caption} {BEGIN embedded_page_title} { text: '<%- @pageTitle( true ) %>', }, {END embedded_page_title} { {BEGIN standalone_page} pageBreak: 'before', standAlonePage: true, {END standalone_page} {BEGIN embedded_grid} embeddedPage: true, {END embedded_grid} layout: { hLineWidth: function(i, node) { return <%- borderWidth %>; }, vLineWidth: function(i, node) { return <%- borderWidth %>; }, hLineColor: function(i, node) { return 'lightgray'; }, vLineColor: function(i, node) { return 'lightgray'; }, }, table: { {BEGIN embedded_grid} embeddedPage: true, {END embedded_grid} tableForm: true, headerRows: 1 <% if gridHeaderRows > 0 : %> <% for row in [0..(gridHeaderRows-1)] : %> {BEGIN row_grid_<%- row %>} +1 {END row_grid_<%- row %>} <% end %> <% end %> {BEGIN embedded_grid} -1 {END embedded_grid} , widths: [ <% if verticalGrid || reportGrid || columnsGrid : %> <% for w, i in columnWidths : %> <%- JSON.stringify(w) %>, <% end %> <% else : %> <% for w, i in columnWidths : %> {BEGIN col_grid_<%- i %>} <%- JSON.stringify(w) %>, {END col_grid_<%- i %>} <% end %> <% end %> ], <% if rowHeights.length : %> <% bodyIndices = @page.forms.grid.getBodyRowIndices() %> heights: [ // first height for header part "%", <% for h, row in rowHeights : %> <% if row == bodyIndices[ 0 ] : %> {BEGIN grid_row} <% end %> {BEGIN row_grid_<%- row %>} <%- JSON.stringify( h ) %>, {END row_grid_<%- row %>} <% if row == bodyIndices[ bodyIndices.length - 1 ] : %> {END grid_row} <% end %> <% end %> ], <% end %> body: [ {BEGIN standalone_page} [ { colSpan: <%- formWidth %>, border:[false, false,false,false], stack: [ <% location = 'top' %> <% if @page.forms[ location ] : %> <% include @page.forms[ location ].pdfTemplate( @addForm( location ) ), @addForm( location ) %>, <% end %> <% location = 'above-grid' %> <% if @page.forms[ location ] : %> <% include @page.forms[ location ].pdfTemplate( @addForm( location ) ), @addForm( location ) %>, <% end %> ] }, ], {END standalone_page} <% location = 'grid' %> <% if @page.forms[ location ] : %> <% include @page.forms[ location ].pdfTemplate( @addForm( location ) ), @addForm( location ) %> <% end %> ] } }, {END body} ], footer: [ <% location = 'below-grid' %> <% if @page.forms[ location ] : %> <% include @page.forms[ location ].pdfTemplate( @addForm( location ) ), @addForm( location ) %> <% end %> ], <% if @page.pdfFooterHeight : %> pageMargins: [40, 40, 40, <%- @page.pdfFooterHeight %>], <% end %> }; pdfFonts = {$pdfFonts};