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
8e0dd930
Commit
8e0dd930
authored
3 years ago
by
Zdravko Iliev
Browse files
Options
Downloads
Patches
Plain Diff
add scale factor to inserQrCOde
parent
1d62a8df
No related branches found
No related tags found
1 merge request
!1
Draft: Resolve "[Document Sealing] Implement PDF parser"
Pipeline
#49151
passed with stages
in 49 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
dist/pdfParser.d.ts
+1
-1
1 addition, 1 deletion
dist/pdfParser.d.ts
dist/pdfParser.js
+2
-2
2 additions, 2 deletions
dist/pdfParser.js
src/pdfParser.ts
+3
-2
3 additions, 2 deletions
src/pdfParser.ts
with
6 additions
and
5 deletions
dist/pdfParser.d.ts
+
1
−
1
View file @
8e0dd930
...
@@ -5,7 +5,7 @@ declare class PDFparser {
...
@@ -5,7 +5,7 @@ declare class PDFparser {
readonly
config
:
any
;
readonly
config
:
any
;
constructor
(
document
:
Buffer
);
constructor
(
document
:
Buffer
);
getPDFMeta
:
()
=>
Promise
<
IgetMetaResponse
>
;
getPDFMeta
:
()
=>
Promise
<
IgetMetaResponse
>
;
insertQrCode
:
(
imgBytes
:
ArrayBuffer
,
url
:
string
)
=>
Promise
<
ArrayBuffer
>
;
insertQrCode
:
(
imgBytes
:
ArrayBuffer
,
url
:
string
,
scaleFactor
:
number
)
=>
Promise
<
ArrayBuffer
>
;
private
createPageLinkAnnotation
;
private
createPageLinkAnnotation
;
}
}
export
default
PDFparser
;
export
default
PDFparser
;
This diff is collapsed.
Click to expand it.
dist/pdfParser.js
+
2
−
2
View file @
8e0dd930
...
@@ -46,10 +46,10 @@ class PDFparser {
...
@@ -46,10 +46,10 @@ class PDFparser {
throw
new
Error
(
"
Could not get pdf metadata
"
);
throw
new
Error
(
"
Could not get pdf metadata
"
);
}
}
});
});
this
.
insertQrCode
=
(
imgBytes
,
url
)
=>
__awaiter
(
this
,
void
0
,
void
0
,
function
*
()
{
this
.
insertQrCode
=
(
imgBytes
,
url
,
scaleFactor
)
=>
__awaiter
(
this
,
void
0
,
void
0
,
function
*
()
{
const
pdfDoc
=
yield
PDFDocument
.
load
(
this
.
document
);
const
pdfDoc
=
yield
PDFDocument
.
load
(
this
.
document
);
const
img
=
yield
pdfDoc
.
embedPng
(
imgBytes
);
const
img
=
yield
pdfDoc
.
embedPng
(
imgBytes
);
const
scaled
=
img
.
scale
(
0.2
);
const
scaled
=
img
.
scale
(
scaleFactor
);
const
pages
=
pdfDoc
.
getPages
();
const
pages
=
pdfDoc
.
getPages
();
for
(
let
index
=
0
;
index
<
pages
.
length
;
index
++
)
{
for
(
let
index
=
0
;
index
<
pages
.
length
;
index
++
)
{
const
page
=
pages
[
index
];
const
page
=
pages
[
index
];
...
...
This diff is collapsed.
Click to expand it.
src/pdfParser.ts
+
3
−
2
View file @
8e0dd930
...
@@ -43,12 +43,13 @@ class PDFparser {
...
@@ -43,12 +43,13 @@ class PDFparser {
insertQrCode
=
async
(
insertQrCode
=
async
(
imgBytes
:
ArrayBuffer
,
imgBytes
:
ArrayBuffer
,
url
:
string
url
:
string
,
scaleFactor
:
number
):
Promise
<
ArrayBuffer
>
=>
{
):
Promise
<
ArrayBuffer
>
=>
{
const
pdfDoc
=
await
PDFDocument
.
load
(
this
.
document
);
const
pdfDoc
=
await
PDFDocument
.
load
(
this
.
document
);
const
img
=
await
pdfDoc
.
embedPng
(
imgBytes
);
const
img
=
await
pdfDoc
.
embedPng
(
imgBytes
);
const
scaled
=
img
.
scale
(
0.2
);
const
scaled
=
img
.
scale
(
scaleFactor
);
const
pages
=
pdfDoc
.
getPages
();
const
pages
=
pdfDoc
.
getPages
();
...
...
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