iTextSharp 5:如何在页脚右侧对齐页码“ x / x”

时间:2019-03-09 12:34:34

标签: c# pdf pagination itext footer

我是iTextSharp 5的新手,我想知道如何在页脚右侧使用此格式 CurrentPage / TotalPages 对齐页码。当创建带有页码和有关的某些信息的页脚时,我设法在右侧写 CurrentPage / ,但在左侧写 TotalPages 。这是我的代码。

19:45:53 **** Incremental Build of configuration Debug for project ReadWriteHDF5 **** 
make all Building target: ReadWriteHDF5 Invoking: GCC C++ Linker g++ -L/usr/local/lib/hdf5-1.10.4/lib -o "ReadWriteHDF5" ./src/ReadWriteHDF5.o -l/usr/local/lib/hdf5-1.10.4/lib/libhdf5_hl_cpp.so -l/usr/local/lib/hdf5-1.10.4/lib/libhdf5_cpp.so -l/usr/local/lib/hdf5-1.10.4/lib/libhdf5.so /usr/bin/ld: cannot find -l/usr/local/lib/hdf5-1.10.4/lib/libhdf5_hl_cpp.so makefile:45: recipe for target 'ReadWriteHDF5' failed /usr/bin/ld: cannot find -l/usr/local/lib/hdf5-1.10.4/lib/libhdf5_cpp.so /usr/bin/ld: cannot find -l/usr/local/lib/hdf5-1.10.4/lib/libhdf5.so collect2: 
error: ld returned 1 exit status 
make: *** [ReadWriteHDF5] Error 1 "make all" terminated with exit code 2. Build might be incomplete. 19:45:54 Build Failed. 5 errors, 0 warnings. (took 271ms)

这就是它的样子

This the footer that I made

1 个答案:

答案 0 :(得分:0)

由于无法提前获取页码,因此可以通过生成pdf(包括两个步骤)来实现。

  1. 生成没有页码的PDF。
  2. 再次呈现pdf,现在在每页上添加一个数字。

生成pdf后,请调用此方法:

SELECT 
    Name
    Issue
    SLC
    Values.value
FROM
    Table-2
LEFT JOIN
    (
        SELECT 'Rank1' descrip, Rank1 value FROM Table-1
        UNION ALL
        SELECT 'Rank2' descrip, Rank1 value FROM Table-1
        UNION ALL
        SELECT 'Rank3' descrip, Rank1 value FROM Table-1
        UNION ALL
        SELECT 'Rank4' descrip, Rank1 value FROM Table-1
    ) as Values
ON Values.descrip = Issue

您需要将此方法定义为:

AddPageNo("Sushant_Without_pageNo.pdf","Sushant_With_pageNo.pdf");