我正在使用ASP MVC,我使用iTextSharp在我的应用程序中生成PDF.但现在我有一个问题:我打印列表,当存在多个页面时,我想显示页码(例如:)Page 1 to 4
.我找到了一些例子,但我认为它比我需要做的更复杂(如exameple).
编辑: 我发现这个例子2.我可以计算页数,但我不能打印页数.
我做了什么:
public ActionResult downloadListaISCC(DateTime? DataFimFiltro)
{
//Code to generate list to PDF
//My document
Document doc1 = new Document();
doc1.SetPageSize(iTextSharp.text.PageSize.A4);
doc1.SetMargins(0f, 0f, 0f, 0f);
doc1.NewPage();
MemoryStream pdfStream = new MemoryStream();
PdfWriter pdfWriter = PdfWriter.GetInstance(doc1, pdfStream);
//Code to create table
doc1.Add(table); //table list in document
//Follow the example 2 (link)
pdfWriter.CloseStream = true;
doc1.Close();
//E fui seguindo o exemplo do segundo link
string file = "D:/gerarPDFOleotorres/"+ nomeDoc +""; …
Run Code Online (Sandbox Code Playgroud) 我尝试更改默认的消息@Html.ValidationMessageFor
.我可以在哪里查找邮件的文件:The _nameFied field is required.
视图:
@Html.ValidationMessageFor(model => model.NumDoc,"", new { @class = "error-input"})
我尝试删除控制器中的文件:
控制器:
[AcceptVerbs(HttpVerbs.Get)]
public JsonResult EliminarDocFotoContrato(int? DocFotoID)
{
DocumentosFotosContrato docFoto = db.DocumentosFotosContrato.Find(DocFotoID);
var nomeDocFoto = docFoto.CaminhoDocFoto;
var dir = Server.MapPath("/uploads");
var path = Path.Combine(dir, nomeDocFoto);
var result = "Documento / Foto apagada.";
return Json(result, JsonRequestBehavior.AllowGet);
}
Run Code Online (Sandbox Code Playgroud)
var nameDocFoto具有名称文件var dir具有目录并且路径具有nameDocFoto + dir(它是正确的)
现在我需要代码来删除文件.我可以帮帮我吗?我只是尝试这样的事情:
File.Delete(path);
Run Code Online (Sandbox Code Playgroud)
但得到这个错误:
Error 2 'System.Web.Mvc.Controller.File(string, string, string)' is a 'method', which is not valid in the given context D:\VS2010\Projects\MvcTesteLayout\MvcTesteLayout\Controllers\_DadosComerciais\ContratoController.cs 1511 17 MvcTesteLayout
Run Code Online (Sandbox Code Playgroud) 我尝试将输入键按下转换为选项卡而不提交表单,但只需删除提交表单按Enter键即可...
风景:
<tr>
<td><input type="text" id="tipoContacto1" name="tipoContacto1" class="form-control input-sm" onkeypress="removerEnter(event)"/></td>
<td><input type="text" id="nomeContacto1" name="nomeContacto1" class="form-control input-sm" onkeypress="removerEnter(event)"/></td>
Run Code Online (Sandbox Code Playgroud)
剧本:
function removerEnter(e) {
if (e.which == 13) {
//$(e).target.nextSibling;
//$(this).next('input').focus();
e.preventDefault();
}
}
Run Code Online (Sandbox Code Playgroud) html javascript model-view-controller asp.net-mvc form-submit
我尝试将razor值发送给jquery funcion.
视图:
@Html.TextBoxFor(model => model.NumTransportado, new { @class = "form-control input-sm", id = "NumTransResp" + Model.ServicosID + "", name = "NumTransResp" + Model.ServicosID + "", onchange = "PreencheDadosVendedor(this, 3, " + @Model.ServicosID + ")" })
Run Code Online (Sandbox Code Playgroud)
我可以使用除以外的所有参数 " + @Model.ServicosID + "
Js文件:
function PreencheDadosVendedor(idVend, tipoFuncionario, idServicoEdicao) {
$.getJSON("/Contrato/getDadosVendedor", { id: $(idVend).val(), tipoFuncionario: tipoFuncionario },
function (result) {
switch (tipoFuncionario) {
case 1:
$("#NomeVendedor_Contrato").val(result.NomeVendedor);
case 2:
$("#NomeTransResponsavel").val(result.NomeVendedor);
case 3:
$("#NomeTransResponsavel_" + idServicoEdicao + "").val(result.NomeVendedor);
}
});
}
Run Code Online (Sandbox Code Playgroud)
我尝试做的idSericoEdicao
是我的 …
我正在使用iTextSharp
我的应用程序创建PDF.但是我必须重新创建一个表,我必须为一个非常小的列设置大小.下面是显示我想要设置列的大小的图片:
当表创建的其余部分都很好时,我无法设置此宽度.
码:
PdfPTable table = new PdfPTable(2);
table.WidthPercentage = 82.0f;
PdfPCell cell = new PdfPCell(new Phrase("Com a assinatura autógrafa, o signatário desta Auto-declaração garante ter cumprido estas condições:", fontetexto));
cell.PaddingBottom = 10f;
cell.PaddingTop = 10f;
cell.Colspan = 2;
cell.HorizontalAlignment = 1; //0=Left, 1=Centre, 2=Right
table.AddCell(cell);
table.AddCell("1. ");
table.AddCell("Os óleos e gorduras vegetais velhos fornecidos são biomassa conforme o Decreto de biomassa.");
Run Code Online (Sandbox Code Playgroud)