Added Pagebreak to Workintime Evaluation
This commit is contained in:
@@ -160,7 +160,40 @@ export const useCreateWorkingTimesPdf = async (input,backgroundSourceBuffer) =>
|
|||||||
|
|
||||||
let rowHeight = 115
|
let rowHeight = 115
|
||||||
|
|
||||||
input.times.forEach(time => {
|
|
||||||
|
let splitted = []
|
||||||
|
|
||||||
|
let reversedInput = input.times.slice().reverse()
|
||||||
|
|
||||||
|
const splittedLength = Math.floor((reversedInput.length - 25) / 40)
|
||||||
|
|
||||||
|
splitted.push(reversedInput.slice(0,25))
|
||||||
|
|
||||||
|
let lastIndex = 25
|
||||||
|
for (let i = 0; i < splittedLength; ++i ) {
|
||||||
|
splitted.push(reversedInput.slice(lastIndex, lastIndex + (i + 1) * 40))
|
||||||
|
lastIndex = lastIndex + (i + 1) * 40 + 1
|
||||||
|
}
|
||||||
|
|
||||||
|
splitted.push(reversedInput.slice(lastIndex, reversedInput.length))
|
||||||
|
|
||||||
|
|
||||||
|
splitted.forEach((chunk,index) => {
|
||||||
|
if(index > 0) {
|
||||||
|
const page = pdfDoc.addPage()
|
||||||
|
|
||||||
|
page.drawPage(secondPageBackground, {
|
||||||
|
x: 0,
|
||||||
|
y: 0,
|
||||||
|
})
|
||||||
|
|
||||||
|
pages.push(page)
|
||||||
|
pageCounter++
|
||||||
|
rowHeight = 20
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
chunk.forEach(time => {
|
||||||
pages[pageCounter - 1].drawText(`${dayjs(time.startDate).format("HH:mm DD.MM.YY")}`,{
|
pages[pageCounter - 1].drawText(`${dayjs(time.startDate).format("HH:mm DD.MM.YY")}`,{
|
||||||
x: getCoordinatesForPDFLib(20,rowHeight,pages[pageCounter -1]).x,
|
x: getCoordinatesForPDFLib(20,rowHeight,pages[pageCounter -1]).x,
|
||||||
y: getCoordinatesForPDFLib(20,rowHeight,pages[pageCounter -1]).y,
|
y: getCoordinatesForPDFLib(20,rowHeight,pages[pageCounter -1]).y,
|
||||||
@@ -182,6 +215,10 @@ export const useCreateWorkingTimesPdf = async (input,backgroundSourceBuffer) =>
|
|||||||
rowHeight += 6
|
rowHeight += 6
|
||||||
|
|
||||||
})
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
uri.value = await pdfDoc.saveAsBase64({dataUri: true})
|
uri.value = await pdfDoc.saveAsBase64({dataUri: true})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user