我想使用itext创建一个pdf,在我的jsp文件中,我创建一个按钮,每当有人点击该按钮pdf必须下载时,大多数所有东西都在这里工作正常但我无法添加我的表内容,它在桌子的地方显示为空。我的段落已添加但在段落后我想添加一个不添加的小表。有人请帮我解决这些问题,这是我的代码:
/itext.jsp
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
btnHello.Clicked += BtnHello_Clicked;
}
private void BtnHello_Clicked(object sender, EventArgs e)
{
lblDetail.Text = entryHello.Text;
}
}
/itextcontroller.java
function downloadfForm()
{
document.location.href = './downloadPDF';
}
<div class="col-md-3 col-sm-3">
<div class="form-group">
<label class="no-bold hidden hidden-md hidden-lg"> </label>
<a href="javascript:void(0)" class="btn btn-warning mutual-funds-submit-anchor" onclick="downloadfForm()">downloadfForm</a>
</div>
</div>
答案 0 :(得分:0)
尝试按照代码使用iText库创建一个pdf表.hope这将对您有所帮助。
PdfPTable table1 = new PdfPTable(4);
float[] columnWidths1 = new float[]{30f, 10f, 30f, 10f};
table1.setWidths(columnWidths1);
table1.setWidthPercentage(100);
table1.setHorizontalAlignment(table.ALIGN_JUSTIFIED);
PdfPCell c1 = new PdfPCell(new Phrase("Details", blackNormalFont));
c1.setHorizontalAlignment(Element.ALIGN_CENTER);
c1.setBackgroundColor(BaseColor.GRAY);
table1.addCell(c1);
c1 = new PdfPCell(new Phrase("Amount (Rs)", blackNormalFont));
c1.setHorizontalAlignment(Element.ALIGN_CENTER);
c1.setBackgroundColor(BaseColor.GRAY);
c1.setHorizontalAlignment(Element.ALIGN_RIGHT);
table1.addCell(c1);
c1 = new PdfPCell(new Phrase("Deductions by HDBFS", blackNormalFont));
c1.setHorizontalAlignment(Element.ALIGN_CENTER);
c1.setBackgroundColor(BaseColor.GRAY);
table1.addCell(c1);
c1 = new PdfPCell(new Phrase("Amount (Rs)", blackNormalFont));
c1.setHorizontalAlignment(Element.ALIGN_CENTER);
c1.setBackgroundColor(BaseColor.GRAY);
table1.addCell(c1);
table1.setHeaderRows(1);
table1.addCell(new Phrase("A. Product Cost", blackNormalFont));
c1 = new PdfPCell(new Phrase(
CustomFormat.NUMBER_0.format(23233223), blackNormalFont));
c1.setHorizontalAlignment(Element.ALIGN_RIGHT);
table1.addCell(c1);
table1.addCell(new Phrase("1. Processing Fees", blackNormalFont));
c1 = new PdfPCell(new Phrase(
CustomFormat.NUMBER_0.format(3232332), blackNormalFont));
c1.setHorizontalAlignment(Element.ALIGN_RIGHT);
table1.addCell(c1);
document.add(table1);
document.close();