Пример #1
0
        public Program(string res_dir, string style_path, string graphics_path, string output_path)
        {
            m_font_factory  = new FontFactory(res_dir);
            m_page_property = new PageProperty();

            m_style_root    = JObject.Parse(File.ReadAllText(style_path));
            m_graphics_root = JObject.Parse(File.ReadAllText(graphics_path));

            m_page_width  = m_page_property.A4_SHORT;
            m_page_height = m_page_property.A4_LONG;

            m_page_count    = 1;
            m_show_page_num = false;

            if (m_style_root["main"] != null)
            {
                if (m_style_root["main"]["width"] != null)
                {
                    m_page_width = (Int64)m_style_root["main"]["width"];
                }

                if (m_style_root["main"]["height"] != null)
                {
                    m_page_height = (Int64)m_style_root["main"]["height"];
                }

                if (m_style_root["main"]["pages"] != null)
                {
                    m_page_count = (int)m_style_root["main"]["pages"];
                }

                if (m_style_root["main"]["show_page"] != null)
                {
                    m_show_page_num = (int)m_style_root["main"]["show_page"] != 0;
                }
            }

            m_page_property.reset(m_page_width, m_page_height);
            m_document = new Document(new RectangleReadOnly(m_page_width, m_page_height));
            m_writer   = PdfWriter.GetInstance(m_document, new FileStream(output_path, FileMode.Create));

            m_document.Open();

            m_direct_content       = m_writer.DirectContent;
            m_direct_content_under = m_writer.DirectContentUnder;
            m_direct_op            = new DirectOperator(
                m_direct_content_under, m_direct_content, m_page_property, m_font_factory);

            m_op_page_map = new Dictionary <int, List <string> >();
            m_custom_oprs = new Dictionary <string, List <string> >();
        }
Пример #2
0
        public DKOperators(
            PdfContentByte direct_content,
            PageProperty page_property,
            FontFactory font_factory,
            DirectOperator direct_op)
        {
            m_direct_content = direct_content;
            m_page_property  = page_property;
            m_font_factory   = font_factory;
            m_direct_op      = direct_op;

            m_width  = m_page_property.RESOLUTION;
            m_height = m_page_property.RESOLUTION;
        }