Grayda / gitlab-doc-builder

A GitLab-CI job to build PDF and DOCX files from markdown
45 stars 10 forks source link

Empty pdf file #4

Closed Europium-152 closed 4 months ago

Europium-152 commented 3 years ago

Hi there, this repository has been quiet for a while but still thought I'd ask. I tried using this and it outputs the docx file just right but the pdf comes out empty. I don't really know all that much about this but this is the job transcript. The problem seems to be with the undefined method to_pdf is there any quick fix? Thanks a lot :)

Running with gitlab-runner 13.9.0-rc2 (69c049fd)
  on docker-auto-scale 72989761
  feature flags: FF_GITLAB_REGISTRY_HELPER_IMAGE:true
Preparing the "docker+machine" executor
00:35
Using Docker executor with image ruby:2.5 ...
Pulling docker image ruby:2.5 ...
Using docker image sha256:67b2b6cb06d9e429852b3db87ca3427648b229685c52cc9474f4c7b2a832ec5e for ruby:2.5 with digest ruby@sha256:d99439def9ef2349c327ae76665be0d18376f7d9cc4d3a8ddfeb8f970271fdae ...
Preparing environment
00:03
Running on runner-72989761-project-23821104-concurrent-0 via runner-72989761-srm-1615307313-fbea9bf9...
Getting source from Git repository
00:01
$ eval "$CI_PRE_CLONE_SCRIPT"
Fetching changes with git depth set to 50...
Initialized empty Git repository in /builds/ipfn-reflectometry/rfl-operation-guide/.git/
Created fresh repository.
Checking out a072868d as master...
Skipping Git submodules setup
Executing "step_script" stage of the job script
00:12
Using docker image sha256:67b2b6cb06d9e429852b3db87ca3427648b229685c52cc9474f4c7b2a832ec5e for ruby:2.5 with digest ruby@sha256:d99439def9ef2349c327ae76665be0d18376f7d9cc4d3a8ddfeb8f970271fdae ...
$ apt-get update -y
Get:1 http://security.debian.org/debian-security buster/updates InRelease [65.4 kB]
Get:2 http://deb.debian.org/debian buster InRelease [122 kB]
Get:3 http://deb.debian.org/debian buster-updates InRelease [51.9 kB]
Get:4 http://security.debian.org/debian-security buster/updates/main amd64 Packages [268 kB]
Get:5 http://deb.debian.org/debian buster/main amd64 Packages [7907 kB]
Get:6 http://deb.debian.org/debian buster-updates/main amd64 Packages [9504 B]
Fetched 8423 kB in 2s (4544 kB/s)
Reading package lists...
$ apt-get install -y pandoc
Reading package lists...
Building dependency tree...
Reading state information...
The following additional packages will be installed:
  liblua5.1-0 pandoc-data
Suggested packages:
  texlive-latex-recommended texlive-xetex texlive-luatex pandoc-citeproc
  texlive-latex-extra context wkhtmltopdf librsvg2-bin groff ghc nodejs php
  ruby r-base-core libjs-mathjax node-katex
The following NEW packages will be installed:
  liblua5.1-0 pandoc pandoc-data
