Cuando genera el PDF es correcto, concuerda con el diseño, la vista prevía es diferente al diseño.
/* Código del botón del formulario que ejecuta el reporte */
private void btnListadoClientesActionPerformed(java.awt.event.ActionEvent evt) {
try {
try {
Class.forName("com.mysql.jdbc.Driver");
} catch (ClassNotFoundException ex) {
Logger.getLogger(frmReportes.class.getName()).log(Level.SEVERE, null, ex);
}
String db = "jdbc:mysql://localhost/facturacion";
cnn = DriverManager.getConnection(db, "root", "Leandro2009");
JasperReport reporteClientes;
try {
reporteClientes = JasperCompileManager.compileReport("reporteClientes.jrxml");
JasperPrint print;
print = JasperFillManager.fillReport(reporteClientes, null, cnn);
/* el parámetro false es necesario para que no cierre la
aplicación al cerrar el reporte */
JasperViewer.viewReport(print, false);
} catch (JRException ex) {
Logger.getLogger(frmReportes.class.getName()).log(Level.SEVERE, null, ex);
}
} catch (SQLException ex1) {
Logger.getLogger(frmReportes.class.getName()).log(Level.SEVERE, null, ex1);
}
}
<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="null" language="groovy" pageWidth="842" pageHeight="595" orientation="Landscape" columnWidth="802" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="7fdd85a6-0f0f-46cd-b6a0-d1345b703138">
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<style name="Title" forecolor="#FFFFFF" fontName="Times New Roman" fontSize="50" isBold="false" pdfFontName="Times-Bold"/>
<style name="SubTitle" forecolor="#CCCCCC" fontName="Times New Roman" fontSize="18" isBold="false" pdfFontName="Times-Roman"/>
<style name="Column header" forecolor="#666666" fontName="Times New Roman" fontSize="14" isBold="true" pdfFontName="Times-Roman"/>
<style name="Detail" mode="Transparent" fontName="Times New Roman" pdfFontName="Times-Roman"/>
<style name="Row" mode="Transparent" fontName="Times New Roman" pdfFontName="Times-Roman">
<conditionalStyle>
<conditionExpression><![CDATA[$V{REPORT_COUNT}%2 == 0]]></conditionExpression>
<style mode="Opaque" backcolor="#F0EFEF"/>
</conditionalStyle>
</style>
<queryString language="SQL">
<![CDATA[SELECT
clientes.`idCliente` AS 'ID Cliente',
case idTipo
when 1 then "Cédula de ciudadanía"
when 2 then "NIT"
when 3 then "Tarjeta de identidad"
when 4 then "Registro Cívil"
when 5 then "Cédula de extranjería"
when 6 then "Pasaporte"
end as 'Tipo Documento',
concat(nombres,' ', apellidos) AS 'Nombre del Cliente',
clientes.`direccion` AS 'Dirección',
clientes.`telefono` AS 'Teléfono',
case idCiudad
when 1 then "Arauca"
when 2 then "Armenia"
when 3 then "Barranquilla"
when 4 then "Bogotá"
when 5 then "Bucaramanga"
when 6 then "Cali"
when 7 then "Cartagena de Indias"
when 8 then "Cúcuta"
when 9 then "Florencia"
when 10 then "Ibagué"
when 11 then "Inírida"
when 12 then "Leticia"
when 13 then "Manizales"
when 14 then "Medellín"
when 15 then "Mitú"
when 16 then "Mocoa"
when 17 then "Montería"
when 18 then "Neiva"
when 19 then "Pasto"
when 20 then "Popayán"
when 21 then "Puerto Carreño"
when 22 then "Quibdó"
when 23 then "Riohacha"
when 24 then "San Andrés"
when 25 then "San José del Guaviare"
when 26 then "Santa Marta"
when 27 then "Sincelejo"
when 28 then "Tunja"
when 29 then "Valledupar"
when 30 then "Villavicencio"
when 31 then "Yopal"
end as 'Ciudad',
DATE_FORMAT(clientes.fechaNacimiento, '%d/%m/%Y') AS 'F.Nacimiento',
DATE_FORMAT(clientes.fechaIngreso, '%d/%m/%Y') AS 'F.Ingreso'
FROM
`clientes` clientes]]>
</queryString>
<field name="ID Cliente" class="java.lang.String"/>
<field name="Tipo Documento" class="java.lang.String"/>
<field name="Nombre del Cliente" class="java.lang.String"/>
<field name="Dirección" class="java.lang.String"/>
<field name="Teléfono" class="java.lang.String"/>
<field name="Ciudad" class="java.lang.String"/>
<field name="F.Nacimiento" class="java.lang.String"/>
<field name="F.Ingreso" class="java.lang.String"/>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="102" splitType="Stretch">
<image>
<reportElement x="725" y="0" width="77" height="102" uuid="ac330a15-0145-4415-b468-bea6947a002e"/>
<imageExpression><![CDATA["cherry.jpg"]]></imageExpression>
</image>
<frame>
<reportElement mode="Opaque" x="0" y="0" width="721" height="66" backcolor="#000000" uuid="52248f5e-b3ac-4df6-9c02-e799be9208e2"/>
<staticText>
<reportElement style="Title" x="0" y="0" width="396" height="66" uuid="c94d6af6-d8c5-452b-9543-5d88f0084df6"/>
<box topPadding="4" leftPadding="4" bottomPadding="4" rightPadding="4"/>
<textElement verticalAlignment="Bottom">
<font isBold="false"/>
</textElement>
<text><![CDATA[Listado de Clientes]]></text>
</staticText>
<staticText>
<reportElement style="SubTitle" x="370" y="37" width="316" height="29" uuid="d3033dc7-9069-479a-85da-b998d9380a38"/>
<textElement textAlignment="Right">
<font size="22" isBold="false"/>
</textElement>
<text><![CDATA[Datos personales]]></text>
</staticText>
</frame>
<frame>
<reportElement mode="Opaque" x="0" y="70" width="721" height="32" forecolor="#000000" backcolor="#CC0000" uuid="e1d39e3b-7bf5-4981-b52b-40b92acd7cbc"/>
<textField pattern="EEEEE dd MMMMM yyyy">
<reportElement x="553" y="12" width="144" height="20" forecolor="#FFFFFF" uuid="a496530e-1b92-4785-8734-c3624c29c720"/>
<textElement textAlignment="Right">
<font size="12"/>
</textElement>
<textFieldExpression><![CDATA[new java.util.Date()]]></textFieldExpression>
</textField>
</frame>
</band>
</title>
<pageHeader>
<band splitType="Stretch"/>
</pageHeader>
<columnHeader>
<band height="18" splitType="Stretch">
<staticText>
<reportElement style="Column header" x="0" y="0" width="68" height="18" forecolor="#000000" uuid="58ed651e-b71d-48ed-9f1e-07710ec5b631"/>
<textElement>
<font fontName="Calibri" isBold="false"/>
</textElement>
<text><![CDATA[ID Cliente]]></text>
</staticText>
<staticText>
<reportElement style="Column header" x="81" y="0" width="99" height="18" forecolor="#000000" uuid="66566603-aa5f-4e54-aeac-676e66b721e8"/>
<textElement>
<font isBold="false"/>
</textElement>
<text><![CDATA[Tipo Documento]]></text>
</staticText>
<staticText>
<reportElement style="Column header" x="198" y="0" width="88" height="18" forecolor="#000000" uuid="a1b81288-f82d-44e8-99e4-89ba11eeb3d3"/>
<textElement>
<font fontName="Calibri" isBold="false"/>
</textElement>
<text><![CDATA[Nombre Cliente]]></text>
</staticText>
<staticText>
<reportElement style="Column header" x="297" y="0" width="68" height="18" forecolor="#000000" uuid="2755d4ed-caed-4a0b-8aec-0fb751073631"/>
<textElement>
<font fontName="Calibri" isBold="false"/>
</textElement>
<text><![CDATA[Dirección]]></text>
</staticText>
<staticText>
<reportElement style="Column header" x="396" y="0" width="68" height="18" forecolor="#000000" uuid="7a87fd70-5970-4492-acc4-81b18bd4c7eb"/>
<textElement>
<font fontName="Calibri" isBold="false"/>
</textElement>
<text><![CDATA[Teléfono]]></text>
</staticText>
<staticText>
<reportElement style="Column header" x="495" y="0" width="68" height="18" forecolor="#000000" uuid="d3c8890e-db5b-4eff-8cc0-04d0d0653f14"/>
<textElement>
<font fontName="Calibri" isBold="false"/>
</textElement>
<text><![CDATA[Ciudad]]></text>
</staticText>
<staticText>
<reportElement style="Column header" x="594" y="0" width="83" height="18" forecolor="#000000" uuid="25cc940c-d59a-404a-afa2-56d73bc667a4"/>
<textElement>
<font fontName="Calibri" isBold="false"/>
</textElement>
<text><![CDATA[F.Nacimiento]]></text>
</staticText>
<staticText>
<reportElement style="Column header" x="693" y="0" width="68" height="18" forecolor="#000000" uuid="9cf20336-ba17-4d87-a0b6-d4c178252bca"/>
<textElement>
<font fontName="Calibri" isBold="false"/>
</textElement>
<text><![CDATA[F.Ingreso]]></text>
</staticText>
</band>
</columnHeader>
<detail>
<band height="18" splitType="Stretch">
<frame>
<reportElement style="Row" mode="Opaque" x="0" y="0" width="797" height="18" uuid="bc123d5e-6afd-4524-b876-f0fe8df58235"/>
<textField isStretchWithOverflow="true">
<reportElement style="Detail" positionType="Float" x="0" y="0" width="99" height="18" uuid="f76bc24c-e670-4f67-81db-ab6187c452ab"/>
<textElement>
<font fontName="Calibri" size="10"/>
</textElement>
<textFieldExpression><![CDATA[$F{ID Cliente}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true">
<reportElement style="Detail" positionType="Float" x="81" y="0" width="99" height="18" uuid="74808248-2f95-4b33-ae44-43d8a1fc2d2c"/>
<textElement>
<font fontName="Calibri" size="10"/>
</textElement>
<textFieldExpression><![CDATA[$F{Tipo Documento}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true">
<reportElement style="Detail" positionType="Float" x="198" y="0" width="99" height="18" uuid="54574af7-3fd0-4b32-a843-6d81cb3a7ba8"/>
<textElement>
<font fontName="Calibri" size="10"/>
</textElement>
<textFieldExpression><![CDATA[$F{Nombre del Cliente}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true">
<reportElement style="Detail" positionType="Float" x="297" y="0" width="99" height="18" uuid="4f76b4ef-3ead-4d94-ab69-7a4ba1841e33"/>
<textElement>
<font fontName="Calibri" size="10"/>
</textElement>
<textFieldExpression><![CDATA[$F{Dirección}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true">
<reportElement style="Detail" positionType="Float" x="396" y="0" width="99" height="18" uuid="3810cfd6-a303-4d99-96d9-d497d84909e0"/>
<textElement>
<font fontName="Calibri" size="10"/>
</textElement>
<textFieldExpression><![CDATA[$F{Teléfono}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true">
<reportElement style="Detail" positionType="Float" x="495" y="0" width="99" height="18" uuid="72112aca-65eb-4963-a85e-c9f96af3aecd"/>
<textElement>
<font fontName="Calibri" size="10"/>
</textElement>
<textFieldExpression><![CDATA[$F{Ciudad}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true">
<reportElement style="Detail" positionType="Float" x="594" y="0" width="99" height="18" uuid="4af86f21-24d3-4123-aae7-1e8f9338b037"/>
<textElement>
<font fontName="Calibri" size="10"/>
</textElement>
<textFieldExpression><![CDATA[$F{F.Nacimiento}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true">
<reportElement style="Detail" positionType="Float" x="693" y="0" width="99" height="18" uuid="a64ebc84-d946-4a6a-b613-0e8f2700f20b"/>
<textElement>
<font fontName="Calibri" size="10"/>
</textElement>
<textFieldExpression><![CDATA[$F{F.Ingreso}]]></textFieldExpression>
</textField>
</frame>
</band>
</detail>
<columnFooter>
<band height="7" splitType="Stretch">
<line>
<reportElement positionType="FixRelativeToBottom" x="0" y="3" width="555" height="1" uuid="d3a7366d-fd7c-4dbb-8263-73e8adfe9efe"/>
<graphicElement>
<pen lineWidth="0.5" lineColor="#999999"/>
</graphicElement>
</line>
</band>
</columnFooter>
<pageFooter>
<band height="25" splitType="Stretch">
<frame>
<reportElement mode="Opaque" x="0" y="0" width="802" height="25" forecolor="#D0B48E" backcolor="#000000" uuid="618249ff-9d72-4074-be59-b669d86c8a40"/>
<textField evaluationTime="Report">
<reportElement style="Column header" x="757" y="3" width="40" height="20" forecolor="#FFFFFF" uuid="ec2fb3a0-5ef7-44a8-a68f-bae5feeb84e0"/>
<textElement verticalAlignment="Middle">
<font size="10" isBold="false"/>
</textElement>
<textFieldExpression><![CDATA[" " + $V{PAGE_NUMBER}]]></textFieldExpression>
</textField>
<textField>
<reportElement style="Column header" x="677" y="3" width="80" height="20" forecolor="#FFFFFF" uuid="0ee9d159-10a6-4371-ab29-060088b4577b"/>
<textElement textAlignment="Right" verticalAlignment="Middle">
<font size="10" isBold="false"/>
</textElement>
<textFieldExpression><![CDATA["Page "+$V{PAGE_NUMBER}+" of"]]></textFieldExpression>
</textField>
<textField pattern="EEEEE dd MMMMM yyyy">
<reportElement style="Column header" x="2" y="3" width="197" height="20" forecolor="#FFFFFF" uuid="cdc3c4d4-6ee8-4ecc-ae54-8da5d1d354de"/>
<textElement verticalAlignment="Middle">
<font size="10" isBold="false"/>
</textElement>
<textFieldExpression><![CDATA[new java.util.Date()]]></textFieldExpression>
</textField>
</frame>
</band>
</pageFooter>
<summary>
<band splitType="Stretch"/>
</summary>
</jasperReport>