Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
slider
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
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
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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tuhe
slider
Commits
7ac8806a
Commit
7ac8806a
authored
Mar 10, 2023
by
tuhe
Browse files
Options
Downloads
Patches
Plain Diff
fixed pdf file reader
parent
282d91b8
No related branches found
No related tags found
No related merge requests found
Pipeline
#14231
failed
Mar 10, 2023
Stage: test
Stage: deploy
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/slider/slide.py
+3
-19
3 additions, 19 deletions
src/slider/slide.py
with
3 additions
and
19 deletions
src/slider/slide.py
+
3
−
19
View file @
7ac8806a
#!python
# The above makes the script executable.
import
os
from
slider
import
legacy_importer
from
slider.legacy_importer
import
SVG_EDIT_RELPATH
,
SVG_TMP_RELPATH
,
move_template_files
,
DTU_beamer_base
,
svg_edit_to_importable
...
...
@@ -24,7 +23,6 @@ def fix_handout(s):
def
_get_osvg_labels
():
pass
def
set_svg_background_images
(
lecture_tex
,
verbose
=
False
,
...
...
@@ -50,9 +48,6 @@ def set_svg_background_images(lecture_tex, verbose=False,
force_fix_broken_osvg_files
=
[]
if
force_fix_broken_osvg_files
is
None
else
force_fix_broken_osvg_files
NO_SVG_TMP_DIR
=
SVG_TMP_DIR
+
"
/no_svg_tmp
"
# if not os.path.isdir(NO_SVG_TMP_DIR):
# os.mkdir(NO_SVG_TMP_DIR)
if
os
.
path
.
isdir
(
NO_SVG_TMP_DIR
):
for
f
in
glob
.
glob
(
MAIN_TEX_DIR
+
"
/*_NO_SVGS.*
"
):
shutil
.
move
(
f
,
MAIN_TEX_DIR
+
"
/
"
+
os
.
path
.
basename
(
f
))
...
...
@@ -84,11 +79,9 @@ def set_svg_background_images(lecture_tex, verbose=False,
ii
=
all_tex
.
find
(
s
)
frame_start
=
all_tex
.
rfind
(
"
\\
begin{frame}
"
,
0
,
ii
)
frame_end
=
all_tex
.
find
(
"
\\
end{frame}
"
,
ii
,
len
(
all_tex
))
cs
=
all_tex
[
frame_start
:
frame_end
]
d
=
{
"
pdf_label
"
:
s
,
"
svg_edit_file
"
:
MAIN_TEX_DIR
+
"
/
"
+
SVG_EDIT_RELPATH
+
"
/
"
+
s
+
"
.svg
"
,
'
slide_tex
'
:
cs
}
sinfo
[
s
]
=
d
# print(d)
if
not
os
.
path
.
exists
(
MAIN_TEX_DIR
+
"
/
"
+
SVG_EDIT_RELPATH
):
os
.
mkdir
(
MAIN_TEX_DIR
+
"
/
"
+
SVG_EDIT_RELPATH
)
...
...
@@ -101,7 +94,7 @@ def set_svg_background_images(lecture_tex, verbose=False,
# find and fix the import
dc2
=
"
\\
input{
"
j1
=
s
.
find
(
dc2
)
+
len
(
dc2
)
j2
=
s
.
find
(
dc2
)
+
s
.
find
(
"
}
"
,
s
.
find
(
dc2
))
j2
=
s
.
find
(
"
}
"
,
s
.
find
(
dc2
))
fhead
=
MAIN_TEX_DIR
+
"
/
"
+
s
[
j1
:
j2
]
+
"
.tex
"
with
open
(
fhead
,
'
r
'
)
as
f
:
sh
=
f
.
read
()
...
...
@@ -138,7 +131,7 @@ def set_svg_background_images(lecture_tex, verbose=False,
# Make .png background images.
import
PyPDF2
# Import PyPDF2 here. There is a strange issue (possibly bad package version?) which makes it inappropriate as a top-level import (CI/CD Breaks).
with
open
(
lecture_tex_nosvg_pdf
,
'
rb
'
)
as
f
:
pdfdoc
=
PyPDF2
.
Pdf
File
Reader
(
f
)
pdfdoc
=
PyPDF2
.
PdfReader
(
f
)
for
i
in
range
(
pdfdoc
.
getNumPages
()):
content
=
pdfdoc
.
getPage
(
i
).
extractText
()
for
osvg_name
,
d
in
sinfo
.
items
():
#enumerate(sinfo):
...
...
@@ -184,7 +177,6 @@ def set_svg_background_images(lecture_tex, verbose=False,
ANY_CHANGES
=
True
if
ANY_CHANGES
and
recompile_on_change
:
latexmk
(
lecture_tex
)
if
clean_temporary_files
:
...
...
@@ -204,20 +196,13 @@ def set_svg_background_images(lecture_tex, verbose=False,
for
f
in
glob
.
glob
(
MAIN_TEX_DIR
+
"
/*_NO_SVGS.*
"
):
shutil
.
move
(
f
,
NO_SVG_TMP_DIR
+
"
/
"
+
os
.
path
.
basename
(
f
))
# if os.path.exists(DNE):
# for v in glob.glob(DNE + "/*"):
# if not v.endswith("png"):
# os.remove(v)
a
=
234
def
slide_no_by_text
(
pdf_file
,
text
):
assert
False
# Make .png background images.
if
os
.
path
.
exists
(
pdf_file
):
with
open
(
pdf_file
,
'
rb
'
)
as
f
:
print
(
pdf_file
)
pdfdoc
=
PyPDF2
.
Pdf
File
Reader
(
f
)
pdfdoc
=
PyPDF2
.
PdfReader
(
f
)
for
i
in
range
(
pdfdoc
.
getNumPages
()):
content
=
pdfdoc
.
getPage
(
i
).
extractText
()
# for j, d in enumerate(sinfo):
...
...
@@ -302,4 +287,3 @@ def recursive_tex_collect(doc):
lines
=
gathersub
(
doc
)
return
"
\n
"
.
join
(
lines
)
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