Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Gib Geld FSR
Manage
Activity
Members
Labels
Plan
Issues
1
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
10
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
FS Info TU Dortmund
Fachschaftsrat
Tools
Gib Geld FSR
Commits
e266b702
Commit
e266b702
authored
1 year ago
by
Jonas Zohren
💬
Browse files
Options
Downloads
Patches
Plain Diff
use german date in pdf form
parent
aa860ca6
No related branches found
No related tags found
No related merge requests found
Pipeline
#156097
passed with stage
in 47 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/lib/pdf.ts
+22
-10
22 additions, 10 deletions
src/lib/pdf.ts
with
22 additions
and
10 deletions
src/lib/pdf.ts
+
22
−
10
View file @
e266b702
...
...
@@ -8,6 +8,17 @@ import { UbuntuRBase64 } from './fonts';
// Fetch the Ubuntu font
const
ubuntuFontBuf
=
Uint8Array
.
from
(
atob
(
UbuntuRBase64
),
(
c
)
=>
c
.
charCodeAt
(
0
));
function
currentGermanDate
()
{
const
now
=
new
Date
();
return
(
now
.
getDate
().
toString
().
padStart
(
2
,
'
0
'
)
+
'
.
'
+
now
.
getMonth
().
toString
().
padStart
(
2
,
'
0
'
)
+
'
.
'
+
now
.
getFullYear
().
toString
()
);
}
export
async
function
renderSummaryToPdf
({
title
,
payoutInfo
,
...
...
@@ -20,7 +31,7 @@ export async function renderSummaryToPdf({
pdfDoc
.
setTitle
(
'
Kostenabrechnung
'
+
title
);
pdfForm
.
getTextField
(
'
subject
'
).
setText
(
title
);
pdfForm
.
getTextField
(
'
date
'
).
setText
(
new
Date
().
toUTCString
());
pdfForm
.
getTextField
(
'
date
'
).
setText
(
currentGermanDate
());
spendingItems
.
forEach
((
spendingItem
,
idx
)
=>
{
const
counter
=
idx
+
1
;
const
fieldIdPrefix
=
'
item.
'
+
counter
+
'
.
'
;
...
...
@@ -156,19 +167,20 @@ function drawSignatureBox(titlePage: PDFPage, pageHeight: number, ubuntuFont: PD
});
}
async
function
addSignatureToPage
(
pdfDoc
:
PDFDocument
,
page
:
PDFPage
,
signatureImageBytes
:
Uint8Array
)
{
async
function
addSignatureToPage
(
pdfDoc
:
PDFDocument
,
page
:
PDFPage
,
signatureImageBytes
:
Uint8Array
)
{
const
image
=
await
pdfDoc
.
embedPng
(
signatureImageBytes
);
page
.
drawImage
(
image
,
{
x
:
60
,
y
:
PageSizes
.
A4
[
1
]
-
800
,
width
:
300
,
height
:
80
,
})
height
:
80
})
;
}
async
function
drawTitleTable
(
pdfDoc
:
PDFDocument
,
page
:
PDFPage
,
...
...
@@ -331,8 +343,8 @@ async function addReceiptPages(spendingItems: SpendingItem[], pdfDoc: PDFDocumen
if
(
receipt
.
type
==
'
application/pdf
'
)
{
const
pdfBytes
=
await
receipt
.
arrayBuffer
();
const
receiptPdfDoc
=
await
PDFDocument
.
load
(
pdfBytes
)
const
receiptPages
=
await
pdfDoc
.
embedPages
(
receiptPdfDoc
.
getPages
())
const
receiptPdfDoc
=
await
PDFDocument
.
load
(
pdfBytes
)
;
const
receiptPages
=
await
pdfDoc
.
embedPages
(
receiptPdfDoc
.
getPages
())
;
let
insertedPageCounter
=
0
;
for
(
const
receiptPage
of
receiptPages
)
{
...
...
@@ -357,4 +369,4 @@ async function addReceiptPages(spendingItems: SpendingItem[], pdfDoc: PDFDocumen
}
}
}
}
\ No newline at end of file
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment