Java - Problema de impresión en java

 
Vista:

Problema de impresión en java

Publicado por Xavier Torres (1 intervención) el 04/08/2017 21:47:53
Saludos. Me podrian ayudar con estas clases de java:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package impresion;
 
import java.awt.print.PageFormat;
import java.awt.print.Paper;
import java.awt.print.PrinterException;
import java.awt.print.PrinterJob;
 
class prueba8{
	public static void main(String []args){
		PrinterJob job = PrinterJob.getPrinterJob();
		PageFormat pf = job.defaultPage();
		Paper papel = new Paper();
		papel.setSize(612.0,832.0);
		double margin = 20;
		papel.setImageableArea(margin, margin, papel.getWidth() - margin, papel.getHeight() - margin);
		pf.setPaper(papel);
		pf.setOrientation(PageFormat.PORTRAIT);
		job.defaultPage(pf);
		job.setPrintable(new ObjetoDeImpresion());
		try{
			job.print();
		}catch(PrinterException e){
			System.out.println(e);
		}
	}
}
 
 
package impresion;
 
import java.awt.Graphics;
import java.awt.print.PageFormat;
import java.awt.print.Printable;
 
public class ObjetoDeImpresion implements Printable{
	int jota=1;
	int xxx=30;
	int yyy=10;
 
	public int print(Graphics g, PageFormat f, int pageIndex){
		if(jota<300) {
			yyy=100;
			int k=jota;
			for(int i=k; i<301; i++) {
				g.drawString("linea de impresion "+" "+i+" xxx "+xxx+" yyy "+yyy, xxx, yyy);
				yyy=yyy+12;
				jota=i;
				if(yyy>590) {
					System.out.println("Termino pagina "+pageIndex);
					return (PAGE_EXISTS);
				}
			}
			return PAGE_EXISTS;
		}else{
			return NO_SUCH_PAGE;
		}
	}
}

Porque se salta las páginas impares. Gracias.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

Problema de impresión en java

