【发布时间】:2017-08-10 16:58:02
【问题描述】:
我正在使用引导框架在 asp.net 中编写一个 Web 应用程序以获取样式。目的是显示 pdf,然后用户填写 pdf,单击下面的按钮后,应将其保存到解决方案内的文件夹中以供进一步处理。我能够嵌入 pdf 并使其完全可编辑,但是,我一直试图将其保存回解决方案。我已经在网上研究了答案,但我认为唯一可能有用的是 File.writeAllBytes() 方法。我只是不知道如何实现它。非常感谢任何有关如何完成此操作的帮助或建议。
这是 UI 代码:
<%@ Page Language="C#" AutoEventWireup="true" masterpagefile="~/Site.Master"
CodeBehind="RenderPDF.aspx.cs" Inherits="DocusignTest.RenderPDF" %>
<asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server">
<div class="row">
<div class="col-lg-4">
<div class="jumbotron">
<label>First Name:</label>
<input type="text" class="form-control"/>
<label>Last Name:</label>
<input type="text" class="form-control"/>
<label>Email:</label>
<input type="email" class="form-control"/>
</div>
</div>
<div class="col-lg-8">
<!-- this is the pdf the user needs to fill out -->
<embed id="pdf" src="e-docs/PAF.pdf" style="width: 100%; height:1000px"/>
<div class="pager">
<asp:Button ID="eSignButton" runat="server" CssClass="btn btn-primary" Text="Sign" OnClick="eSign_Click" Enabled="false"/>
<input type="checkbox" id="eSignCheckbox" onclick="enableButton();"/>I have filled out this document to the best of my abilities.
</div>
</div>
</div>
<script lang="javascript" type="text/javascript">
var button = WebForm_GetElementById("MainContent_eSignButton")
var checkbox = WebForm_GetElementById("eSignCheckbox")
function enableButton() {
if (checkbox.checked) {
button.disabled = false;
} else {
button.disabled = true;
}
}
</script>
下面是代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
namespace DocusignTest
{
public partial class RenderPDF : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void eSign_Click(object sender, EventArgs e)
{
savePDF();
}
protected void savePDF()
{
//DO something.
//Maybe using File.writeAllBytes() to save the embedded PDF to folder in solution.
}
}
【问题讨论】:
-
完成的PDF文件不需要上传吗?
-
@stuartd 上传到哪里?服务器?为什么?我需要将其保存到解决方案内的文件夹中以进一步处理它,然后我可以将其保存到服务器
-
“我需要将它保存到解决方案内的文件夹中” - 您想将 PDF 保存在您的代码中吗?这很令人困惑。不会是网络服务器上的文件夹吗?如我所见,您已在网页中嵌入了 PDF,并且您的用户正在浏览器中对其进行编辑。当他们点击签名按钮时,填写的PDF只存在于浏览器中,所以您不必上传它进行进一步处理吗?
-
@stuartd 实际上 pdf 已经存在于解决方案内的文件夹中。
-
好吧,对不起,我想我误解了。