Ir para conteúdo
Fórum Script Brasil
  • 0

negrito no FPDF


charles junqueira

Pergunta

3 respostass a esta questão

Posts Recomendados

  • 0

Cara... pra adicionar algo em negrito você deverá fazer algo assim:

q = 5
t = 10 
pdf.SetFont "Arial","B",t
pdf.SetY(35)
pdf.SetX(10)

pdf.MultiCell 0,q,"Seu Texto Negrito",0,0,0

pdf.SetFont "Arial","",t
pdf.SetY(50)
pdf.SetX(10)
pdf.MultiCell 0,q,"Seu Texto SEM Negrito",0,0,0

sendo q = quebra de linha e t = tamanho da fonte!

[]'s Rafael Spilki

Link para o comentário
Compartilhar em outros sites

  • 0

utilize a função abaixo:

<%
function TrataFormatacao (Palavra, Fonte, Tamanho)

    TrataFormatacao=false
    if instr(Palavra,"<b>")<>0 then
        Palavra=replace(Palavra,"<b>","")
        pdf.SetFont Fonte,"B",Tamanho
    end if
    if instr(Palavra,"</b>")<>0 then
        Palavra=replace(Palavra,"</b>","")
        TrataFormatacao=true
    end if        
    if instr(Palavra,"<i>")<>0 then
        Palavra=replace(Palavra,"<i>","")
        pdf.SetFont Fonte,"I",Tamanho
    end if
    if instr(Palavra,"</i>")<>0 then
        Palavra=replace(Palavra,"</i>","")
        TrataFormatacao=true            
    end if    
    
end function

Sub ParagrafoPDF (Texto, Largura, EspacoEntreLinhas, NomeFonte, TamanhoFonte)

    Palavras=split(Texto," ")
    tl=0
    pl=0
    for n=0 to ubound(Palavras)

        DesligaFormatacao=TrataFormatacao(Palavras(n),NomeFonte,TamanhoFonte)

        tl = tl + PDF.GetStringWidth(Palavras(n))
        if tl>Largura then
            fl=fl & (Largura-(tl-PDF.GetStringWidth(Palavras(n))))/pl & ";"
            tl=PDF.GetStringWidth(Palavras(n))
            pl=0        
        end if    
        pl = pl + 1
        tl = tl + PDF.GetStringWidth(" ")
        if DesligaFormatacao then
            pdf.SetFont NomeFonte,"",TamanhoFonte
        end if    
    next    

    fator=split(fl,";")

    Palavras=split(Texto," ")
    tl=0
    l=0
    fatoracum=0
    f=0
    for n=0 to ubound(Palavras)

        DesligaFormatacao=TrataFormatacao(Palavras(n),NomeFonte,TamanhoFonte)

        tl = tl + PDF.GetStringWidth(Palavras(n))
        if tl>Largura then
            CALL PDF.Ln (EspacoEntreLinhas)
            tl=PDF.GetStringWidth(Palavras(n))
            l = l + 1
            fatoracum=0
        end if    
        tl = tl + PDF.GetStringWidth(" ")
        if l>=ubound(fator) then
            f = 0
        else    
            f = int((fatoracum + cdbl(fator(l))) - int(fatoracum))
        end if    
        CALL PDF.Cell(PDF.GetStringWidth(Palavras(n) & " ")+f,EspacoEntreLinhas,Palavras(n) & " ",0,0,"L")
        if l<ubound(fator) then
            fatoracum=fatoracum + cdbl(fator(l))
            fatoracum2=fatoracum2 + f
        end if    
        if DesligaFormatacao then
            pdf.SetFont NomeFonte,"",TamanhoFonte
        end if    
    next    

end sub

' Exemplo de uso:

Texto = "Lorem <b>ipsum</b> dolor sit amet, <i>consectetur</i> adipiscing elit. Nulla felis nisi, malesuada in condimentum quis, tempus sit amet nisi. Aliquam at tellus elit, sed adipiscing nibh. Aliquam at adipiscing mi. Vivamus ultrices pretium libero, quis tempor lorem mollis porta. Aenean id eros tellus. Phasellus id vestibulum erat" 

Largura=400
EspacoEntreLinhas=20
NomeFonte="Helvetica"
TamanhoFonte=10

ParagrafoPDF (Texto, Largura, EspacoEntreLinhas, NomeFonte, TamanhoFonte)


%>

Link para o comentário
Compartilhar em outros sites

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152,1k
    • Posts
      651,9k
×
×
  • Criar Novo...