Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in
Toggle navigation
F
fund_report
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
彭熊
fund_report
Commits
3c728683
Commit
3c728683
authored
Dec 04, 2020
by
pengxiong@wealthgrow.cn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
直接生成pdf
parent
ecb52bcb
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
6 deletions
+11
-6
html_to_pdf.py
app/utils/html_to_pdf.py
+3
-3
jinjia2html.py
app/utils/jinjia2html.py
+8
-3
No files found.
app/utils/html_to_pdf.py
View file @
3c728683
...
...
@@ -23,8 +23,8 @@ def html_to_pdf(source_path, target_path):
'margin-bottom'
:
'0mm'
,
'margin-left'
:
'0mm'
}
#
pdfkit.from_string(source_path, target_path, options=options)
pdfkit
.
from_file
(
source_path
,
target_path
,
options
=
options
)
pdfkit
.
from_string
(
source_path
,
target_path
,
options
=
options
)
#
pdfkit.from_file(source_path, target_path, options=options)
def
merge_pdf
(
pdfFiles
,
target_file
=
'/Users/pengxiong/Desktop/combine.pdf'
):
""""""
...
...
@@ -40,5 +40,5 @@ def merge_pdf(pdfFiles, target_file='/Users/pengxiong/Desktop/combine.pdf'):
if
__name__
==
'__main__'
:
html_to_pdf
(
'/Users/pengxiong/Desktop/fund_report/app/
templates
/v2/monthReportV2.html'
,
'/Users/pengxiong/Desktop/fund_report/app/pdf/
%
s.pdf'
%
str
(
uuid
.
uuid4
()))
html_to_pdf
(
'/Users/pengxiong/Desktop/fund_report/app/
html
/v2/monthReportV2.html'
,
'/Users/pengxiong/Desktop/fund_report/app/pdf/
%
s.pdf'
%
str
(
uuid
.
uuid4
()))
# merge_pdf(['/Users/pengxiong/Desktop/out1.pdf', '/Users/pengxiong/Desktop/out.pdf'])
app/utils/jinjia2html.py
View file @
3c728683
import
time
import
uuid
from
jinja2
import
PackageLoader
,
Environment
...
...
@@ -9,6 +10,7 @@ import numpy as np
# 准备数据
from
app.utils.draw
import
draw_month_return_chart
,
draw_contribution_chart
,
draw_combination_chart
,
\
draw_old_combination_chart
from
app.utils.html_to_pdf
import
html_to_pdf
from
app.utils.radar_chart
import
gen_radar_chart
...
...
@@ -210,9 +212,12 @@ class DataIntegrate:
# with open(save_file, 'w', encoding="utf-8") as f:
# f.write(monthReport_html)
save_file
=
"app/html/v2/monthReportV2.html"
with
open
(
save_file
,
'w'
,
encoding
=
"utf-8"
)
as
f
:
f
.
write
(
monthReport_html
)
# save_file = "app/html/v2/monthReportV2.html"
# with open(save_file, 'w', encoding="utf-8") as f:
# f.write(monthReport_html)
html_to_pdf
(
monthReport_html
,
'/Users/pengxiong/Desktop/fund_report/app/pdf/
%
s.pdf'
%
str
(
uuid
.
uuid4
()))
if
__name__
==
'__main__'
:
start
=
time
.
time
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment