我正在从我的网络上的SQL Server数据库生成PDF,一切正常,但PDF文件最后总共有一个空白页。我不确定问题是存在于我的存储过程中还是存在于我的网络中,但您能否为我查看这个问题?
@gfromDate VARCHAR(10),
@gtoDate VARCHAR(10)
AS
BEGIN
SET NOCOUNT ON;
DECLARE @fromDate DATE
DECLARE @toDate DATE
DECLARE @totaldays INT
SET @fromDate = (SELECT convert(VARCHAR(10), @gfromDate, 101))
SET @toDate = (SELECT convert(VARCHAR(10), @gtoDate, 101))
SET @totaldays = (SELECT datediff(day, @fromdate, @toDate) + 2)
DECLARE @sql VARCHAR(max) = ''
DECLARE @tablename VARCHAR(20)
DECLARE @counter INT = 1
WHILE @counter < @totaldays
BEGIN
SET @tablename = ((SELECT REPLACE(UPPER(RIGHT(CONVERT(VARCHAR(11), @fromDate, 106), 8)), ' ', '') AS [Mon-YYYY]))
SET @tablename = replace(@tablename, ' ', '')
SET @sql = @sql + 'SELECT
accname,
add1,
add2,
zip,
stat,
statdate,
FROM gen_048_' + @tablename + ' WHERE refdate = ''' + REPLACE(convert(VARCHAR(10), @fromDate), '-','') + ''''
IF (@counter != @totaldays - 1)
BEGIN
SET @sql = @sql + ' union '
END
SET @fromDate = dateadd(day, 1, @fromDate)
SET @counter = @counter + 1
END
END
PRINT @sql
EXEC (@sql)
我相信这是我的PDF生成代码我是对的吗?我使用codeigniter作为我的框架,这是我在控制器中的代码。
function dormancy()
{
$data['gfDate']= $this->input->post("fdate");
$data['gtDate']= $this->input->post("tdate");
$data['print']= $this->input->post("print");
$this->load->library('mpdf');
$this->load->model('mpdf_model');
$query = $this->mpdf_model->mpdf_gen020($data);
if($query!=null)
{
foreach($query as $data){
$hello .='
<img src="'.base_url().'images/ubplogo.png"> </img>
';
$hello.=' TESTING
<p style="text-align: center;"> This is a system-generated form. No signatures are required</p>
<br/> <pagebreak />
';
}
$mpdf=new mPDF('ISO-8859-1','letter', 10, 'Arial', 15, 15, 16, 16, 9, 9, 'P');
$stylesheet = file_get_contents(base_url().'css/pdf.css');
ini_set('memory_limit', '-1');
$mpdf->cacheTables = true;
$mpdf->simpleTables=true;
$mpdf->packTableData=true;
$mpdf->WriteHTML($stylesheet,1);
$mpdf->SetHTMLHeader('<img src="'.base_url().'css/edrsletter.jpg"></img>');
$mpdf->WriteHTML($hello);
$mpdf->SetFooter(' Sample PDF template - {PAGENO}');
$mpdf->Output();
}
}