lucascaton / code2pdf Goto Github PK
View Code? Open in Web Editor NEWConvert your source code to PDF
Home Page: https://www.lucascaton.com.br/
License: Other
Convert your source code to PDF
Home Page: https://www.lucascaton.com.br/
License: Other
[Code2pdf v.1.0.0 // Python v.3.5.1 //Windows ] [Installed using git clone]
I am trying to execute the following code:
from Code2pdf.code2pdf import Code2pdf
ifile,ofile,size = "test.py", "test.pdf", "A4"
pdf = Code2pdf(ifile, ofile, size) # create the Code2pdf object
pdf.init_print() # call print method to print pdf
And I get the following error:
ImportError: cannot import name 'main'
The possibility of passing font size (or scaling) of the generated pdf as an option while invoking code2pdf would be a great addition.
Hi,
Whenever I attempt to convert my source code, I receive an error stating that there is no such file or directory, even when it exists. I have also tried moving my source code files to different directories and it has made no difference.
Here is the full log:
PS E:\Program Files (x86)\Ruby25-x64\bin> Code2pdf C:/Users/Ben/Desktop/Kameleon/app/src/main
Reading file C:/Users/Ben/Desktop/Kameleon/app/src/main/AndroidManifest.xml
Traceback (most recent call last):
13: from E:/Program Files (x86)/Ruby25-x64/bin/code2pdf:23:in `<main>'
12: from E:/Program Files (x86)/Ruby25-x64/bin/code2pdf:23:in `load'
11: from E:/Program Files (x86)/Ruby25-x64/lib/ruby/gems/2.5.0/gems/code2pdf-0.4.3/bin/code2pdf:39:in `<top (required)>'
10: from E:/Program Files (x86)/Ruby25-x64/lib/ruby/gems/2.5.0/gems/code2pdf-0.4.3/bin/code2pdf:39:in `new'
9: from E:/Program Files (x86)/Ruby25-x64/lib/ruby/gems/2.5.0/gems/code2pdf-0.4.3/lib/code2pdf/convert_to_pdf.rb:23:in `initialize'
8: from E:/Program Files (x86)/Ruby25-x64/lib/ruby/gems/2.5.0/gems/code2pdf-0.4.3/lib/code2pdf/convert_to_pdf.rb:30:in `save'
7: from E:/Program Files (x86)/Ruby25-x64/lib/ruby/gems/2.5.0/gems/code2pdf-0.4.3/lib/code2pdf/convert_to_pdf.rb:38:in `pdf'
6: from E:/Program Files (x86)/Ruby25-x64/lib/ruby/gems/2.5.0/gems/code2pdf-0.4.3/lib/code2pdf/convert_to_pdf.rb:90:in `read_files'
5: from E:/Program Files (x86)/Ruby25-x64/lib/ruby/gems/2.5.0/gems/code2pdf-0.4.3/lib/code2pdf/convert_to_pdf.rb:90:in `foreach'
4: from E:/Program Files (x86)/Ruby25-x64/lib/ruby/gems/2.5.0/gems/code2pdf-0.4.3/lib/code2pdf/convert_to_pdf.rb:96:in `block in read_files'
3: from E:/Program Files (x86)/Ruby25-x64/lib/ruby/gems/2.5.0/gems/code2pdf-0.4.3/lib/code2pdf/convert_to_pdf.rb:107:in `process_file'
2: from E:/Program Files (x86)/Ruby25-x64/lib/ruby/gems/2.5.0/gems/code2pdf-0.4.3/lib/code2pdf/convert_to_pdf.rb:107:in `open'
1: from E:/Program Files (x86)/Ruby25-x64/lib/ruby/gems/2.5.0/gems/code2pdf-0.4.3/lib/code2pdf/convert_to_pdf.rb:108:in `block in process_file'
E:/Program Files (x86)/Ruby25-x64/lib/ruby/gems/2.5.0/gems/code2pdf-0.4.3/lib/code2pdf/convert_to_pdf.rb:108:in ``': No such file or directory - file C:/Users/Ben/Desktop/Kameleon/app/src/main/AndroidManifest.xml (Errno::ENOENT)
I hope that you can help me fix this issue, thank you.
Requests
I ran the code2pdf command. It didnt specify the location of the output pdf file.
Hey, Lucas! Thanks a lot for the great tool!
My Cyrillic text was hidden from my source code at pdf. Could you add supporting that.
This program needs the capability to soft-wrap files, otherwise the code gets really tiny when encountering long lines of code.
Would be great if the program can detect common binary files (such as jpg and mp4s) and not attempt to read them.
Na execusão do code2pdf em alguns arquivos é apresentado este erro:
Reading file SiNNP/modules/mod_menu/helper.php
/var/lib/gems/2.3.0/gems/rouge-3.1.0/lib/rouge/regex_lexer.rb:304:in skip': invalid byte sequence in UTF-8 (ArgumentError) from /var/lib/gems/2.3.0/gems/rouge-3.1.0/lib/rouge/regex_lexer.rb:304:in
block in step'
from /var/lib/gems/2.3.0/gems/rouge-3.1.0/lib/rouge/regex_lexer.rb:289:in each' from /var/lib/gems/2.3.0/gems/rouge-3.1.0/lib/rouge/regex_lexer.rb:289:in
step'
from /var/lib/gems/2.3.0/gems/rouge-3.1.0/lib/rouge/regex_lexer.rb:270:in stream_tokens' from /var/lib/gems/2.3.0/gems/rouge-3.1.0/lib/rouge/lexer.rb:405:in
lex'
from /var/lib/gems/2.3.0/gems/rouge-3.1.0/lib/rouge/formatters/html_table.rb:27:in each' from /var/lib/gems/2.3.0/gems/rouge-3.1.0/lib/rouge/formatters/html_table.rb:27:in
stream'
from /var/lib/gems/2.3.0/gems/rouge-3.1.0/lib/rouge/formatter.rb:37:in format' from /var/lib/gems/2.3.0/gems/code2pdf-0.4.1/lib/code2pdf/convert_to_pdf.rb:53:in
syntax_highlight'
from /var/lib/gems/2.3.0/gems/code2pdf-0.4.1/lib/code2pdf/convert_to_pdf.rb:37:in block in pdf' from /var/lib/gems/2.3.0/gems/code2pdf-0.4.1/lib/code2pdf/convert_to_pdf.rb:35:in
each'
from /var/lib/gems/2.3.0/gems/code2pdf-0.4.1/lib/code2pdf/convert_to_pdf.rb:35:in pdf' from /var/lib/gems/2.3.0/gems/code2pdf-0.4.1/lib/code2pdf/convert_to_pdf.rb:27:in
save'
from /var/lib/gems/2.3.0/gems/code2pdf-0.4.1/lib/code2pdf/convert_to_pdf.rb:20:in initialize' from /var/lib/gems/2.3.0/gems/code2pdf-0.4.1/bin/code2pdf:33:in
new'
from /var/lib/gems/2.3.0/gems/code2pdf-0.4.1/bin/code2pdf:33:in <top (required)>' from /usr/local/bin/code2pdf:23:in
load'
from /usr/local/bin/code2pdf:23:in `
Hi, thanks for app. But i got error with russia words:
Reading file ./microservices/transcoding_to_360/consumer_echo.py
/var/lib/gems/2.3.0/gems/code2pdf-0.4.2/lib/code2pdf/convert_to_pdf.rb:114:in `gsub': invalid byte sequence in UTF-8 (ArgumentError)
from /var/lib/gems/2.3.0/gems/code2pdf-0.4.2/lib/code2pdf/convert_to_pdf.rb:114:in `prepare_line_breaks'
from /var/lib/gems/2.3.0/gems/code2pdf-0.4.2/lib/code2pdf/convert_to_pdf.rb:37:in `block in pdf'
from /var/lib/gems/2.3.0/gems/code2pdf-0.4.2/lib/code2pdf/convert_to_pdf.rb:35:in `each'
from /var/lib/gems/2.3.0/gems/code2pdf-0.4.2/lib/code2pdf/convert_to_pdf.rb:35:in `pdf'
from /var/lib/gems/2.3.0/gems/code2pdf-0.4.2/lib/code2pdf/convert_to_pdf.rb:27:in `save'
from /var/lib/gems/2.3.0/gems/code2pdf-0.4.2/lib/code2pdf/convert_to_pdf.rb:20:in `initialize'
from /var/lib/gems/2.3.0/gems/code2pdf-0.4.2/bin/code2pdf:39:in `new'
from /var/lib/gems/2.3.0/gems/code2pdf-0.4.2/bin/code2pdf:39:in `<top (required)>'
from /usr/local/bin/code2pdf:22:in `load'
from /usr/local/bin/code2pdf:22:in `<main>'
Hi!
I install Ruby with RVM and code2pdf lib, but when I execute the command, I get this error:
/root/.rvm/gems/ruby-2.1.10/gems/code2pdf-0.4.2/lib/code2pdf/convert_to_pdf.rb:1 14:in `gsub': invalid byte sequence in UTF-8 (ArgumentError)
from /root/.rvm/gems/ruby-2.1.10/gems/code2pdf-0.4.2/lib/code2pdf/conver t_to_pdf.rb:114:in `prepare_line_breaks'
from /root/.rvm/gems/ruby-2.1.10/gems/code2pdf-0.4.2/lib/code2pdf/conver t_to_pdf.rb:37:in `block in pdf'
from /root/.rvm/gems/ruby-2.1.10/gems/code2pdf-0.4.2/lib/code2pdf/conver t_to_pdf.rb:35:in `each'
from /root/.rvm/gems/ruby-2.1.10/gems/code2pdf-0.4.2/lib/code2pdf/conver t_to_pdf.rb:35:in `pdf'
from /root/.rvm/gems/ruby-2.1.10/gems/code2pdf-0.4.2/lib/code2pdf/conver t_to_pdf.rb:27:in `save'
from /root/.rvm/gems/ruby-2.1.10/gems/code2pdf-0.4.2/lib/code2pdf/conver t_to_pdf.rb:20:in `initialize'
from /root/.rvm/gems/ruby-2.1.10/gems/code2pdf-0.4.2/bin/code2pdf:39:in `new'
from /root/.rvm/gems/ruby-2.1.10/gems/code2pdf-0.4.2/bin/code2pdf:39:in `<top (required)>'
from /root/.rvm/gems/ruby-2.1.10/bin/code2pdf:23:in `load'
from /root/.rvm/gems/ruby-2.1.10/bin/code2pdf:23:in `<main>'
from /root/.rvm/gems/ruby-2.1.10/bin/ruby_executable_hooks:15:in `eval'
from /root/.rvm/gems/ruby-2.1.10/bin/ruby_executable_hooks:15:in `<main>
It's my first time using this lib. How I can proceed?
Thank you.
Mac OS 10.15.4
Trying to convert a ReactJS project. just src directory.
What did I made wrong?
Traceback (most recent call last):
10: from /usr/local/bin/code2pdf:23:in `<main>'
9: from /usr/local/bin/code2pdf:23:in `load'
8: from /Library/Ruby/Gems/2.6.0/gems/code2pdf-0.4.3/bin/code2pdf:39:in `<top (required)>'
7: from /Library/Ruby/Gems/2.6.0/gems/code2pdf-0.4.3/bin/code2pdf:39:in `new'
6: from /Library/Ruby/Gems/2.6.0/gems/code2pdf-0.4.3/lib/code2pdf/convert_to_pdf.rb:23:in `initialize'
5: from /Library/Ruby/Gems/2.6.0/gems/code2pdf-0.4.3/lib/code2pdf/convert_to_pdf.rb:30:in `save'
4: from /Library/Ruby/Gems/2.6.0/gems/code2pdf-0.4.3/lib/code2pdf/convert_to_pdf.rb:38:in `pdf'
3: from /Library/Ruby/Gems/2.6.0/gems/code2pdf-0.4.3/lib/code2pdf/convert_to_pdf.rb:38:in `each'
2: from /Library/Ruby/Gems/2.6.0/gems/code2pdf-0.4.3/lib/code2pdf/convert_to_pdf.rb:40:in `block in pdf'
1: from /Library/Ruby/Gems/2.6.0/gems/code2pdf-0.4.3/lib/code2pdf/convert_to_pdf.rb:118:in `prepare_line_breaks'
/Library/Ruby/Gems/2.6.0/gems/code2pdf-0.4.3/lib/code2pdf/convert_to_pdf.rb:118:in `gsub': invalid byte sequence in US-ASCII (ArgumentError)
//Separated errors
Traceback (most recent call last):
9: from /usr/local/bin/code2pdf:23:in `<main>'
8: from /usr/local/bin/code2pdf:23:in `load'
7: from /Library/Ruby/Gems/2.6.0/gems/code2pdf-0.4.3/bin/code2pdf:39:in `<top (required)>'
6: from /Library/Ruby/Gems/2.6.0/gems/code2pdf-0.4.3/bin/code2pdf:39:in `new'
5: from /Library/Ruby/Gems/2.6.0/gems/code2pdf-0.4.3/lib/code2pdf/convert_to_pdf.rb:23:in `initialize'
4: from /Library/Ruby/Gems/2.6.0/gems/code2pdf-0.4.3/lib/code2pdf/convert_to_pdf.rb:30:in `save'
3: from /Library/Ruby/Gems/2.6.0/gems/code2pdf-0.4.3/lib/code2pdf/convert_to_pdf.rb:44:in `pdf'
2: from /Library/Ruby/Gems/2.6.0/gems/code2pdf-0.4.3/lib/code2pdf/convert_to_pdf.rb:44:in `new'
1: from /Library/Ruby/Gems/2.6.0/gems/pdfkit-0.8.4.2/lib/pdfkit/pdfkit.rb:36:in `initialize'
/Library/Ruby/Gems/2.6.0/gems/pdfkit-0.8.4.2/lib/pdfkit/pdfkit.rb:94:in `find_options_in_meta': uninitialized constant PDFKit::Tempfile (NameError)
Hello,
first of all, thank you for your work :)
I'd really need something like this to export some repositories and read them offline on my ebook reader.
But it seems I can't get code2pdf to work.
I installed it:
$ sudo apt-get install ruby
$ sudo gem install code2pdf
I cloned one of the repositories I'm interested into (in C#):
$ mkdir "/home/ruben/Downloads/_Temp/ML .NET"
$ cd "/home/ruben/Downloads/_Temp/ML .NET"
$ git clone https://github.com/dotnet/machinelearning.git
While running it against one single sub-folder that contains few classes, I get no error but also no PDF either:
$ code2pdf /home/ruben/Downloads/_Temp/ML\ .NET/machinelearning/src/Microsoft.ML.Analyzer/
Reading file /home/ruben/Downloads/_Temp/ML .NET/machinelearning/src/Microsoft.ML.Analyzer/TypeIsSchemaShapeAnalyzer.cs
Reading file /home/ruben/Downloads/_Temp/ML .NET/machinelearning/src/Microsoft.ML.Analyzer/Microsoft.ML.Analyzer.csproj
Reading file /home/ruben/Downloads/_Temp/ML .NET/machinelearning/src/Microsoft.ML.Analyzer/Properties/AssemblyInfo.cs
What to I do wrong?
Aren't C# .cs files supported?
Thanks!
Convert each code file into a different pdf
Would be useful to be able to ignore file globbing patterns like *.md, my-report-0*.md, etc.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.