我想在getstringwidth
使用while
时仅在下一行设置宽度时调用while
。
我的表格标题:
while ($row2x = $stmt2x->fetch(PDO::FETCH_ASSOC)){
$string = $row2x['nama_kriteria'];
$cellwidth = $pdf->GetStringWidth($string);
$pdf->Cell($cellwidth + 2,7,$row2x['nama_kriteria'],1,0,'L');
}
如何在下一个表格行中使用表格标题宽度?
我的表格行:
while ($rowrx = $stmtrx->fetch(PDO::FETCH_ASSOC)){
$pdf->Cell(/*$cellwidth + 2*/,7,$rowrx['nilai_rangking'],1,0,'L');
}
任何想法如何让它好看?
答案 0 :(得分:1)
尝试将宽度存储在数组中。
AuthenticationContext authenticationContext = new AuthenticationContext(UserModeConstants.AuthString, false);
AuthenticationResult userAuthnResult = await authenticationContext.AcquireTokenAsync(GlobalConstants.ResourceUrl,
UserModeConstants.ClientId, redirectUri, new PlatformParameters(PromptBehavior.RefreshSession));
TokenForUser = userAuthnResult.AccessToken;
Console.WriteLine("\n Welcome " + userAuthnResult.UserInfo.GivenName + " " +
userAuthnResult.UserInfo.FamilyName);
你需要填充从$width = array();
while ($row2x = $stmt2x->fetch(PDO::FETCH_ASSOC)){
$string = $row2x['nama_kriteria'];
$cellwidth = $pdf->GetStringWidth($string);
$pdf->Cell($cellwidth + 2,7,$row2x['nama_kriteria'],1,0,'L');
$width[] = $cellwidth + 2;
}
$i = 0;
while ($rowrx = $stmtrx->fetch(PDO::FETCH_ASSOC))
{
$pdf->Cell($width[$i],7,$rowrx['nilai_rangking'],1,0,'L');
$i++;
}
获得的宽度数组,然后你只需使用宽度变量宽度值