Class: DPTM6::PDF::DCLImage
Constant Summary
collapse
- REGEXP_PARSE =
Regexp.compile('(?:(\[[^\[\]]*+\])\s++)?+' <<
'(?:(-?+\d++(?:\.\d++)?+)\s++)?+' * 6 <<
'(?:(/\w++)\s++)?+' <<
'(\w++)\s++' <<
'((?:/\w++\s++\w++\s++){2})?+' )
Instance Attribute Summary
Attributes inherited from Object
#data, #num, #pdf
Instance Method Summary
collapse
Methods inherited from PageObject
#to_string
Methods inherited from Object
#replace_pagenum, #to_string
Constructor Details
#initialize(pdf, num) ⇒ DCLImage
287
288
289
|
# File 'lib/dptm6/pdf.rb', line 287
def initialize(pdf, num)
super(pdf, pdf.pages[num])
end
|
Instance Method Details
#move_to(pdf, num) ⇒ Object
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
|
# File 'lib/dptm6/pdf.rb', line 291
def move_to(pdf, num)
m = pdf.xref.size + 1
nx = @obj_resource.x_objects.size
@obj_content. move_to(pdf, m + 1)
@obj_content.obj_length.move_to(pdf, m + 2)
@obj_resource. move_to(pdf, m )
super(pdf, m + 3 + nx)
@obj_resource.x_objects.each_with_index do |(key,obj),i|
obj. move_to(pdf, m + 3 + i)
obj.obj_length.move_to(pdf, m + 4 + nx + i)
end
self
end
|
draw XObject (“… cm ‘/a0 gs /x5 Do ’”)
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
|
# File 'lib/dptm6/pdf.rb', line 328
def parse
stream_new = "q\n"
concat = nil
color = { :rg => nil, :RG => nil }
flag_x = false
buf_node = []
path = Path.new
str_check = @obj_content.stream.gsub(REGEXP_PARSE) do |a|
md = $~
op = md[-2].to_sym
case op
when :m, :l
buf_node << Path::Node.new(md[2], md[3], op)
when :h, :B
if flag_x
flag_x = false
Path.new(buf_node).output_stroke(stream_new, true)
path = Path.new
else
path.add(buf_node)
end
buf_node = []
when :S
path.optimize.output_fill(stream_new)
path = Path.new
Path.new(buf_node).output_stroke(stream_new)
buf_node = []
when :rg, :RG
rgbstr = md[2..4].join(' ')
if (rgbstr == color[op])
else
path.optimize.output_fill(stream_new)
path = Path.new
color[op] = rgbstr
stream_new << a
end
when :cm
if md[-1]
flag_x = true
stream_new << "q\n"
stream_new << "0 1 1 0 -842 0 cm\n" if concat
stream_new << a << "Q\n"
else
stream_new << "q " << (concat = a) unless concat
end
when :q, :Q
else
stream_new << a
end
''
end
STDERR.puts("WARNING: Some script could not be parsed -- #{str_check.inspect}") if (str_check != '')
stream_new << "Q\n"
@obj_content.stream = stream_new
self
end
|
#set_deflevel(level) ⇒ Object
312
313
314
|
# File 'lib/dptm6/pdf.rb', line 312
def set_deflevel(level)
@obj_content.set_deflevel(level)
end
|
316
317
318
319
320
321
|
# File 'lib/dptm6/pdf.rb', line 316
def write
@obj_content. write
@obj_resource.write
super
@obj_resource.x_objects.each_value(&:write)
end
|