Skip to content

Commit

Permalink
Donnerstag 13:45
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Hornburger committed Oct 19, 2023
1 parent 2859821 commit ed9bfdc
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 16 deletions.
3 changes: 2 additions & 1 deletion src/datenstrukturen/thumbnailstrucktur_server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ export type Thumbnailstruktur = {
};


// HEllo Wolrd
// H
//
85 changes: 70 additions & 15 deletions src/routes/saveprotokollerouts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ export class SaveProtokolleroutsClass {
let Thumbnailliste: Thumbnailstruktur[][][];
let Thumbnailbreite: number;
let Thumb: Thumbnailstruktur;
let pdfdoc: any;
let Imagebuffuer: any;
const logoimageblob = await this.ReadLogo();
const browser = await puppeteer.launch();
const page = await browser.newPage();
Expand Down Expand Up @@ -242,7 +244,19 @@ export class SaveProtokolleroutsClass {
Thumbnail = this.GetEmptyThumbnail();
Thumbnail.id = Eintrag.Bilderliste[Thumbindex].FileID;
Thumbnail.weburl = Eintrag.Bilderliste[Thumbindex].WebUrl;
Thumb = await this.ReadThumbnailinfo(Eintrag.Bilderliste[Thumbindex].FileID, Eintrag.Bilderliste[Thumbindex].WebUrl);

try {

Thumb = await this.ReadThumbnailinfo(Eintrag.Bilderliste[Thumbindex].FileID, Eintrag.Bilderliste[Thumbindex].WebUrl);

console.log('Thumnbnailinfos wurde gelesen: ' + Thumbnail.weburl);

}
catch (error) {

res.status(500).send({ Error: error.message });
}


if(Thumb !== null) {

Expand All @@ -251,8 +265,22 @@ export class SaveProtokolleroutsClass {
Thumbnail.mediumurl = Thumb.mediumurl;
Thumbnail.largeurl = Thumb.largeurl;

Content = await this.ReadThumbnailcontent(Thumbnail, Eintrag.Thumbnailsize);
let Imagebuffuer = await Content.arrayBuffer(); // URL.createObjectURL(Content);
try {


Content = await this.ReadThumbnailcontent(Thumbnail, Eintrag.Thumbnailsize);
Imagebuffuer = await Content.arrayBuffer(); // URL.createObjectURL(Content);

console.log('Thumnbnail wurde geladen.');

}
catch (error) {

res.status(500).send({ Error: error.message });
}



let Image = Buffer.from(Imagebuffuer).toString('base64');
Thumbnail.Content = Image;
}
Expand Down Expand Up @@ -409,16 +437,34 @@ export class SaveProtokolleroutsClass {
html += '</html>';
}

await page.setContent(html, { waitUntil: 'domcontentloaded' });
try {

const pdf = await page.pdf({
margin: { top: '50px', right: '30px', bottom: '50px', left: '30px' },
printBackground: true,
format: 'A4',
displayHeaderFooter: true,
headerTemplate: Header,
footerTemplate: Footer
});
await page.setContent(html, { waitUntil: 'domcontentloaded' });

console.log('PDF Page wurde erstellt.');
}
catch (error: any) {

res.status(500).send({ Error: error.message });
}

try {

pdfdoc = await page.pdf({
margin: { top: '50px', right: '30px', bottom: '50px', left: '30px' },
printBackground: true,
format: 'A4',
displayHeaderFooter: true,
headerTemplate: Header,
footerTemplate: Footer
});

console.log('PDF Dokuemnt wurde erzeugt.');
}
catch (error: any) {

res.status(500).send({ Error: error.message });
}

const msalConfig = {
auth: {
Expand All @@ -434,7 +480,17 @@ export class SaveProtokolleroutsClass {
scopes: ['https://graph.microsoft.com/.default'],
};

token = await msalClient.acquireTokenByClientCredential(tokenRequest);
try {

token = await msalClient.acquireTokenByClientCredential(tokenRequest);

console.log('Token wurde erstellt.');
}
catch (error: any) {

res.status(500).send({ Error: error.message });
}


const graphClient = Client.init({

Expand All @@ -444,12 +500,11 @@ export class SaveProtokolleroutsClass {
}
});

// let Url = '/groups/' + TeamsID + '/drive/items/' + DirectoryID + ':/' + Filename + ':/content';
let Url = '/sites/' + this.Const.BAESiteID + '/drive/items/' + DirectoryID + ':/' + Filename + ':/content';

try {

putdata = await graphClient.api(Url).put(pdf);
putdata = await graphClient.api(Url).put(pdfdoc);

console.log('Protokoll ' + Filename + ' wurde erstellt.');

Expand Down

0 comments on commit ed9bfdc

Please sign in to comment.