imposition 0.9.2 → 0.9.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/impostor +1 -1
- data/lib/imposition/clases.rb +13 -3
- data/lib/imposition/metodos.rb +26 -11
- metadata +3 -3
data/bin/impostor
CHANGED
@@ -67,7 +67,7 @@ def escalado(tipo)
|
|
67
67
|
end
|
68
68
|
#
|
69
69
|
def todasPag(nPliegos, nX, nY, caben, tiene)
|
70
|
-
STDOUT.puts("el pdf tiene #{tiene.to_i} paginas, pero en #{nPliegos.to_i} de #{nX}x#{nY} caben #{caben.to_i} paginas ¿usar las del pdf? (y/n)")
|
70
|
+
#STDOUT.puts("el pdf tiene #{tiene.to_i} paginas, pero en #{nPliegos.to_i} de #{nX}x#{nY} caben #{caben.to_i} paginas ¿usar las del pdf? (y/n)")
|
71
71
|
escalar=STDIN.gets.to_s
|
72
72
|
if escalar[0]==121 then#Y
|
73
73
|
return true
|
data/lib/imposition/clases.rb
CHANGED
@@ -100,7 +100,11 @@ class Mensaje
|
|
100
100
|
return @retorno
|
101
101
|
end
|
102
102
|
def ==(msg)
|
103
|
-
|
103
|
+
if msg!=nil then
|
104
|
+
return @id==msg.id
|
105
|
+
else
|
106
|
+
return false
|
107
|
+
end
|
104
108
|
end
|
105
109
|
end
|
106
110
|
#
|
@@ -209,6 +213,7 @@ class MensajeMedida < Mensaje
|
|
209
213
|
if level==3 then
|
210
214
|
return "no caben #{args[0]} paginas de #{args[1]["numero"].to_s+args[1]["unidad"]} de alto en un pliego de #{args[2]["numero"].to_s+args[2]["unidad"]}"
|
211
215
|
elsif level==2 then
|
216
|
+
@id=15
|
212
217
|
return "sobra #{args[0].to_s+args[1]} de alto"
|
213
218
|
end
|
214
219
|
end
|
@@ -307,6 +312,7 @@ end
|
|
307
312
|
class PreguntaCXC < Pregunta
|
308
313
|
attr_reader :cXC
|
309
314
|
def initialize()
|
315
|
+
@ide=4
|
310
316
|
@mensaje="cXC - cuadernillos por costura (0->todos unos dentro de otros, 1->todos uno al lado de otro o n-> de a n cuadernillos uno dentro de otro)"
|
311
317
|
end
|
312
318
|
def metodo(cXC)
|
@@ -337,6 +343,8 @@ end
|
|
337
343
|
class PreguntaTodasPag < Pregunta
|
338
344
|
attr_accessor :nPliegos, :nX, :nY, :caben, :tiene
|
339
345
|
def initialize(nPliegos, nX, nY, caben, tiene)
|
346
|
+
@ide=3
|
347
|
+
@mensaje="el pdf tiene #{tiene.to_i} paginas, pero en #{nPliegos.to_i} de #{nX}x#{nY} caben #{caben.to_i} paginas ¿usar las del pdf? (y/n)"
|
340
348
|
@nPliegos=nPliegos
|
341
349
|
@nX=nX
|
342
350
|
@nY=nY
|
@@ -352,7 +360,8 @@ end
|
|
352
360
|
class PreguntaReducir < Pregunta
|
353
361
|
attr_reader :q, :cuadernillosPorCostura, :paginasSobran, :nCuad, :sobranMenos
|
354
362
|
def initialize(cuadernillosPorCostura, paginasSobran, nCuad, sobranMenos, q)
|
355
|
-
@
|
363
|
+
@ide=5
|
364
|
+
@mensaje="al ultimo grupo de #{cuadernillosPorCostura} cuadernillos le sobraran #{paginasSobran}p podemos reducirlo a #{nCuad} cuadernillos, asi sobrarian #{sobranMenos}. ¿0K? (y/n)"
|
356
365
|
@cuadernillosPorCostura=cuadernillosPorCostura
|
357
366
|
@paginasSobran=paginasSobran
|
358
367
|
@nCuad=nCuad
|
@@ -396,4 +405,5 @@ class RespuestaImpostor
|
|
396
405
|
end
|
397
406
|
|
398
407
|
end#fin módulo
|
399
|
-
|
408
|
+
#proximo
|
409
|
+
#16
|
data/lib/imposition/metodos.rb
CHANGED
@@ -91,8 +91,16 @@ def refresh
|
|
91
91
|
FileUtils.cp($entrada, $temp)
|
92
92
|
end
|
93
93
|
|
94
|
+
#forma hash de variable para impostor
|
95
|
+
def nuevo(valor,unidad)
|
96
|
+
retorno=Hash.new
|
97
|
+
retorno["numero"]=valor ||= 0
|
98
|
+
retorno["unidad"]=unidad
|
99
|
+
return retorno
|
100
|
+
end
|
101
|
+
|
94
102
|
#########
|
95
|
-
module_function :funcionar, :checksCompile, :checksRun, :input2alchemist, :refresh
|
103
|
+
module_function :funcionar, :checksCompile, :checksRun, :input2alchemist, :refresh, :nuevo
|
96
104
|
|
97
105
|
def self.pdfinfo(impostor, temp)
|
98
106
|
Dir.chdir(File.dirname(temp))
|
@@ -151,7 +159,6 @@ def self.imponerStack(impostor,temp)
|
|
151
159
|
hC=pdflatexUnit(impostor.h, impostor.h_["unidad"])
|
152
160
|
impostor.h=hC[0]
|
153
161
|
impostor.h_["unidad"]=hC[1]
|
154
|
-
|
155
162
|
#las paginas que no existen se dejan en blanco
|
156
163
|
cS=cutStack(impostor.nX,impostor.nY,impostor.nPaginas,impostor.nPliegos,impostor.w.to_f,impostor.h.to_f)
|
157
164
|
for i in 0...cS.size
|
@@ -179,7 +186,8 @@ def self.imponerStack(impostor,temp)
|
|
179
186
|
cutStack.puts "marginpar=0mm"
|
180
187
|
cutStack.puts "}"
|
181
188
|
cutStack.puts "\\begin{document}"
|
182
|
-
cutStack.puts "\\includepdf[pages={#{cS}},nup=#{impostor.nX}x#{impostor.nY},noautoscale,
|
189
|
+
cutStack.puts "\\includepdf[pages={#{cS}},nup=#{impostor.nX}x#{impostor.nY},noautoscale, width=#{impostor.w}#{impostor.w_["unidad"]}, height=#{impostor.h}#{impostor.h_["unidad"]}]{#{temp}}"
|
190
|
+
#TODO frame opcional
|
183
191
|
cutStack.puts "\\end{document}"
|
184
192
|
end
|
185
193
|
|
@@ -320,7 +328,7 @@ end
|
|
320
328
|
def self.cutStack(nX,nY,nPaginas,nPliegos,w,h)
|
321
329
|
coordenadas=getCoordinates(nX,nY,w,h)
|
322
330
|
posiciones=myPlacePDF(nX,nY,nPaginas,nPliegos)
|
323
|
-
|
331
|
+
remix=[]
|
324
332
|
for i in 0...posiciones.size
|
325
333
|
mix=Clases::Mix.new(posiciones[i].mC, coordenadas[posiciones[i].mP].x, coordenadas[posiciones[i].mP].y, posiciones[i].t)
|
326
334
|
remix.insert(i, mix)
|
@@ -413,14 +421,14 @@ def self.mult4(paginasEnPliego)
|
|
413
421
|
end
|
414
422
|
|
415
423
|
def self.cortarCola(nPaginas, pagsEnCuadernillo, cuadernillosPorCostura)
|
416
|
-
max = (nPaginas/pagsEnCuadernillo).ceil
|
424
|
+
max = (nPaginas.to_f/pagsEnCuadernillo.to_f).ceil
|
417
425
|
if max*pagsEnCuadernillo>nPaginas then
|
418
426
|
anterior=pagsEnCuadernillo*(max-1)
|
419
427
|
q=nPaginas-anterior
|
420
428
|
if q%4!=0 then
|
421
429
|
q=((q/4)+1)*4
|
422
430
|
end
|
423
|
-
if anterior+q < max*pagsEnCuadernillo then
|
431
|
+
if anterior+q < max*pagsEnCuadernillo then
|
424
432
|
return Clases::PreguntaReducir.new(cuadernillosPorCostura, max*pagsEnCuadernillo-nPaginas, q/4, (anterior+q)-nPaginas, q)
|
425
433
|
end
|
426
434
|
end
|
@@ -514,8 +522,8 @@ def self.validacion(impostor, preguntas)
|
|
514
522
|
impostor.w=impostor.wReal
|
515
523
|
if impostor.cuadernillos then
|
516
524
|
impostor.w=impostor.w*2
|
517
|
-
impostor.w_["numero"]=impostor.w
|
518
525
|
end
|
526
|
+
impostor.w_["numero"]=impostor.w
|
519
527
|
impostor.w_["unidad"]=impostor.size["unidad"]
|
520
528
|
mensajes.push(Clases::MensajeDato.new(1, "horizontal", 4))#info
|
521
529
|
impostor.wP_["numero"]=impostor.nX*impostor.w.to_f
|
@@ -595,14 +603,14 @@ def self.validacion(impostor, preguntas)
|
|
595
603
|
hPDummy=impostor.hP_["numero"].send(impostor.hP_["unidad"])
|
596
604
|
if redondear(impostor.nX*impostor.w.to_f) > redondear(impostor.wP.to(impostor.w_["unidad"]).to_f) then
|
597
605
|
mensajes.push(Clases::MensajeMedida.new(3, "horizontal", [impostor.nX, impostor.w_, impostor.wP_]))#error
|
598
|
-
elsif impostor.nX>0 and wPDummy -(impostor.nX*impostor.w.to_f).send(impostor.w_["unidad"]) >
|
606
|
+
elsif impostor.nX>0 and wPDummy -(impostor.nX*impostor.w.to_f).send(impostor.w_["unidad"]) > 1.send("point") then
|
599
607
|
sobra=impostor.wP-(impostor.nX*impostor.w.to_f).send(impostor.w_["unidad"])
|
600
608
|
impostor.wP=impostor.wP_["numero"].send(impostor.wP_["unidad"])
|
601
609
|
mensajes.push(Clases::MensajeMedida.new(2, "horizontal", [sobra, impostor.wP_["unidad"]]))#warn
|
602
610
|
end
|
603
611
|
if redondear(impostor.nY*impostor.h.to_f) > redondear(impostor.hP.to(impostor.h_["unidad"]).to_f) then
|
604
612
|
mensajes.push(Clases::MensajeMedida.new(3, "vertical", [impostor.nY, impostor.h_, impostor.hP_]))#error
|
605
|
-
elsif impostor.nY>0 and hPDummy - (impostor.nY*impostor.h.to_f).send(impostor.h_["unidad"]) >
|
613
|
+
elsif impostor.nY>0 and hPDummy - (impostor.nY*impostor.h.to_f).send(impostor.h_["unidad"]) > 1.send("point") then
|
606
614
|
sobra=impostor.hP-(impostor.nY*impostor.h.to_f).send(impostor.h_["unidad"])
|
607
615
|
impostor.hP=impostor.hP_["numero"].send(impostor.hP_["unidad"])
|
608
616
|
mensajes.push(Clases::MensajeMedida.new(2, "vertical", [sobra, impostor.hP_["unidad"]]))#warn
|
@@ -674,7 +682,10 @@ def self.validacion(impostor, preguntas)
|
|
674
682
|
pagsEnCuadernillo=impostor.cuadernillosPorCostura*4
|
675
683
|
end
|
676
684
|
if preguntas["reducir"]==nil or !preguntas["reducir"].ok then
|
677
|
-
|
685
|
+
reducir=cortarCola(impostor.nPaginas, pagsEnCuadernillo, impostor.cuadernillosPorCostura)
|
686
|
+
if reducir!=nil then
|
687
|
+
preguntas["reducir"]=reducir
|
688
|
+
end
|
678
689
|
else
|
679
690
|
if preguntas["reducir"].yn then
|
680
691
|
q=preguntas["reducir"].q
|
@@ -682,14 +693,18 @@ def self.validacion(impostor, preguntas)
|
|
682
693
|
end
|
683
694
|
impostor.bookletz=booklets(pagsEnCuadernillo, impostor.nPaginas, impostor.nPaginasReal, q)
|
684
695
|
impostor.nPaginas=impostor.bookletz.length/2
|
696
|
+
impostor.nPliegos=(2*impostor.nPaginas.to_f/(nXm*impostor.nY)).ceil
|
697
|
+
#mensajes.push(Clases::MensajeDato.new(1, "paginas", 2))#info TODO if not already
|
685
698
|
end
|
686
699
|
#nPaginas multiplo de nX*nY
|
687
700
|
if impostor.nX*impostor.nY!=0 and impostor.nPaginas%(impostor.nX*impostor.nY)!=0 then
|
688
701
|
impostor.nPaginas=(impostor.nPaginas/(impostor.nX*impostor.nY)+1)*(impostor.nX*impostor.nY)
|
689
702
|
mensajes.push(Clases::MensajeMultiplo.new(1, "El pdf tiene #{impostor.nPaginasReal} paginas, que impuestas en #{impostor.nX}x#{impostor.nY} son #{impostor.nPaginas} paginas"))
|
703
|
+
#TODO impostor.nPliegos=(impostor.nPaginas.to_f/(nXm*impostor.nY)).ceil ?
|
690
704
|
end
|
691
|
-
|
705
|
+
|
692
706
|
return Clases::RespuestaImpostor.new(preguntas,mensajes)
|
693
707
|
end
|
708
|
+
#TODO ¿ROTAR? si se gasta menos espacio por pliego o en total da menos pliegos
|
694
709
|
|
695
710
|
end
|
metadata
CHANGED