forked from AOT-Technologies/forms-flow-ai-doc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
exportpdf.html
135 lines (108 loc) · 4.54 KB
/
exportpdf.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<article class="docs-article">
<section class="docs-section" id="pdf">
<div>
<h1>Export form as PDF</h1> <br>
<hr>
<p>
This feature enables users to export forms with submitted data as a pdf from the UI. Users will have an
“Export PDF ” button in form view pages to click and get the form downloaded as a pdf in the browser
itself.
</p>
<p>
<img src="./assets/images/pdf2.png" width="1000" ><br>
<br><br><br>
<img src="./assets/images/pdf3.png" width="1000">
</p>
<p>
</p>
<h3>API Details</h3>
<br>
<p>
<strong>API URL</strong> :
<form-flow-webapi-server>/form/<form-id>/submission/<submission-id>/export/pdf
</p>
<p>
Optional params:
</p>
<p>
<strong>timezone </strong>: A parameter to render form based on client timezone or any custom timezone.
</p>
<p>
Eg:
<form-flow-webapi-server>/form/<form-id>/submission/<submission-id>/export/pdf?timezone=Asia/Calcutta
</p>
<p>
<strong>API Method</strong>: GET
</p>
<p>
<strong>API Response</strong>: Will be a blob response that can be used by the client to save it as a
pdf
</p>
<p>
This feature requires the following prerequisites for running in local without docker.
</p>
<ol>
<li>A Chrome installation and its driver are required to render this form and print it as a pdf in
headless mode on the server side.
</li>
</ol>
<p>
Chrome driver path can be provided via env variable like below
</p>
<p>
In windows
</p>
<pre class="prettyprint"><code> CHROME_DRIVER_PATH=C:\driver\chromedriver.exe</code>
</pre>
<p>
In Linux
</p>
<pre class="prettyprint"><code> CHROME_DRIVER_PATH=/usr/local/bin/chromedriver</code>
</pre>
<p>
If not given the default value will be <code>/usr/local/bin/chromedriver</code>
</p>
<p>
<strong>Installation of Chrome and chrome driver</strong>
</p>
<p>
Forms flow docker images already contain code to install the latest Chrome and its chrome driver as
shown below
</p>
<p>
<ul>
<li> Dockerfile</li>
</p>
<pre><code class="hljs">
# Install Chrome WebDriver
RUN CHROMEDRIVER_VERSION=`curl -sS chromedriver.storage.googleapis.com/LATEST_RELEASE` && \
mkdir -p /opt/chromedriver-$CHROMEDRIVER_VERSION && \
curl -sS -o /tmp/chromedriver_linux64.zip http://chromedriver.storage.googleapis.com/$CHROMEDRIVER_VERSION/chromedriver_linux64.zip && \
unzip -qq /tmp/chromedriver_linux64.zip -d /opt/chromedriver-$CHROMEDRIVER_VERSION && \
rm /tmp/chromedriver_linux64.zip && \
chmod +x /opt/chromedriver-$CHROMEDRIVER_VERSION/chromedriver && \
ln -fs /opt/chromedriver-$CHROMEDRIVER_VERSION/chromedriver /usr/local/bin/chromedriver
# Install Google Chrome
RUN curl -sS -o - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && \
echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list && \
apt-get -yqq update && \
apt-get -yqq install google-chrome-stable && \
rm -rf /var/lib/apt/lists/*
# set display port to avoid crash
ENV DISPLAY=:99
</code></pre>
<li>The export feature can be enabled for Formsflow web by enabling a few env.
</li>
<pre>
<code>
# To enable export feature in UI
REACT_APP_EXPORT_PDF_ENABLED=true
# Url of python document service url
REACT_APP_DOCUMENT_SERVICE_URL=<<yourIP:port>>
</code>
</pre>
</ul>
</div>
</section>
</article>
<script>hljs.initHighlighting();</script>