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
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
|
# File 'lib/sisu/texpdf.rb', line 187
def latex_do(texfilename,papersize)
@texfilename=texfilename
@@n_lpdf=@@n_lpdf+1
tex_fn_base=@texfilename.gsub(/\.tex$/,'')
tell=SiSU_Screen::Ansi.new(@md.opt.selections.str)
if @md.opt.act[:pdf_p][:set]==:on
if (@md.opt.act[:verbose][:set]==:on \
|| @md.opt.act[:verbose_plus][:set]==:on \
|| @md.opt.act[:maintenance][:set]==:on)
SiSU_Screen::Ansi.new(
@md.opt.act[:color_state][:set],
"#{papersize} portrait ->"
).dark_grey_title_hi
end
cmd=SiSU_Env::SystemCall.new("#{tex_fn_base}.tex",'',@md.opt.selections.str)
if @md.opt.act[:verbose][:set]==:on \
|| @md.opt.act[:verbose_plus][:set]==:on \
|| @md.opt.act[:maintenance][:set]==:on
tell.grey_open
end
if "#{tex_fn_base}" =~/\w+/ \
and "#{papersize}" =~/\w+/
2.times { |i| cmd.latex2pdf(@md,papersize) } end
if @md.opt.act[:verbose][:set]==:on \
|| @md.opt.act[:verbose_plus][:set]==:on \
|| @md.opt.act[:maintenance][:set]==:on
tell.p_off
end
end
if @md.opt.act[:pdf_l][:set]==:on
if (@md.opt.act[:verbose][:set]==:on \
|| @md.opt.act[:verbose_plus][:set]==:on \
|| @md.opt.act[:maintenance][:set]==:on)
SiSU_Screen::Ansi.new(
@md.opt.act[:color_state][:set],
"#{papersize} landscape ->"
).dark_grey_title_hi
end
cmd=SiSU_Env::SystemCall.new("#{tex_fn_base}.landscape.tex",'',@md.opt.selections.str)
if (@md.opt.act[:verbose][:set]==:on \
|| @md.opt.act[:verbose_plus][:set]==:on \
|| @md.opt.act[:maintenance][:set]==:on)
tell.grey_open
end
if "#{tex_fn_base}" =~/\w+/ \
and "#{papersize}" =~/\w+/
2.times { |i| cmd.latex2pdf(@md,papersize) } end
if (@md.opt.act[:verbose][:set]==:on \
|| @md.opt.act[:verbose_plus][:set]==:on \
|| @md.opt.act[:maintenance][:set]==:on)
tell.p_off
end
end
pwd=Dir.pwd
if @md.opt.act[:pdf_p][:set]==:on
portrait_pdf="#{pwd}/#{tex_fn_base}.pdf"
end
if @md.opt.act[:pdf_l][:set]==:on
landscape_pdf="#{pwd}/#{tex_fn_base}.landscape.pdf"
end
case papersize
when /a4/ then pdf_p=@f.pdf_p_a4; pdf_l=@f.pdf_l_a4
when /a5/ then pdf_p=@f.pdf_p_a5; pdf_l=@f.pdf_l_a5
when /b5/ then pdf_p=@f.pdf_p_b5; pdf_l=@f.pdf_l_b5
when /letter/ then pdf_p=@f.pdf_p_letter; pdf_l=@f.pdf_l_letter
when /legal/ then pdf_p=@f.pdf_p_legal; pdf_l=@f.pdf_l_legal
else pdf_p=@f.pdf_p_a4; pdf_l=@f.pdf_l_a4
end
FileUtils::mkdir_p(@md.file.output_path.pdf.dir) unless FileTest.directory?(@md.file.output_path.pdf.dir)
cX=SiSU_Screen::Ansi.new(@md.opt.act[:color_state][:set]).cX
if @md.opt.act[:pdf_p][:set]==:on
if FileTest.file?(portrait_pdf)
FileUtils::cp(portrait_pdf,"#{@md.file.output_path.pdf.dir}/#{pdf_p}")
FileUtils::rm(portrait_pdf)
else
STDERR.puts "#{__FILE__}:#{__LINE__} NOT FOUND: #{portrait_pdf}" if @md.opt.act[:maintenance][:set]==:on
errmsg="pdf file not generated #{portrait_pdf.gsub(/.+?([^\/]+?\.pdf)$/,'\1')} (check texlive dependencies)"
if @md.opt.act[:no_stop][:set]==:on
SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).
error("#{errmsg}, proceeding without pdf output (as requested)")
else
SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).
error("#{errmsg}, STOPPING")
exit
end
end
end
if @md.opt.act[:pdf_l][:set]==:on
if FileTest.file?(landscape_pdf)
FileUtils::cp(landscape_pdf,"#{@md.file.output_path.pdf.dir}/#{pdf_l}")
FileUtils::rm(landscape_pdf)
else
STDERR.puts "#{__FILE__}:#{__LINE__} NOT FOUND: #{landscape_pdf}" if @md.opt.act[:maintenance][:set]==:on
errmsg="pdf file not generated #{landscape_pdf.gsub(/.+?([^\/]+?\.pdf)$/,'\1')} (check texlive dependencies)"
if @md.opt.act[:no_stop][:set]==:on
SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).
error("#{errmsg}, proceeding without pdf output (as requested)")
else
SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).
error("#{errmsg}, STOPPING")
exit
end
end
end
if (@md.opt.act[:verbose][:set]==:on \
|| @md.opt.act[:verbose_plus][:set]==:on \
|| @md.opt.act[:maintenance][:set]==:on)
SiSU_Screen::Ansi.new(
@md.opt.act[:color_state][:set],
@@n_lpdf,
'processed (SiSU LaTeX to pdf - using pdfetex aka. pdftex or pdflatex)'
).generic_number
end
end
|