Redmine export задач и описаний в PDF в одну строчку

432 views
Skip to first unread message

Нурбек Якупов

unread,
Oct 30, 2015, 8:33:55 AM10/30/15
to RubyOnRails to russian
Добрый вечер, господа рубисты и им сочувстувующие.

В стандартном редмайне есть возможность экспортировать задачи в PDF файл. Все экпортируется отлично, однако если добавить поле "Описание" задачи в выходную форму, то поле "Описание" оказывается на второй строке. Нужно чтобы было в одно строчке.

Подскажите куда копать?

Выходит так:
















Надо так:




библиотека экспорта в PDF редмайна

# encoding: utf-8
#
# Redmine - project management software
# Copyright (C) 2006-2015  Jean-Philippe Lang
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

require 'rbpdf'

module Redmine
  module Export
    module PDF
      class ITCPDF < RBPDF
        include Redmine::I18n
        attr_accessor :footer_date

        def initialize(lang, orientation='P')
          @@k_path_cache = Rails.root.join('tmp', 'pdf')
          FileUtils.mkdir_p @@k_path_cache unless File::exist?(@@k_path_cache)
          set_language_if_valid lang
          super(orientation, 'mm', 'A4')
          set_print_header(false)
          set_rtl(l(:direction) == 'rtl')

          @font_for_content = l(:general_pdf_fontname)
          @font_for_footer  = l(:general_pdf_fontname)
          set_creator(Redmine::Info.app_name)
          set_font(@font_for_content)

          set_header_font([@font_for_content, '', 10])
          set_footer_font([@font_for_content, '', 8])
          set_default_monospaced_font(@font_for_content)
          set_display_mode('default', 'OneColumn')
        end

        def SetFontStyle(style, size)
          set_font(@font_for_content, style, size)
        end

        def SetFont(family, style='', size=0, fontfile='')
          # FreeSerif Bold Thai font has problem.
          style.delete!('B') if l(:general_pdf_fontname) == 'freeserif'
          # DejaVuSans Italic Arabic and Persian font has problem.
          style.delete!('I') if l(:general_pdf_fontname) == 'DejaVuSans'
          super(family, style, size, fontfile)
        end
        alias_method :set_font, :SetFont

        def fix_text_encoding(txt)
          RDMPdfEncoding::rdm_from_utf8(txt, "UTF-8")
        end

        def formatted_text(text)
          Redmine::WikiFormatting.to_html(Setting.text_formatting, text)
        end

        def RDMCell(w ,h=0, txt='', border=0, ln=0, align='', fill=0, link='')
          cell(w, h, txt, border, ln, align, fill, link)
        end

        def RDMMultiCell(w, h=0, txt='', border=0, align='', fill=0, ln=1)
          multi_cell(w, h, txt, border, align, fill, ln)
        end

        def RDMwriteFormattedCell(w, h, x, y, txt='', attachments=[], border=0, ln=1, fill=0)
          @attachments = attachments

          css_tag = ' <style>
          table, td {
            border: 2px #ff0000 solid;
          }
          th {  background-color:#EEEEEE; padding: 4px; white-space:nowrap; text-align: center;  font-style: bold;}
          pre {
            background-color: #fafafa;
          }
          </style>'

          # Strip {{toc}} tags
          txt.gsub!(/<p>\{\{([<>]?)toc\}\}<\/p>/i, '')
          writeHTMLCell(w, h, x, y, css_tag + txt, border, ln, fill)
        end

        def RDMwriteHTMLCell(w, h, x, y, txt='', attachments=[], border=0, ln=1, fill=0)
          txt = formatted_text(txt)
          RDMwriteFormattedCell(w, h, x, y, txt, attachments, border, ln, fill)
        end

        def get_image_filename(attrname)
          atta = RDMPdfEncoding.attach(@attachments, attrname, "UTF-8")
          if atta
            return atta.diskfile
          else
            return nil
          end
        end

        def get_sever_url(url)
          if !empty_string(url) and (url[0, 1] == '/')
            Setting.host_name.split('/')[0] + url
          else
            url
          end
        end

        def Footer
          set_font(@font_for_footer, 'I', 8)
          set_x(15)
          if get_rtl
            RDMCell(0, 5, @footer_date, 0, 0, 'R')
          else
            RDMCell(0, 5, @footer_date, 0, 0, 'L')
          end
          set_x(-30)
          RDMCell(0, 5, get_alias_num_page() + '/' + get_alias_nb_pages(), 0, 0, 'C')
        end
      end

      class RDMPdfEncoding
        def self.rdm_from_utf8(txt, encoding)
          txt ||= ''
          txt = Redmine::CodesetUtil.from_utf8(txt, encoding)
          txt.force_encoding('ASCII-8BIT')
          txt
        end

        def self.attach(attachments, filename, encoding)
          filename_utf8 = Redmine::CodesetUtil.to_utf8(filename, encoding)
          atta = nil
          if filename_utf8 =~ /^[^\/"]+\.(gif|jpg|jpe|jpeg|png)$/i
            atta = Attachment.latest_attach(attachments, filename_utf8)
          end
          if atta && atta.readable? && atta.visible?
            return atta
          else
            return nil
          end
        end
      end
    end
  end
end



Ilya Nemihin

unread,
Oct 30, 2015, 9:33:42 AM10/30/15
to ror...@googlegroups.com
тут просто не получится, т.к. это формирование PDF, а не html

--
--
Данное сообщение отправлено Вам, так как Вы являетесь подписчиком группы "RubyOnRails to russian" на https://groups.google.com/group/ror2ru
FAQ группы находится по адресу: http://ru.wikibooks.org/wiki/RubyFAQ
 
Для того, чтобы отправить сообщение в эту группу, пошлите его по адресу
ror...@googlegroups.com
---
Вы получили это сообщение, поскольку подписаны на группу "RubyOnRails to russian".
Чтобы отменить подписку на эту группу и больше не получать от нее сообщения, отправьте письмо на электронный адрес ror2ru+un...@googlegroups.com.
Чтобы посмотреть обсуждение на веб-странице, перейдите по ссылке https://groups.google.com/d/msgid/ror2ru/69acfbab-2af0-47fa-aa7e-a0779ccb12ef%40googlegroups.com.
Чтобы настроить другие параметры, перейдите по ссылке https://groups.google.com/d/optout.

Нурбек Якупов

unread,
Nov 12, 2015, 7:16:37 AM11/12/15
to ror...@googlegroups.com
Друзья, нужна помощь

есть такой хороший плагин - checklist

плагин работает на отлично.
единственная проблема, в выгружаемых формах (например в формате PDF) - эти чеклисты отсутствуют.

нужна помощь с допиливанием pdf.rb (в версии 2,6,5) или issues_pdf_helper.rb (redmine 3.1.1) чтобы можно было экспортировать ISSUES с чеклистами 
(а желательно сразу только те, которые выполнены (статус чеклиста - done)


Can anyone help?


30 октября 2015 г., 19:33 пользователь Ilya Nemihin <nem...@gmail.com> написал:
Чтобы посмотреть обсуждение на веб-странице, перейдите по ссылке https://groups.google.com/d/msgid/ror2ru/CAM30JeZBbFYScnFqANCo0eRfx%2BZOMaGhtrqRZA-H_ktBW1Hb3A%40mail.gmail.com.

Нурбек Якупов

unread,
Dec 3, 2015, 3:26:59 AM12/3/15
to ror...@googlegroups.com
добрый день, рубисты

Кто подскажет в какую сторону копать, чтобы в redmine чеклисты (из плагина redmine_checklist)  отображался в списке доступных столбцов ?
необходимо добавить возможность вывода в перечне задач чеклисты со статусам (выполнено)





заранее спасибо

12 ноября 2015 г., 18:16 пользователь Нурбек Якупов <y.nu...@gmail.com> написал:
Reply all
Reply to author
Forward
0 new messages