在React App中使用pdfform.js面临困难

时间:2019-05-30 08:36:58

标签: javascript reactjs pdf

我想在react应用程序中使用pdfform.js库(包)。我尝试使用npm pdfform,但是没有运气。

非常感谢您的帮助。

https://github.com/phihag/pdfform.js

1 个答案:

答案 0 :(得分:0)

这是一个可行的演示,也许会对您有所帮助。

<!DOCTYPE html>
<html>

<head>
	<meta charset="utf-8" />
	<title>pddform.js demo</title>
	<link rel="stylesheet" href="https://phihag.github.io/pdfform.js/docs/demo.css" />
</head>

<body>
	<div class="error"></div>
	<form class="url_form">
		<div>Upload a PDF form file: <label><input type="file" name="file" /></label></div>

		<label>or download one: <input type="text" size="40" value="Spielberichtsbogen_2BL.pdf" name="url" /><button role="submit">Download</button></label>
	</form>

	<form class="cur_file"></form>

	<form class="lib_form">
		PDF library:
		<label><input type="radio" name="pdflib" value="minipdf" checked="checked" />minipdf</label>
		<label><input type="radio" name="pdflib" value="pdf.js" />PDF.js</label>
	</form>

	<form class="fill_form"><button class="fill" disabled="disabled">Fill and download PDF</button></form>

	<form class="list_form">
	</form>

	<div class="loading">Loading (this may take a while since PDF.js is gigantic)</div>

	<!-- In a real-life scenario, you want to chose EITHER minipdf (smaller) -->
	<script src="https://phihag.github.io/pdfform.js/minipdf.js"></script>

	<!-- .. OR pdf.js (huge, but better compatibility).
pdf.worker.js is slightly modified to export the actual classes we care about -->
	<script src="https://phihag.github.io/pdfform.js/customlibs/pdf.worker.js"></script>
	<script src="https://phihag.github.io/pdfform.js/minipdf_js.js"></script>


	<!-- pako and pdfform.js are required either way -->
	<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/pako/1.0.3/pako.min.js" integrity="sha256-X7u/eQo6oIgWqc5jOmTjQn3loM8Lse0ock76Gkkn/Ro="
	 crossorigin="anonymous"></script>
	<script src="https://phihag.github.io/pdfform.js/pdfform.js"></script>

	<!-- FileSaver.js is just needed for the demo, although you'll probably use it in some form as well -->
	<script src="https://cdnjs.cloudflare.com/ajax/libs/FileSaver.js/1.0.0/FileSaver.min.js"></script>

	<script src="https://phihag.github.io/pdfform.js/docs/demo.js"></script>

</body>

</html>