Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Font size of pdf as optional argument #11

Open
cibinjoseph opened this issue Jan 28, 2018 · 8 comments
Open

Font size of pdf as optional argument #11

cibinjoseph opened this issue Jan 28, 2018 · 8 comments

Comments

@cibinjoseph
Copy link

The possibility of passing font size (or scaling) of the generated pdf as an option while invoking code2pdf would be a great addition.

@lucascaton
Copy link
Owner

Thanks for your suggestion, @cibinjoseph.

Feel free to submit a PR! 🙂

@vaibhavgeek
Copy link

How do I change font-size in the library code? It seems the font size is being defined by Rouge Gem

@vaibhavgeek
Copy link

vaibhavgeek commented Oct 4, 2018

It just changes the file path font style. I came up with a hack but the problem is that the code refactoring goes away when one does that.

def pdf
    html ||= ''
    codestyle = 'font-size: 16px;' 
    style = 'size: 19px; font-family: Helvetica, sans-serif;'
    read_files.each do |file|
      html += "<strong style='#{style}'>File: #{file.first}</strong></br></br>"
      html += "<code style='#{codestyle}'><pre>" + prepare_line_breaks(file.last).to_s + "</pre></code>"
      html += add_space(30)
    end

    @kit = PDFKit.new(html, page_size: 'A4')
    @kit
  end

I looked into Rouge Gem but that didn't help much either. Let me know how to work this out, I am looking forward to create a pull request.

@biwin
Copy link

biwin commented Oct 15, 2018

It would be better to go for a monospaced font by default because it is code 😄

@vaibhavgeek
Copy link

I am looking for coloured fonts.

@biwin
Copy link

biwin commented Oct 15, 2018

Would colored font make any sense with code in a PDF file? I guess they are for typography design . 😆

@juanyunis
Copy link

juanyunis commented Mar 31, 2020

I know this is an old issue, but for anyone that wants to customize font, colors and other css attributes, the way i did it is to use Rouge legacy formatter and to have a syntax.css file at the root of the project because PDFKit will load it.

To get a sample css file, you can run rougify style base16.light > syntax.css in the root of the project and you will be able to customize that css.

I have attached my /lib/code2pdf/convert_to_pdf.rb file here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants