Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
df1224860a | ||
|
|
f8db8c87eb |
11
bookshop/mtx/sidecar/package.json
Normal file
11
bookshop/mtx/sidecar/package.json
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"name": "mtx-sidecar", "version": "0.0.0",
|
||||||
|
"dependencies": {
|
||||||
|
"@sap/cds-mtxs": "^1",
|
||||||
|
"@sap/cds": "^6",
|
||||||
|
"express": "^4"
|
||||||
|
},
|
||||||
|
"cds": {
|
||||||
|
"profile": "mtx-sidecar"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -20,8 +20,10 @@
|
|||||||
"watch": "cds watch"
|
"watch": "cds watch"
|
||||||
},
|
},
|
||||||
"cds": {
|
"cds": {
|
||||||
|
"profile": "with-mtx-sidecar",
|
||||||
"requires": {
|
"requires": {
|
||||||
"db": "sql"
|
"multitenancy": true,
|
||||||
|
"db": { "kind": "sql" }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +1,5 @@
|
|||||||
using CatalogService from '@capire/bookstore';
|
using CatalogService from '@capire/bookstore';
|
||||||
|
|
||||||
using from '@sap/cds-pdf-export';
|
|
||||||
|
|
||||||
annotate CatalogService with @(
|
|
||||||
Capabilities: { SupportedFormats : [ 'application/pdf' ] },
|
|
||||||
PDF.Features: {
|
|
||||||
DocumentDescriptionReference : '/-pdf/',
|
|
||||||
DocumentDescriptionCollection : 'createDocumentDescription'
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// Books Object Page
|
// Books Object Page
|
||||||
|
|||||||
@@ -43,16 +43,6 @@
|
|||||||
"[production]": {
|
"[production]": {
|
||||||
"model": "db/hana"
|
"model": "db/hana"
|
||||||
}
|
}
|
||||||
},
|
|
||||||
"pdf": {
|
|
||||||
"kind": "btp-adobe-forms",
|
|
||||||
"vcap": {
|
|
||||||
"label": "adsrestapi"
|
|
||||||
},
|
|
||||||
"[pdfme]": {
|
|
||||||
"kind": "export-pdf",
|
|
||||||
"impl": "./pdfme.js"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"hana": {
|
"hana": {
|
||||||
|
|||||||
@@ -1,38 +0,0 @@
|
|||||||
const { generate, BLANK_PDF } = require("@pdfme/generator");
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Generate PDF with @pdfme/generator library
|
|
||||||
*/
|
|
||||||
module.exports = async (data, headers) => {
|
|
||||||
|
|
||||||
let inputs = data
|
|
||||||
|
|
||||||
let x = 0, y = 0;
|
|
||||||
const width = 30;
|
|
||||||
const height = 5;
|
|
||||||
|
|
||||||
const tableSchema = {}
|
|
||||||
for (const entry of headers) {
|
|
||||||
x += width;
|
|
||||||
tableSchema[entry.Name] = {
|
|
||||||
type: 'text',
|
|
||||||
position: { x, y: 10 },
|
|
||||||
width,
|
|
||||||
height
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const row of data) {
|
|
||||||
for (const [key, value] of Object.entries(row)) {
|
|
||||||
if (typeof value !== 'string') row[key] = ''+value // stringify
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const template = {
|
|
||||||
basePdf: BLANK_PDF,
|
|
||||||
schemas: [tableSchema]
|
|
||||||
};
|
|
||||||
const pdf = await generate({ template, inputs });
|
|
||||||
|
|
||||||
return pdf;
|
|
||||||
};
|
|
||||||
6
package-lock.json
generated
6
package-lock.json
generated
@@ -446,9 +446,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@sap/cds": {
|
"node_modules/@sap/cds": {
|
||||||
"version": "6.6.1",
|
"version": "6.6.0",
|
||||||
"resolved": "https://registry.npmjs.org/@sap/cds/-/cds-6.6.1.tgz",
|
"resolved": "https://registry.npmjs.org/@sap/cds/-/cds-6.6.0.tgz",
|
||||||
"integrity": "sha512-1JKiYO+N9m5UME7aejce4K5j6mDLkQC0P6BWcHoQJtDjkjsVc6LCLNd06RJqU8XcxeGd3EwIF33GJTLDyGIkUQ==",
|
"integrity": "sha512-+rJQIsirbHNVpzZQsTpHzzbcxPM8Y5gEAQtK8blxlukluvyk6IqrwA1eoJH8grab+DtXqcUqT8c0ooGfnCrbPw==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@sap/cds-compiler": "^3.2.0",
|
"@sap/cds-compiler": "^3.2.0",
|
||||||
"@sap/cds-foss": "^4"
|
"@sap/cds-foss": "^4"
|
||||||
|
|||||||
Reference in New Issue
Block a user