Publicado por fido (1 intervención) el 15/08/2017 02:48:29
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:pe="http://primefaces.org/ui/extensions">
    <h:head>
        <meta content='text/html; charset=UTF-8' http-equiv="Content-Type"/>
        <title>Rutas de Recolección</title>
        <link rel="icon" href="/ELEKTRADIS/resources/img/pestanaElektra.png" />
        <h:outputStylesheet library="css" name="general.css" />
    </h:head>
    <ui:include src="/portal/menu.xhtml"></ui:include>
    <h:body>
 
        <pe:ajaxErrorHandler type="javax.faces.application.ViewExpiredException" button="Reload"
                             buttonOnclick="document.location.href=document.location.href;"
                             body="Sesión invalidada" title="La página expiró ..."/>
 
        <h:form id="form" >
            <p:growl id="msg" sticky="true"  autoUpdate="true" showDetail="true" showSummary="true"/>
 
            <p:ajaxStatus id="ajaxStatus" onstart="statusDialog.show();" onsuccess="statusDialog.hide();" />
 
            <p:dialog modal="true" widgetVar="statusDialog"  draggable="false" closable="false" resizable="false" showHeader="false">
                <p:graphicImage library="img" name="horizontalloader.GIF" />
                <br/>
                <h:outputText value="Procesando." />
            </p:dialog>
 
            <p:panel header="Rutas de Recolección" rendered="true">
                <center>
                    <p:panelGrid>
                        <p:row>
                            <p:column colspan="3">
                                <center>
                                    <h:outputLabel value="Seleccione DS:" />
                                    <p:selectOneMenu value="#{recoleccion.ds}" style="margin-left:20px">
                                        <f:selectItems value="#{recoleccion.arrDss}" />
                                    </p:selectOneMenu>
                                </center>
                            </p:column>
                        </p:row>
                        <p:row>
                            <p:column>
                                <h:outputLabel value="Tipo de Recolecta:" />
                                <p:selectOneMenu value="#{recoleccion.tipoRecoleccion}" style="margin-left:10px">
                                    <p:ajax event="change" update="i_sku, i_tdas, i_ref" listener="#{recoleccion.valSku()}"/>
                                    <f:selectItems value="#{recoleccion.tiposRecoleccion}" />
                                </p:selectOneMenu>
                            </p:column>
                            <p:column>
                                <h:outputLabel value="Sku:" />
                                <p:column style="text-align: center">
                                    <p:inputText id="i_sku" value="#{recoleccion.sku}" style="text-align: center; margin-left:10px" disabled="#{!recoleccion.rdrSku}" />
                                </p:column>
                            </p:column>
                        </p:row>
                        <p:row>
                            <p:column>
                                <h:outputLabel value="Tiendas:" />
                                <p:column style="text-align: center">
                                    <p:inputText id="i_tdas" value="#{recoleccion.tiendas}" style="text-align: center; margin-left:10px" disabled="#{!recoleccion.rdrSku}" />
                                </p:column>
                            </p:column>
                            <p:column>
                                <h:outputLabel value="Referencia:" />
                                <p:column style="text-align: center">
                                    <p:inputText id="i_ref" value="#{recoleccion.referencia}" style="text-align: center; margin-left:10px" disabled="#{!recoleccion.rdrSku}" />
                                </p:column>
                            </p:column>
                        </p:row>
                        <f:facet name="footer">
                            <p:row>
                                <p:column colspan="2">
                                    <center>
                                        <p:commandButton value="Mostrar" icon="ui-icon-check" ajax="true" update=":form" actionListener="#{recoleccion.muestraRutasPendientes}" />
                                    </center>
                                </p:column>
                            </p:row>
                        </f:facet>
                    </p:panelGrid>
                </center>
 
                <p:dialog id="detalleDlg" widgetVar="detalleDlg" header="Detalle de Ruta" modal="true" resizable="false">
                    <p:dataTable id="detalleTbl" var="det" value="#{recoleccion.rutaDetalleList}" rendered="#{recoleccion.renderDataTblDetalle}"
                                 style="text-align:center;margin: 20px auto;font-size: 75%;"
                                 scrollable="true" scrollWidth="70%" scrollHeight="300">
                        <p:column width="30" headerText="SKU">
                            #{det.sku}
                        </p:column>
                        <p:column width="150" headerText="Descripción">
                            #{det.skuDesc}
                        </p:column>
                        <p:column width="50" headerText="Código de Remate">
                            #{det.codRemate}
                        </p:column>
                        <p:column width="40" headerText="Causa">
                            #{det.causa}
                        </p:column>
                        <p:column width="40" headerText="Cantidad">
                            #{det.cantidad}
                        </p:column>
                        <p:column width="40" headerText="m3">
                            #{det.getmCubicos()}
                        </p:column>
                    </p:dataTable>
                </p:dialog>
 
                <p:dataTable id="rutasCabecero" var="listCab" value="#{recoleccion.rutasCabeceroList}" rowKey="#{listCab.id}"
                             selection="#{recoleccion.listaRutaSeleccioanadas}" rendered="#{recoleccion.mostrarTabla}"
                             editable="true" editMode="cell"
                             scrollable="true" scrollHeight="150" scrollWidth="88%"
                             style="width: 90%;font-size: 75%; margin: 20px auto; text-align:center">
 
                    <p:ajax event="rowSelectCheckbox" listener="#{recoleccion.onRowSelect}" onstart="statusDialog.show();" onsuccess="statusDialog.hide();"  update=":form, :form:rutasCabecero:m2" global="false" />
                    <p:ajax event="rowUnselectCheckbox" listener="#{recoleccion.onRowUnselect}" onstart="statusDialog.show();" onsuccess="statusDialog.hide();" update=":form, :form:rutasCabecero:m2" global="false"/>
                    <p:ajax event="rowSelect" listener="#{recoleccion.onRowSelect}" onstart="statusDialog.show();" onsuccess="statusDialog.hide();" update=":form, :form:rutasCabecero:m2" global="false" />
                    <p:ajax event="rowUnselect" listener="#{recoleccion.onRowUnselect}" onstart="statusDialog.show();" onsuccess="statusDialog.hide();" update=":form , :form:rutasCabecero:m2" global="false"/>
                    <p:ajax event="cellEdit" listener="#{recoleccion.onCellEdit}" onstart="statusDialog.show();" onsuccess="statusDialog.hide();" update="rutasCabecero" />
 
                    <f:facet name="header">
                        Rutas Pendientes
                        <h:commandLink style="float:right">
                            <h:graphicImage library="img" name="Excel.png" style="height:20px;width:20px"/>
                            <p:dataExporter type="xls" target="rutasCabecero" fileName="repTransitoTdaDS"/>
                        </h:commandLink>
                    </f:facet>
 
                    <p:column width="15" selectionMode="multiple" exportable="false"/>
                    <p:column width="20">
                        <f:facet name="header">
                            <h:outputText value="#"/>
                        </f:facet>
                        <h:outputText value="#{listCab.id}"/>
                    </p:column>
 
                    <p:column width="40" sortBy="#{listCab.sucursal}" >
                        <f:facet name="header">
                            <h:outputText value="Sucursal"/>
                        </f:facet>
                        <h:outputText value="#{listCab.sucursal}" />
                    </p:column>
 
                    <p:column width="150" sortBy="#{listCab.sucDescripcion}" >
                        <f:facet name="header">
                            <h:outputText value="Descripción"/>
                        </f:facet>
                        <h:outputText value="#{listCab.sucDescripcion}"/>
                    </p:column>
 
                    <p:column width="40" sortBy="#{listCab.cantidadN}" >
                        <f:facet name="header">
                            <h:outputText value="Cantidad Normal"/>
                        </f:facet>
                        <h:outputText value="#{listCab.cantidadN}"/>
                    </p:column>
 
                    <p:column width="40" sortBy="#{listCab.mCubicosN}" >
                        <f:facet name="header">
                            <h:outputText value="m3 Normal"/>
                        </f:facet>
                        <h:outputText value="#{listCab.mCubicosN}"/>
                    </p:column>
 
                    <p:column width="40" sortBy="#{listCab.cantidadT}" >
                        <f:facet name="header">
                            <h:outputText value="Cantidad Telefonía"/>
                        </f:facet>
                        <h:outputText value="#{listCab.cantidadT}"/>
                    </p:column>
 
                    <p:column width="40" sortBy="#{listCab.mCubicosT}" >
                        <f:facet name="header">
                            <h:outputText value="m3 Telefonía"/>
                        </f:facet>
                        <h:outputText value="#{listCab.mCubicosT}"/>
                    </p:column>
 
                    <p:column  width="80" headerText="Tipo" exportable="false">
                        <p:cellEditor width="80">
                            <f:facet name="output" width="80"><h:outputText value="#{listCab.tipoSeleccionado}" /></f:facet>
                            <f:facet name="input" width="80">
                                <h:selectOneMenu value="#{listCab.tipoSeleccionado}" width="80">
                                    <f:selectItems value="#{listCab.tipo}" var="tipos" itemLabel="#{tipos}" itemValue="#{tipos}" />
                                </h:selectOneMenu>
                            </f:facet>
                        </p:cellEditor>
                    </p:column>
 
                    <p:column width="50" exportable="false">
                        <f:facet name="header">
                            <h:outputText value="Detalle"/>
                        </f:facet>
                        <p:commandButton update=":form:detalleDlg" oncomplete="detalleDlg.show()" icon="ui-icon-search" title="View">
                            <f:setPropertyActionListener value="#{listCab}" target="#{recoleccion.rutaSeleccionada}" />
                        </p:commandButton>
                    </p:column>
                    <f:facet name="footer">
                        <p:outputLabel id="m2" value="Metros Cúbicos acumulados: #{recoleccion.acumulado} m3" rendered="#{recoleccion.mostrarTabla}"/>
                    </f:facet>
                </p:dataTable>
 
 
 
                <p:dataTable id="economicosTbl" var="eco" value="#{recoleccion.listEconomicos}" selection="#{recoleccion.economicoSeleccionado}"
                             selectionMode="single" rowKey="#{eco.unipla}" rendered="#{recoleccion.mostrarEconomicoGrid}" filteredValue="#{recoleccion.listEconomicosFlt}"
                             style="width: 90%;font-size: 75%; margin: 20px auto; text-align:center"
                             scrollable="true" scrollHeight="150">
 
                    <f:facet name="header">
                        Selecciona el Económico
                    </f:facet>
 
                    <p:column width="50" headerText="Poveedor" sortBy="#{eco.unipro} ">
                        #{eco.unipro}
                    </p:column>
                    <p:column width="150" headerText="Descripcion" sortBy="#{eco.tralin}">
                        #{eco.tralin}
                    </p:column>
 
                    <p:column width="100" headerText="Económico" sortBy="#{eco.unieco}" filterBy="#{eco.unieco}">
                        #{eco.unieco}
                    </p:column>
 
                    <p:column width="50" headerText="Metros"  sortBy="#{eco.unimts}">
                        #{eco.unimts}
                    </p:column>
 
                    <p:column width="50" headerText="Placas" sortBy="#{eco.unipla}">
                        #{eco.unipla}
                    </p:column>
 
                    <p:column width="50" headerText="Tipo" sortBy="#{eco.unitipo}">
                        #{eco.unitipo}
                    </p:column>
 
                    <p:column width="150" headerText="Chofer" sortBy="#{eco.unicho}">
                        #{eco.unicho}
                    </p:column>
 
                    <f:facet name="footer">
                        <p:commandButton id="preCapturaBtn" value="Pre-Captura de Ruta" icon="ui-icon-check" action="#{recoleccion.caputraPreRuta()}" update=":form"  />
                    </f:facet>
                </p:dataTable>
            </p:panel>
        </h:form>
    </h:body>
</html>
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar