Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
L
Lib-PDF
Manage
Activity
Members
Labels
Plan
Issues
2
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Code
JS Toolbox
Lib-PDF
Commits
60b08df6
Commit
60b08df6
authored
3 years ago
by
Zdravko Iliev
Browse files
Options
Downloads
Patches
Plain Diff
qrcode in center
parent
c7b432b6
No related branches found
No related tags found
1 merge request
!1
Draft: Resolve "[Document Sealing] Implement PDF parser"
Pipeline
#49093
passed with stages
in 50 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
dist/pdfParser.js
+15
-6
15 additions, 6 deletions
dist/pdfParser.js
src/pdfParser.ts
+18
-6
18 additions, 6 deletions
src/pdfParser.ts
with
33 additions
and
12 deletions
dist/pdfParser.js
+
15
−
6
View file @
60b08df6
...
...
@@ -48,13 +48,22 @@ class PDFparser {
this
.
insertQrCode
=
(
imgBytes
)
=>
__awaiter
(
this
,
void
0
,
void
0
,
function
*
()
{
const
pdfDoc
=
yield
PDFDocument
.
load
(
this
.
document
);
const
img
=
yield
pdfDoc
.
embedPng
(
imgBytes
);
const
imagePage
=
pdfDoc
.
insertPage
(
0
);
imagePage
.
drawImage
(
img
,
{
x
:
0
,
y
:
0
,
width
:
imagePage
.
getWidth
(),
height
:
imagePage
.
getHeight
(),
// const imagePage = pdfDoc.insertPage(0);
const
pages
=
pdfDoc
.
getPages
();
const
firstPage
=
pages
[
0
];
const
{
width
,
height
}
=
firstPage
.
getSize
();
firstPage
.
drawImage
(
img
,
{
x
:
firstPage
.
getWidth
()
/
2
-
img
.
width
/
2
,
y
:
firstPage
.
getHeight
()
/
2
-
img
.
height
/
2
,
width
:
img
.
width
,
height
:
img
.
height
,
});
// firstPage.drawImage(img, {
// x: 0,
// y: 0,
// width: firstPage.getWidth(),
// height: firstPage.getHeight(),
// });
const
pdfBytes
=
yield
pdfDoc
.
save
();
return
pdfBytes
;
});
...
...
This diff is collapsed.
Click to expand it.
src/pdfParser.ts
+
18
−
6
View file @
60b08df6
...
...
@@ -44,15 +44,27 @@ class PDFparser {
insertQrCode
=
async
(
imgBytes
:
ArrayBuffer
):
Promise
<
ArrayBuffer
>
=>
{
const
pdfDoc
=
await
PDFDocument
.
load
(
this
.
document
);
const
img
=
await
pdfDoc
.
embedPng
(
imgBytes
);
const
imagePage
=
pdfDoc
.
insertPage
(
0
);
//
const imagePage = pdfDoc.insertPage(0);
imagePage
.
drawImage
(
img
,
{
x
:
0
,
y
:
0
,
width
:
imagePage
.
getWidth
(),
height
:
imagePage
.
getHeight
(),
const
pages
=
pdfDoc
.
getPages
();
const
firstPage
=
pages
[
0
];
const
{
width
,
height
}
=
firstPage
.
getSize
();
firstPage
.
drawImage
(
img
,
{
x
:
firstPage
.
getWidth
()
/
2
-
img
.
width
/
2
,
y
:
firstPage
.
getHeight
()
/
2
-
img
.
height
/
2
,
width
:
img
.
width
,
height
:
img
.
height
,
});
// firstPage.drawImage(img, {
// x: 0,
// y: 0,
// width: firstPage.getWidth(),
// height: firstPage.getHeight(),
// });
const
pdfBytes
=
await
pdfDoc
.
save
();
return
pdfBytes
;
...
...
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