0 upgraded, 3 newly installed, 0 to remove and 8 not upgraded.
Need to get 15.2 MB of archives.
After this operation, 117 MB of additional disk space will be used.
Get:1 http://deb.debian.org/debian buster/main amd64 liblua5.1-0 amd64 5.1.5-8.1+b2 [111 kB]
Get:2 http://deb.debian.org/debian buster/main amd64 pandoc-data all 2.2.1-3 [329 kB]
Get:3 http://deb.debian.org/debian buster/main amd64 pandoc amd64 2.2.1-3+b2 [14.7 MB]
debconf: delaying package configuration, since apt-utils is not installed
Fetched 15.2 MB in 0s (40.2 MB/s)
Selecting previously unselected package liblua5.1-0:amd64.
(Reading database ... 23985 files and directories currently installed.)
Preparing to unpack .../liblua5.1-0_5.1.5-8.1+b2_amd64.deb ...
Unpacking liblua5.1-0:amd64 (5.1.5-8.1+b2) ...
Selecting previously unselected package pandoc-data.
Preparing to unpack .../pandoc-data_2.2.1-3_all.deb ...
Unpacking pandoc-data (2.2.1-3) ...
Selecting previously unselected package pandoc.
Preparing to unpack .../pandoc_2.2.1-3+b2_amd64.deb ...
Unpacking pandoc (2.2.1-3+b2) ...
Setting up liblua5.1-0:amd64 (5.1.5-8.1+b2) ...
Setting up pandoc-data (2.2.1-3) ...
Setting up pandoc (2.2.1-3+b2) ...
Processing triggers for libc-bin (2.28-10) ...
$ gem install kramdown
Successfully installed rexml-3.2.4
Successfully installed kramdown-2.3.0
2 gems installed
$ gem install prawn
Successfully installed pdf-core-0.9.0
Successfully installed ttfunk-1.7.0
Successfully installed prawn-2.4.0
3 gems installed
$ gem install prawn-table
Successfully installed prawn-table-0.2.2
1 gem installed
$ find . -name '*.md' -exec sh -c 'pandoc $0 -f markdown -t docx -o $0.docx' {} \;
$ find . -name '*.md' -exec sh -c 'kramdown $0 --output pdf > $0.pdf' {} \;
/usr/local/bundle/gems/kramdown-2.3.0/lib/kramdown/document.rb:120:in `method_missing': undefined method `to_pdf' for #<Kramdown::Document:0x000055d1d6f41660> (NoMethodError)
    from /usr/local/bundle/gems/kramdown-2.3.0/bin/kramdown:126:in `block in <top (required)>'
    from /usr/local/bundle/gems/kramdown-2.3.0/bin/kramdown:126:in `each'
    from /usr/local/bundle/gems/kramdown-2.3.0/bin/kramdown:126:in `<top (required)>'
    from /usr/local/bundle/bin/kramdown:23:in `load'
    from /usr/local/bundle/bin/kramdown:23:in `<main>'
/usr/local/bundle/gems/kramdown-2.3.0/lib/kramdown/document.rb:120:in `method_missing': undefined method `to_pdf' for #<Kramdown::Document:0x000055931aa77ad0> (NoMethodError)
    from /usr/local/bundle/gems/kramdown-2.3.0/bin/kramdown:126:in `block in <top (required)>'
    from /usr/local/bundle/gems/kramdown-2.3.0/bin/kramdown:126:in `each'
    from /usr/local/bundle/gems/kramdown-2.3.0/bin/kramdown:126:in `<top (required)>'
    from /usr/local/bundle/bin/kramdown:23:in `load'
    from /usr/local/bundle/bin/kramdown:23:in `<main>'
Uploading artifacts for successful job
00:02
Uploading artifacts...
untracked: found 4 files                           
Uploading artifacts as "archive" to coordinator... ok  id=1084195161 responseStatus=201 Created token=YKYfsBF6
Cleaning up file based variables
00:01
Job succeeded
Grayda commented 3 years ago

I didn't mean to close this issue, but rather to add a comment. Can you try this again? Looks like newer versions of kramdown needed the kramdown-converter-pdf gem installed, which I've added.

I no longer use this, so I can't easily test it, but I'm hoping that this will work. Can you try it and let me know?

Europium-152 commented 3 years ago

Hi there, I think that solved my problem, but I've got a new one xD It looks like it's having some problems with the content of the file itself. I tried creating another markdown file with the text "abcdefghij" and it outputs the pdf just fine. It looks like I need an external font to make it work. I can download a ttf file from google, but I don't know how to adapt the .yml file accordingly. Any ideas? Thanks a lot :)

Running with gitlab-runner 13.9.0-rc2 (69c049fd)
  on docker-auto-scale 72989761
  feature flags: FF_GITLAB_REGISTRY_HELPER_IMAGE:true
Preparing the "docker+machine" executor
00:34
Using Docker executor with image ruby:2.5 ...
Pulling docker image ruby:2.5 ...
Using docker image sha256:67b2b6cb06d9e429852b3db87ca3427648b229685c52cc9474f4c7b2a832ec5e for ruby:2.5 with digest ruby@sha256:d99439def9ef2349c327ae76665be0d18376f7d9cc4d3a8ddfeb8f970271fdae ...
Preparing environment
00:02
Running on runner-72989761-project-23821104-concurrent-0 via runner-72989761-srm-1615374208-c72a585c...
Getting source from Git repository
00:02
$ eval "$CI_PRE_CLONE_SCRIPT"
Fetching changes with git depth set to 50...
Initialized empty Git repository in /builds/ipfn-reflectometry/rfl-operation-guide/.git/
Created fresh repository.
Checking out 59f3eebd as master...
Skipping Git submodules setup
Executing "step_script" stage of the job script
00:13
Using docker image sha256:67b2b6cb06d9e429852b3db87ca3427648b229685c52cc9474f4c7b2a832ec5e for ruby:2.5 with digest ruby@sha256:d99439def9ef2349c327ae76665be0d18376f7d9cc4d3a8ddfeb8f970271fdae ...
$ apt-get update -y
Get:1 http://security.debian.org/debian-security buster/updates InRelease [65.4 kB]
Get:2 http://deb.debian.org/debian buster InRelease [122 kB]
Get:3 http://deb.debian.org/debian buster-updates InRelease [51.9 kB]
Get:4 http://security.debian.org/debian-security buster/updates/main amd64 Packages [268 kB]
Get:5 http://deb.debian.org/debian buster/main amd64 Packages [7907 kB]
Get:6 http://deb.debian.org/debian buster-updates/main amd64 Packages [9504 B]
Fetched 8423 kB in 2s (4361 kB/s)
Reading package lists...
$ apt-get install -y pandoc
Reading package lists...
Building dependency tree...
Reading state information...
The following additional packages will be installed:
  liblua5.1-0 pandoc-data
Suggested packages:
  texlive-latex-recommended texlive-xetex texlive-luatex pandoc-citeproc
  texlive-latex-extra context wkhtmltopdf librsvg2-bin groff ghc nodejs php
  ruby r-base-core libjs-mathjax node-katex
The following NEW packages will be installed:
  liblua5.1-0 pandoc pandoc-data
0 upgraded, 3 newly installed, 0 to remove and 8 not upgraded.
Need to get 15.2 MB of archives.
After this operation, 117 MB of additional disk space will be used.
Get:1 http://deb.debian.org/debian buster/main amd64 liblua5.1-0 amd64 5.1.5-8.1+b2 [111 kB]
Get:2 http://deb.debian.org/debian buster/main amd64 pandoc-data all 2.2.1-3 [329 kB]
Get:3 http://deb.debian.org/debian buster/main amd64 pandoc amd64 2.2.1-3+b2 [14.7 MB]
debconf: delaying package configuration, since apt-utils is not installed
Fetched 15.2 MB in 0s (31.1 MB/s)
Selecting previously unselected package liblua5.1-0:amd64.
(Reading database ... 23985 files and directories currently installed.)
Preparing to unpack .../liblua5.1-0_5.1.5-8.1+b2_amd64.deb ...
Unpacking liblua5.1-0:amd64 (5.1.5-8.1+b2) ...
Selecting previously unselected package pandoc-data.
Preparing to unpack .../pandoc-data_2.2.1-3_all.deb ...
Unpacking pandoc-data (2.2.1-3) ...
Selecting previously unselected package pandoc.
Preparing to unpack .../pandoc_2.2.1-3+b2_amd64.deb ...
Unpacking pandoc (2.2.1-3+b2) ...
Setting up liblua5.1-0:amd64 (5.1.5-8.1+b2) ...
Setting up pandoc-data (2.2.1-3) ...
Setting up pandoc (2.2.1-3+b2) ...
Processing triggers for libc-bin (2.28-10) ...
$ gem install kramdown
Successfully installed rexml-3.2.4
Successfully installed kramdown-2.3.0
2 gems installed
$ gem install kramdown-converter-pdf
Successfully installed pdf-core-0.9.0
Successfully installed ttfunk-1.7.0
Successfully installed prawn-2.4.0
Successfully installed prawn-table-0.2.2
Successfully installed kramdown-converter-pdf-1.0.5
5 gems installed
$ gem install prawn
Successfully installed prawn-2.4.0
1 gem installed
$ gem install prawn-table
Successfully installed prawn-table-0.2.2
1 gem installed
$ find . -name '*.md' -exec sh -c 'pandoc $0 -f markdown -t docx -o $0.docx' {} \;
$ find . -name '*.md' -exec sh -c 'kramdown $0 --output pdf > $0.pdf' {} \;
PDF's built-in fonts have very limited support for internationalized text.
If you need full UTF-8 support, consider using an external font instead.
To disable this warning, add the following line to your code:
Prawn::Fonts::AFM.hide_m17n_warning = true
/usr/local/bundle/gems/prawn-2.4.0/lib/prawn/fonts/afm.rb:116:in `rescue in normalize_encoding': Your document includes text that's not compatible with the Windows-1252 character set. (Prawn::Errors::IncompatibleStringEncoding)
If you need full UTF-8 support, use external fonts instead of PDF's built-in fonts.
    from /usr/local/bundle/gems/prawn-2.4.0/lib/prawn/fonts/afm.rb:111:in `normalize_encoding'
    from /usr/local/bundle/gems/prawn-2.4.0/lib/prawn/text/formatted/box.rb:396:in `block (2 levels) in normalize_encoding'
    from /usr/local/bundle/gems/prawn-2.4.0/lib/prawn/font.rb:60:in `block in font'
    from /usr/local/bundle/gems/prawn-2.4.0/lib/prawn/font.rb:214:in `save_font'
    from /usr/local/bundle/gems/prawn-2.4.0/lib/prawn/font.rb:58:in `font'
    from /usr/local/bundle/gems/prawn-2.4.0/lib/prawn/text/formatted/box.rb:395:in `block in normalize_encoding'
    from /usr/local/bundle/gems/prawn-2.4.0/lib/prawn/text/formatted/box.rb:393:in `each'
    from /usr/local/bundle/gems/prawn-2.4.0/lib/prawn/text/formatted/box.rb:393:in `normalize_encoding'
    from /usr/local/bundle/gems/prawn-2.4.0/lib/prawn/text/formatted/box.rb:371:in `normalized_text'
    from /usr/local/bundle/gems/prawn-2.4.0/lib/prawn/text/formatted/box.rb:219:in `block (3 levels) in render'
    from /usr/local/bundle/gems/pdf-core-0.9.0/lib/pdf/core/text.rb:202:in `text_rendering_mode'
    from /usr/local/bundle/gems/prawn-2.4.0/lib/prawn/text/formatted/box.rb:216:in `block (2 levels) in render'
    from /usr/local/bundle/gems/pdf-core-0.9.0/lib/pdf/core/text.rb:227:in `character_spacing'
    from /usr/local/bundle/gems/prawn-2.4.0/lib/prawn/text/formatted/box.rb:215:in `block in render'
    from /usr/local/bundle/gems/prawn-2.4.0/lib/prawn/font.rb:214:in `save_font'
    from /usr/local/bundle/gems/prawn-2.4.0/lib/prawn/text/formatted/box.rb:214:in `render'
    from /usr/local/bundle/gems/prawn-2.4.0/lib/prawn/text.rb:380:in `fill_formatted_text_box'
    from /usr/local/bundle/gems/prawn-2.4.0/lib/prawn/text.rb:216:in `formatted_text'
    from /usr/local/bundle/gems/kramdown-converter-pdf-1.0.5/lib/kramdown/converter/pdf.rb:593:in `block in render_padded_and_formatted_text'
    from /usr/local/bundle/gems/kramdown-converter-pdf-1.0.5/lib/kramdown/converter/pdf.rb:586:in `with_block_padding'
    from /usr/local/bundle/gems/kramdown-converter-pdf-1.0.5/lib/kramdown/converter/pdf.rb:593:in `render_padded_and_formatted_text'
    from /usr/local/bundle/gems/kramdown-converter-pdf-1.0.5/lib/kramdown/converter/pdf.rb:138:in `render_p'
    from /usr/local/bundle/gems/kramdown-converter-pdf-1.0.5/lib/kramdown/converter/pdf.rb:81:in `convert'
    from /usr/local/bundle/gems/kramdown-converter-pdf-1.0.5/lib/kramdown/converter/pdf.rb:95:in `block in inner'
    from /usr/local/bundle/gems/kramdown-converter-pdf-1.0.5/lib/kramdown/converter/pdf.rb:92:in `map'
    from /usr/local/bundle/gems/kramdown-converter-pdf-1.0.5/lib/kramdown/converter/pdf.rb:92:in `inner'
    from /usr/local/bundle/gems/kramdown-converter-pdf-1.0.5/lib/kramdown/converter/pdf.rb:231:in `render_li'
    from /usr/local/bundle/gems/kramdown-converter-pdf-1.0.5/lib/kramdown/converter/pdf.rb:81:in `convert'
    from /usr/local/bundle/gems/kramdown-converter-pdf-1.0.5/lib/kramdown/converter/pdf.rb:208:in `block (3 levels) in render_ul'
    from /usr/local/bundle/gems/prawn-2.4.0/lib/prawn/document/bounding_box.rb:297:in `indent'
    from /usr/local/bundle/gems/prawn-2.4.0/lib/prawn/document.rb:528:in `indent'
    from /usr/local/bundle/gems/kramdown-converter-pdf-1.0.5/lib/kramdown/converter/pdf.rb:208:in `block (2 levels) in render_ul'
    from /usr/local/bundle/gems/kramdown-converter-pdf-1.0.5/lib/kramdown/converter/pdf.rb:206:in `each'
    from /usr/local/bundle/gems/kramdown-converter-pdf-1.0.5/lib/kramdown/converter/pdf.rb:206:in `block in render_ul'
    from /usr/local/bundle/gems/kramdown-converter-pdf-1.0.5/lib/kramdown/converter/pdf.rb:586:in `with_block_padding'
    from /usr/local/bundle/gems/kramdown-converter-pdf-1.0.5/lib/kramdown/converter/pdf.rb:205:in `render_ul'
    from /usr/local/bundle/gems/kramdown-converter-pdf-1.0.5/lib/kramdown/converter/pdf.rb:81:in `convert'
    from /usr/local/bundle/gems/kramdown-converter-pdf-1.0.5/lib/kramdown/converter/pdf.rb:95:in `block in inner'
    from /usr/local/bundle/gems/kramdown-converter-pdf-1.0.5/lib/kramdown/converter/pdf.rb:92:in `map'
    from /usr/local/bundle/gems/kramdown-converter-pdf-1.0.5/lib/kramdown/converter/pdf.rb:92:in `inner'
    from /usr/local/bundle/gems/kramdown-converter-pdf-1.0.5/lib/kramdown/converter/pdf.rb:231:in `render_li'
    from /usr/local/bundle/gems/kramdown-converter-pdf-1.0.5/lib/kramdown/converter/pdf.rb:81:in `convert'
    from /usr/local/bundle/gems/kramdown-converter-pdf-1.0.5/lib/kramdown/converter/pdf.rb:208:in `block (3 levels) in render_ul'
    from /usr/local/bundle/gems/prawn-2.4.0/lib/prawn/document/bounding_box.rb:297:in `indent'
    from /usr/local/bundle/gems/prawn-2.4.0/lib/prawn/document.rb:528:in `indent'
    from /usr/local/bundle/gems/kramdown-converter-pdf-1.0.5/lib/kramdown/converter/pdf.rb:208:in `block (2 levels) in render_ul'
    from /usr/local/bundle/gems/kramdown-converter-pdf-1.0.5/lib/kramdown/converter/pdf.rb:206:in `each'
    from /usr/local/bundle/gems/kramdown-converter-pdf-1.0.5/lib/kramdown/converter/pdf.rb:206:in `block in render_ul'
    from /usr/local/bundle/gems/kramdown-converter-pdf-1.0.5/lib/kramdown/converter/pdf.rb:586:in `with_block_padding'
    from /usr/local/bundle/gems/kramdown-converter-pdf-1.0.5/lib/kramdown/converter/pdf.rb:205:in `render_ul'
    from /usr/local/bundle/gems/kramdown-converter-pdf-1.0.5/lib/kramdown/converter/pdf.rb:81:in `convert'
    from /usr/local/bundle/gems/kramdown-converter-pdf-1.0.5/lib/kramdown/converter/pdf.rb:95:in `block in inner'
    from /usr/local/bundle/gems/kramdown-converter-pdf-1.0.5/lib/kramdown/converter/pdf.rb:92:in `map'
    from /usr/local/bundle/gems/kramdown-converter-pdf-1.0.5/lib/kramdown/converter/pdf.rb:92:in `inner'
    from /usr/local/bundle/gems/kramdown-converter-pdf-1.0.5/lib/kramdown/converter/pdf.rb:231:in `render_li'
    from /usr/local/bundle/gems/kramdown-converter-pdf-1.0.5/lib/kramdown/converter/pdf.rb:81:in `convert'
    from /usr/local/bundle/gems/kramdown-converter-pdf-1.0.5/lib/kramdown/converter/pdf.rb:208:in `block (3 levels) in render_ul'
    from /usr/local/bundle/gems/prawn-2.4.0/lib/prawn/document/bounding_box.rb:297:in `indent'
    from /usr/local/bundle/gems/prawn-2.4.0/lib/prawn/document.rb:528:in `indent'
    from /usr/local/bundle/gems/kramdown-converter-pdf-1.0.5/lib/kramdown/converter/pdf.rb:208:in `block (2 levels) in render_ul'
    from /usr/local/bundle/gems/kramdown-converter-pdf-1.0.5/lib/kramdown/converter/pdf.rb:206:in `each'
    from /usr/local/bundle/gems/kramdown-converter-pdf-1.0.5/lib/kramdown/converter/pdf.rb:206:in `block in render_ul'
    from /usr/local/bundle/gems/kramdown-converter-pdf-1.0.5/lib/kramdown/converter/pdf.rb:586:in `with_block_padding'
    from /usr/local/bundle/gems/kramdown-converter-pdf-1.0.5/lib/kramdown/converter/pdf.rb:205:in `render_ul'
    from /usr/local/bundle/gems/kramdown-converter-pdf-1.0.5/lib/kramdown/converter/pdf.rb:81:in `convert'
    from /usr/local/bundle/gems/kramdown-converter-pdf-1.0.5/lib/kramdown/converter/pdf.rb:95:in `block in inner'
    from /usr/local/bundle/gems/kramdown-converter-pdf-1.0.5/lib/kramdown/converter/pdf.rb:92:in `map'
    from /usr/local/bundle/gems/kramdown-converter-pdf-1.0.5/lib/kramdown/converter/pdf.rb:92:in `inner'
    from /usr/local/bundle/gems/kramdown-converter-pdf-1.0.5/lib/kramdown/converter/pdf.rb:111:in `render_root'
    from /usr/local/bundle/gems/kramdown-converter-pdf-1.0.5/lib/kramdown/converter/pdf.rb:81:in `convert'
    from /usr/local/bundle/gems/kramdown-2.3.0/lib/kramdown/converter/base.rb:107:in `convert'
    from /usr/local/bundle/gems/kramdown-2.3.0/lib/kramdown/document.rb:116:in `method_missing'
    from /usr/local/bundle/gems/kramdown-2.3.0/bin/kramdown:126:in `block in <top (required)>'
    from /usr/local/bundle/gems/kramdown-2.3.0/bin/kramdown:126:in `each'
    from /usr/local/bundle/gems/kramdown-2.3.0/bin/kramdown:126:in `<top (required)>'
    from /usr/local/bundle/bin/kramdown:23:in `load'
    from /usr/local/bundle/bin/kramdown:23:in `<main>'
Uploading artifacts for successful job
00:02
Uploading artifacts...
untracked: found 4 files                           
Uploading artifacts as "archive" to coordinator... ok  id=1086359146 responseStatus=201 Created token=y4-qaTwr
Cleaning up file based variables
00:00
Job succeeded