我正在从定义占位符的html模板文件创建一个pdf。我可以用一些文本替换占位符,例如
content.Replace(["Product_ID"],TextBox1.text);
有什么办法我也可以用复选框替换占位符(根据条件选中或取消选中)?
我正在从定义占位符的html模板文件创建一个pdf。我可以用一些文本替换占位符,例如
content.Replace(["Product_ID"],TextBox1.text);
有什么办法我也可以用复选框替换占位符(根据条件选中或取消选中)?
创建两个图像,一个用于复选框“选中”状态,一个“未选中”,并使用 IF 语句获取正确的图像:即:
string pdfpath = Server.MapPath("PDFs");
string imagepath = Server.MapPath("Images");
Document doc = new Document();
try
{
PdfWriter.GetInstance(doc, new FileStream(pdfpath + "/Images.pdf", FileMode.Create));
doc.Open();
doc.Add(new Paragraph("GIF"));
Image gif;
if (chkBoxExample.Checked)
{
gif = Image.GetInstance(imagepath + "/checked.gif");
}
else
{
gif = Image.GetInstance(imagepath + "/unchecked.gif");
}
doc.Add(gif);
}
finally
{
doc.Close();
}