325: def initialize(options = {})
326: paper = options[:paper] || "LETTER"
327: orientation = options[:orientation] || :portrait
328: version = options[:version] || PDF_VERSION_13
329:
330: @mutex = Mutex.new
331: @current_id = @current_font_id = 0
332:
333:
334: @objects = []
335: @callbacks = []
336: @font_families = {}
337: @fonts = {}
338: @stack = []
339: @state_stack = StateStack.new
340: @loose_objects = []
341: @current_text_state = ""
342: @options = {}
343: @destinations = {}
344: @add_loose_objects = {}
345: @images = []
346: @word_space_adjust = nil
347: @current_stroke_style = PDF::Writer::StrokeStyle.new(1)
348: @page_numbering = nil
349: @arc4 = nil
350: @encryption = nil
351: @file_identifier = nil
352:
353: @columns = {}
354: @columns_on = false
355: @insert_mode = nil
356:
357: @catalog = PDF::Writer::Object::Catalog.new(self)
358: @outlines = PDF::Writer::Object::Outlines.new(self)
359: @pages = PDF::Writer::Object::Pages.new(self)
360:
361: @current_node = @pages
362: @procset = PDF::Writer::Object::Procset.new(self)
363: @info = PDF::Writer::Object::Info.new(self)
364: @page = PDF::Writer::Object::Page.new(self)
365: @current_text_render_style = 0
366: @first_page = @page
367:
368: @version = version
369:
370:
371: init_font_families
372:
373: @font_size = 10
374: @pageset = [@pages.first_page]
375:
376: if paper.kind_of?(Array)
377: if paper.size == 4
378: size = paper
379: else
380: size = [0, 0, PDF::Writer.cm2pts(paper[0]), PDF::Writer.cm2pts(paper[1])]
381:
382: end
383: else
384: size = PAGE_SIZES[paper.upcase].dup
385: end
386: size[3], size[2] = size[2], size[3] if orientation == :landscape
387:
388: @pages.media_box = size
389:
390: @page_width = size[2] - size[0]
391: @page_height = size[3] - size[1]
392: @y = @page_height
393:
394:
395:
396: margins_pt(36)
397:
398:
399: @y = absolute_top_margin
400:
401:
402:
403: fill_color! Color::RGB::Black
404: stroke_color! Color::RGB::Black
405:
406: yield self if block_given?
407: end