我目前正在使用FPDF生成PDF报价。我想获得以下输出:
€520
通过这样做:
$pdf->Cell(20, 10, chr(128).' 520', 1, 0);
但是fpdf只显示一个空白区域。我使用Calibri作为字体,我加载它:
$pdf->AddFont('Calibri', '', 'calibri.php');
但无济于事。有趣的是,123到127和129等工作。欧元符号是唯一符号未显示。任何人都知道怎么做这个?
更新:,当我尝试
时$pdf->Cell(20, 10, utf8_decode('€ 520'), 1, 0);
我收到了一个问号。它不应该是无效的字体,因为我在calibri.php中发现了chr(128)。
答案 0 :(得分:1)
我通过删除“128 /.notdef”修改了calibri.php字体。不知怎的,它在那之后起作用......
答案 1 :(得分:0)
尝试使用iconv
$euro = iconv('utf-8', 'cp1252', '€');
$pdf->Cell(20, 10, $euro.' 520'), 1, 0);
cp1252(西欧) php中的header()不能在文件中打印pdf您的请求,但只能在页面中打印。
答案 2 :(得分:0)
这个也可以工作,可以用于包含多个€的字符串:
Function Calculating_billing_time(strStartDate As String, intDuration As Integer, Optional blnOVTDisabled As Boolean = False) As (intTSNormal As Integer, intTSOVT1 As Integer, intTSOVT1N As Integer, intTSOVT2 As Integer, intTSOVT2N As Integer, intTSOVT3 As Integer, intTSOVT3N As Integer)
Dim intTSNormal As Integer = 0
Dim intTSOVT1 As Integer = 0
Dim intTSOVT1N As Integer = 0
Dim intTSOVT2 As Integer = 0
Dim intTSOVT2N As Integer = 0
Dim intTSOVT3 As Integer = 0
Dim intTSOVT3N As Integer = 0
Dim strDateBorderAm As String
Dim dtDateBorderAM As Date
'Dim strDateBorder_6AM As String
'Dim dtDateBorder_6AM As Date
'Dim strDateDayAfterBorder_6AM As String
'Dim dtDateDayAfterBorder_6AM As Date
Dim strDateBorderPM As String
Dim dtDateBorderPM As Date
Dim strDateBorderNT As String
Dim dtDateBorderNT As Date
Dim strDateBorderMD As String
Dim dtDateBorderMD As Date
Dim strDateDayAfterBorderAM As String
Dim dtDateDayAfterBorderAM As Date
Dim dateformat2 As String
Dim dateFormat As String
' transformation of the string to actual date system
Dim dtStartDate As Date
Dim dtEndDate As Date
dateFormat = "M/d/yyyy HH:mm:ss"
dateformat2 = "d/M/yyy HH:mm:ss"
dtStartDate = Date.ParseExact(strStartDate, dateFormat, Globalization.CultureInfo.InvariantCulture)
dtStartDate = dtStartDate.AddSeconds(-(dtStartDate.TimeOfDay.Seconds))
dtEndDate = dtStartDate.AddSeconds(intDuration)
Console.WriteLine("Date start: " & dtStartDate)
Console.WriteLine("Date end : " & dtEndDate)
If blnOVTDisabled = True Then
intTSNormal = intDuration
Else
'strDateBorder_6AM = dtStartDate.Day & "/" & dtStartDate.Month & "/" & dtStartDate.Year & " 06:00:00"
'dtDateBorder_6AM = Date.ParseExact(strDateBorder_6AM, dateFormat, Globalization.CultureInfo.InvariantCulture)
strDateBorderAm = dtStartDate.Day & "/" & dtStartDate.Month & "/" & dtStartDate.Year & " 07:00:00"
dtDateBorderAM = Date.ParseExact(strDateBorderAm, dateformat2, Globalization.CultureInfo.InvariantCulture)
strDateBorderPM = dtStartDate.Day & "/" & dtStartDate.Month & "/" & dtStartDate.Year & " 18:00:00"
dtDateBorderPM = Date.ParseExact(strDateBorderPM, dateformat2, Globalization.CultureInfo.InvariantCulture)
strDateBorderNT = dtStartDate.Day & "/" & dtStartDate.Month & "/" & dtStartDate.Year & " 22:00:00"
dtDateBorderNT = Date.ParseExact(strDateBorderNT, dateformat2, Globalization.CultureInfo.InvariantCulture)
strDateBorderMD = dtStartDate.AddDays(1).Day & "/" & dtStartDate.Month & "/" & dtStartDate.Year & " 00:00:00"
dtDateBorderMD = Date.ParseExact(strDateBorderMD, dateformat2, Globalization.CultureInfo.InvariantCulture)
strDateDayAfterBorderAM = dtStartDate.AddDays(1).Day & "/" & dtStartDate.Month & "/" & dtStartDate.Year & "07:00:00"
dtDateDayAfterBorderAM = Date.ParseExact(strDateBorderAm, dateformat2, Globalization.CultureInfo.InvariantCulture)
'strDateDayAfterBorder_6AM = dtStartDate.AddDays(1).Day & "/" & dtStartDate.Month & "/" & dtStartDate.Year & " 06:00:00"
'dtDateDayAfterBorder_6AM = Date.ParseExact(strDateBorderAm, dateFormat, Globalization.CultureInfo.InvariantCulture)
Console.WriteLine("")
'Console.WriteLine("Date Border AM: " & dtDateBorder_6AM)
Console.WriteLine("Date Border AM: " & dtDateBorderAM)
Console.WriteLine("Date Border PM:" & dtDateBorderPM)
Console.WriteLine("Date Border Night:" & dtDateBorderNT)
Console.WriteLine("Date Border Midnight:" & dtDateBorderMD)
'Console.WriteLine("Date Day After Border 6 AM:" & dtDateDayAfterBorder_6AM)
Console.WriteLine("Date Day After Border AM:" & dtDateDayAfterBorderAM)
Console.WriteLine("")
' Start before 7h00 (AM)
If (dtStartDate <= dtDateBorderAM) Then
Console.WriteLine("Start before 7h00 (AM) for:" & dtStartDate.DayOfWeek)
If dtStartDate.DayOfWeek.ToString = "Sunday" Then
intTSOVT2N += CInt(DateDiff(DateInterval.Second, dtStartDate, dtDateBorderAM).ToString)
Else
intTSOVT1N += CInt(DateDiff(DateInterval.Second, dtStartDate, dtDateBorderAM).ToString)
End If
Console.WriteLine("TSNormal " & intTSNormal)
Console.WriteLine("TSOVT1 " & intTSOVT1)
Console.WriteLine("TSOVT1N " & intTSOVT1N)
Console.WriteLine("TSOVT2 " & intTSOVT2)
Console.WriteLine("TSOVT2N " & intTSOVT2N)
Console.WriteLine("TSOVT3 " & intTSOVT3)
Console.WriteLine("TSOVT3N " & intTSOVT3N)
Console.WriteLine("")
Console.WriteLine("start date " & dtStartDate)
Console.WriteLine("end date " & dtEndDate)
End If
'Start After 7h00 (AM)
If dtStartDate >= dtDateBorderAM Then
Console.WriteLine("Start After 7h00 (AM) for " & dtStartDate.DayOfWeek)
If dtStartDate.DayOfWeek.ToString = "Saturday" Then
intTSOVT1 += CInt(DateDiff(DateInterval.Second, dtStartDate, dtDateBorderPM).ToString)
ElseIf dtStartDate.DayOfWeek.ToString = "Sunday" Then
intTSOVT2 += CInt(DateDiff(DateInterval.Second, dtStartDate, dtDateBorderPM).ToString)
Else
intTSNormal += CInt(DateDiff(DateInterval.Second, dtStartDate, dtDateBorderPM).ToString)
Console.WriteLine("TSNormal " & intTSNormal)
Console.WriteLine("TSOVT1 " & intTSOVT1)
Console.WriteLine("TSOVT1N " & intTSOVT1N)
Console.WriteLine("TSOVT2 " & intTSOVT2)
Console.WriteLine("TSOVT2N " & intTSOVT2N)
Console.WriteLine("TSOVT3 " & intTSOVT3)
Console.WriteLine("TSOVT3N " & intTSOVT3N)
Console.WriteLine("")
Console.WriteLine("start date " & dtStartDate)
Console.WriteLine("end date " & dtEndDate)
End If
End If
' Stop before 18h
If dtEndDate <= dtDateBorderPM Then
Console.WriteLine("Stop before 18h for" & dtEndDate.DayOfWeek)
If dtEndDate.DayOfWeek.ToString = "Saturday" Then
intTSOVT1 += CInt(DateDiff(DateInterval.Second, dtEndDate, dtDateBorderPM).ToString)
ElseIf dtEndDate.DayOfWeek.ToString = "Sunday" Then
intTSOVT2 += CInt(DateDiff(DateInterval.Second, dtEndDate, dtDateBorderPM).ToString)
Else
intTSNormal += CInt(DateDiff(DateInterval.Second, dtEndDate, dtDateBorderPM))
Console.WriteLine("TSNormal " & intTSNormal)
Console.WriteLine("TSOVT1 " & intTSOVT1)
Console.WriteLine("TSOVT1N " & intTSOVT1N)
Console.WriteLine("TSOVT2 " & intTSOVT2)
Console.WriteLine("TSOVT2N " & intTSOVT2N)
Console.WriteLine("TSOVT3 " & intTSOVT3)
Console.WriteLine("TSOVT3N " & intTSOVT3N)
Console.WriteLine("")
Console.WriteLine("start date " & dtStartDate)
Console.WriteLine("end date " & dtEndDate)
End If
End If
' Stop After 18h and Before 22h
If (dtEndDate > dtDateBorderPM) And (dtEndDate <= dtDateBorderNT) Then
Console.WriteLine("Stop After 18h and Before 22h for " & dtEndDate.DayOfWeek)
If (dtEndDate.DayOfWeek.ToString = "Saturday") Then
intTSOVT1 += CInt(DateDiff(DateInterval.Second, dtDateBorderPM, dtEndDate).ToString)
ElseIf dtEndDate.DayOfWeek.ToString = "Sunday" Then
intTSOVT2 += CInt(DateDiff(DateInterval.Second, dtDateBorderPM, dtEndDate).ToString)
Else
intTSOVT1 += CInt(DateDiff(DateInterval.Second, dtDateBorderPM, dtEndDate).ToString)
Console.WriteLine("TSNormal " & intTSNormal)
Console.WriteLine("TSOVT1 " & intTSOVT1)
Console.WriteLine("TSOVT1N " & intTSOVT1N)
Console.WriteLine("TSOVT2 " & intTSOVT2)
Console.WriteLine("TSOVT2N " & intTSOVT2N)
Console.WriteLine("TSOVT3 " & intTSOVT3)
Console.WriteLine("TSOVT3N " & intTSOVT3N)
Console.WriteLine("")
Console.WriteLine("start date " & dtStartDate)
Console.WriteLine("end date " & dtEndDate)
End If
End If
'Stop After 22h and Before 07h00 (AM) Day After
If dtEndDate >= dtDateBorderNT And dtEndDate <= dtDateDayAfterBorderAM Then
Console.WriteLine("Stop After 22h and Before 07h00 (AM) day After for" & (dtEndDate.DayOfWeek))
If dtEndDate.DayOfWeek.ToString = "Saturday" Then
intTSOVT1 += CInt(DateDiff(DateInterval.Second, dtDateBorderPM, dtDateBorderNT).ToString)
intTSOVT1N += CInt(DateDiff(DateInterval.Second, dtDateBorderNT, dtEndDate).ToString)
ElseIf dtEndDate.DayOfWeek.ToString = "Sunday" Then
intTSOVT2 += CInt(DateDiff(DateInterval.Second, dtDateBorderPM, dtDateBorderNT).ToString)
intTSOVT2N += CInt(DateDiff(DateInterval.Second, dtDateBorderNT, dtEndDate).ToString)
Else
intTSOVT1 += CInt(DateDiff(DateInterval.Second, dtDateBorderNT, dtDateBorderPM).ToString)
intTSOVT1N += CInt(DateDiff(DateInterval.Second, dtEndDate, dtDateBorderNT).ToString)
End If
Console.WriteLine("TSNormal " & intTSNormal)
Console.WriteLine("TSOVT1 " & intTSOVT1)
Console.WriteLine("TSOVT1N " & intTSOVT1N)
Console.WriteLine("TSOVT2 " & intTSOVT2)
Console.WriteLine("TSOVT2N " & intTSOVT2N)
Console.WriteLine("TSOVT3 " & intTSOVT3)
Console.WriteLine("TSOVT3N " & intTSOVT3N)
Console.WriteLine("")
Console.WriteLine("start date " & dtStartDate)
Console.WriteLine("end date " & dtEndDate)
End If
'Stop After 07h00 (AM) Day After
If dtEndDate > dtDateBorderNT And dtEndDate > dtDateDayAfterBorderAM Then
Console.WriteLine("Stop After 07h00 (AM) Day After for " & dtEndDate.DayOfWeek)
If dtEndDate.DayOfWeek.ToString = "Saturday" Then
intTSOVT1N += CInt(DateDiff(DateInterval.Second, dtDateBorderNT, dtDateDayAfterBorderAM).ToString)
intTSOVT1 += CInt(DateDiff(DateInterval.Second, dtDateDayAfterBorderAM, dtEndDate).ToString)
ElseIf dtEndDate.DayOfWeek.ToString = "Sunday" Then
intTSOVT1N += CInt(DateDiff(DateInterval.Second, dtDateBorderNT, dtDateBorderMD).ToString)
intTSOVT2N += CInt(DateDiff(DateInterval.Second, dtDateBorderMD, dtDateDayAfterBorderAM).ToString)
intTSOVT2 += CInt(DateDiff(DateInterval.Second, dtDateDayAfterBorderAM, dtEndDate).ToString)
ElseIf dtEndDate.DayOfWeek.ToString = "Monday" Then
intTSOVT2 += CInt(DateDiff(DateInterval.Second, dtDateBorderPM, dtDateBorderNT).ToString)
intTSOVT2N += CInt(DateDiff(DateInterval.Second, dtDateBorderNT, dtDateBorderMD).ToString)
intTSOVT2N += CInt(DateDiff(DateInterval.Second, dtDateBorderMD, dtDateDayAfterBorderAM).ToString)
intTSNormal += CInt(DateDiff(DateInterval.Second, dtDateDayAfterBorderAM, dtEndDate).ToString)
Else
intTSOVT1 += CInt(DateDiff(DateInterval.Second, dtDateBorderPM, dtDateBorderNT).ToString)
intTSOVT1N += CInt(DateDiff(DateInterval.Second, dtDateBorderNT, dtDateDayAfterBorderAM).ToString)
intTSNormal += CInt(DateDiff(DateInterval.Second, dtDateDayAfterBorderAM, dtEndDate).ToString)
End If
Console.WriteLine("")
Console.WriteLine("TSNormal:" & intTSNormal)
Console.WriteLine("intTSOVT1:" & intTSOVT1)
Console.WriteLine("intTSOVT1N:" & intTSOVT1N)
Console.WriteLine("TSOVT2:" & intTSOVT2)
Console.WriteLine("TSOVT2N:" & intTSOVT2N)
Console.WriteLine("intTSOVT3N:" & intTSOVT3N)
Console.WriteLine("")
End If
Return (intTSNormal, intTSOVT1, intTSOVT1N, intTSOVT2, intTSOVT2N, intTSOVT3, intTSOVT3N)
End If 'le generale
End Function
End Module
HTH