Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
plugin_dbui
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
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
w2pext
plugin_dbui
Commits
7a897195
Commit
7a897195
authored
13 years ago
by
tux091
Browse files
Options
Downloads
Patches
Plain Diff
Fully running view translating a latex file into pdf.
parent
013f62a3
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
views/reports/report_2.pdf
+44
-0
44 additions, 0 deletions
views/reports/report_2.pdf
with
44 additions
and
0 deletions
views/reports/report_2.pdf
0 → 100644
+
44
−
0
View file @
7a897195
{{include 'reports/report_2.latex'}}
{{
import cStringIO
import os
from subprocess import call
from tempfile import TemporaryFile
from uuid import uuid4
# recuperate the latex string generate by the latex view
# and remove it from the response object
latex = response.body.getvalue()
response.body = cStringIO.StringIO()
# go to the private directory and create a latex file
cwd = os.getcwd()
os.chdir(os.path.join(request.folder, 'private'))
fn = str(uuid4())
fi = open('%s.tex' % fn, 'wb')
fi.write(latex)
fi.close()
# convert the latex file into pdf
cmd = ['pdflatex', '-interaction', 'nonstopmode', '%s.tex' % fn]
call(cmd, stdout=TemporaryFile())
# copy the pdf in the new response
fi = open('%s.pdf' % fn, 'rb')
response.headers['Content-Type']='application/pdf'
response.write(fi.read(), escape=False)
# clean file
for ext in ('aux', 'log', 'pdf', 'tex'):
f = '%s.%s' % (fn, ext)
if os.path.exists(f):
os.remove(f)
pass
pass
# goback to the web2py main directory
os.chdir(cwd)
}}
\ 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