jsonresume / resume-cli

CLI tool to easily setup a new resume 📑
https://jsonresume.org
MIT License
4.55k stars 384 forks source link

PDF output currently broken #94

Closed pcolby closed 3 years ago

pcolby commented 9 years ago

Currently, for me, all PDF outputs contain just this text:

<!DOCTYPE html>
    <html>
    <head>
      <meta name="viewport" content="width=device-width, initial-scale=1">
      <style type="text/css">
        html, body, iframe { margin: 0; padding: 0; height: 100%; }
        iframe { display: block; width: 100%; border: none; }
      </style>
    <title>Application Error</title>
    </head>
    <body>
      <iframe src="//s3.amazonaws.com/heroku_pages/error.html">
        <p>Application Error</p>
      </iframe>
    </body>
    </html

This is regardless of the theme I use, and for a JSON document that hasn't changed for days, and was working just a couple of hours ago.

I'm guessing whatever online service jsonresume-cli uses in the background for PDF conversion is currently broken, but I'm not sure where else to report it.

Thanks.

pcolby commented 9 years ago

It appears to have resolved itself now.

sebastialonso commented 9 years ago

I'm having an issue with pdf export

The command resume export resume.pdf seems to work correctly, and even 'creates' a pdf file. When I try to open it, I get the following Documen Viewer error

Unable to open document

File type HTML document (text/html) is not supported

Nothing else on console or anything :/

pdavid0 commented 9 years ago

+1

The text in my broken pdf file : ERROR: No API conversion tokens available

PeterDaveHello commented 9 years ago

cc @thomasdavis

SamJoan commented 9 years ago

I created a PDF file from the command line and I got the following:

xxd file.pdf
0000000: 4552 524f 523a 204e 6f20 4150 4920 636f  ERROR: No API co
0000010: 6e76 6572 7369 6f6e 2074 6f6b 656e 7320  nversion tokens
0000020: 6176 6169 6c61 626c 65                   available

Online, this is the same:

http://registry.jsonresume.org/test.pdf

laibulle commented 9 years ago

+1

The text in my broken pdf file : ERROR: No API conversion tokens available

thomasdavis commented 9 years ago

Sorry everyone, I actually ran into some financial problems, getting this sorted asap! We should probably migrate off the service also...

mchelen commented 9 years ago

@thomasdavis No worries, thanks for responding. Can we use the Gratipay for this? If we know what target needs to be reached, we could also do a fund raising drive. I'd love to find another alternative, but I'm not sure what better options exist.

sebastialonso commented 9 years ago

@thomasdavis what about Heroku? Simple to deploy to.

@thomasdavis https://github.com/thomasdavis No worries, thanks for responding. Can we use the Gratipay for this? If we know what target needs to be reached, we could do a fund raising drive. I'd love to find another alternative, but I'm not sure what better options exist.

— Reply to this email directly or view it on GitHub https://github.com/jsonresume/resume-cli/issues/94#issuecomment-90251772.

mchelen commented 9 years ago

@sebastialonso What actual code would run on Heroku? We have tried a few other libraries & apps, but none have good enough output quality. If you know of any other programs to suggest or want to try tweaking settings on some of the ones we have tried that would be great, here is the issue about PDF conversion code:: https://github.com/jsonresume/resume-cli/issues/72

SamJoan commented 9 years ago

For those looking for a workaround, open your CV in google chrome and press Ctrl + P for "print", and then set "Save as PDF" as the destination. Works great!

elijahchancey commented 9 years ago

Would it make sense to do PDF conversion locally instead of using a paid service?

mchelen commented 9 years ago

@elijahchancey See https://github.com/jsonresume/resume-cli/issues/72

rpbaltazar commented 9 years ago

what about asking the user to register in pdfcrown and then build a config file with his token? This way, each person would have 100 credits for free.

howardroark commented 9 years ago

It would not be too crazy to build a service which runs a basic web framework + phantomJS on the cloud (certainly Heroku is an option). Each time a user wishes to generate a PDF you pass the HTML as a POST request to an endpoint. The service would then serve that HTML up for PhantomJS to take a snapshot of (maybe store the markup in redis or something). From there pass that generated PDF back to the user and remove it from the file system. Really your biggest overhead is the read/write/delete from the last part. Should be able to run well on a machine with 1gb of RAM with at least a few concurrent connections.

http://www.cloudatcost.com/ is always a good option for this type of thing. They have 50% off sales pretty often.

mchelen commented 9 years ago

@howardroark Try phantomJS and see what you think of the PDF output quality. The issue is not finding a host, but which library/program to use for PDF generation.

thomasdavis commented 9 years ago

Ok guys was finally able to get the pdf service paid up to scratch, thanks for the patience. We also have a budget to put a bounty on issues now, so maybe a proper pdf conversion module?

mchelen commented 9 years ago

@thomasdavis Thanks for addressing the PDFCrowd issue! It looks like there is still some problem, maybe the Heroku apps needs to be restarted? Here is the output from resume export foo.pdf:

<!DOCTYPE html>
    <html>
    <head>
      <meta name="viewport" content="width=device-width, initial-scale=1">
      <style type="text/css">
        html, body, iframe { margin: 0; padding: 0; height: 100%; }
        iframe { display: block; width: 100%; border: none; }
      </style>
    <title>Application Error</title>
    </head>
    <body>
      <iframe src="//s3.amazonaws.com/heroku_pages/error.html">
        <p>Application Error</p>
      </iframe>
    </body>
    </html>
thomasdavis commented 9 years ago

Hrmm I've just restarted the server. Maybe give it another shot.

thomasdavis commented 9 years ago

Ahh I'm getting the error too now.

program247365 commented 9 years ago

In the meantime, you can mess with this script + node module I found that may help you.

  1. First output to your resume.json to HTML with resume-cli
  2. npm install html-pdf
  3. Then create a file called html2pdf.js, and have this as it's contents (see below)
  4. Use it like this: node html2pdf.js <path-and-filename-of-prev-generated-html-output-in-step-one> myresume.pdf
  5. Fiddle with the options object to get the outputted PDF to look nice. YMMV.
var fs = require('fs');
var pdf = require('html-pdf');

var args = process.argv;
var htmlfile = args[2];
var pdffile = args[3];

if(htmlfile === undefined || pdffile === undefined) {
    console.error('You must supply a html filename, and then a PDF filename.');
    process.exit();
}

var html = fs.readFileSync(htmlfile, 'utf8')
var options = { filename: pdffile, format: 'Letter' };

pdf.create(html, options).toFile(function(err, res) {
  if (err) return console.log(err);
  console.log(res); // { filename: '/tmp/html-pdf-8ymPV.pdf' }
});
mchelen commented 9 years ago

Can someone test https://github.com/jsonresume/registry-server and see if it has any errors running locally? Or try deploying it to Heroku and see if that shows any problems.

mistakenot commented 9 years ago

What is stopping client side generation being possible?

mchelen commented 9 years ago

Please see https://github.com/jsonresume/resume-cli/issues/72 for discussion of client side PDF generation.

mistakenot commented 9 years ago

Gotcha. PDF sucks.

JamesPaden commented 9 years ago

@thomasdavis could I offer up the services of https://docraptor.com instead? I think we could support this through some sort of community project. Our backend uses PrinceXML which was build from the ground up for PDF generation. Generally speaking, better results/more power than PhantomJS/wkhtmltopdf.

ianchanning commented 8 years ago

I'm getting this bug occuring again.

ianchanning commented 8 years ago

I found that the best work around was by @TimDaub suggesting using Chrome to view the print view of the HTML and save it to PDF.

dbkaplun commented 8 years ago

There's also NightmareJS that I've been using with great success for headless testing that seems to also do PDF rendering.

mpgeek commented 8 years ago

Getting the "No API tokens" error with native PDF conversion. The browser print option with a more-compact theme works good enough today for a one-page resume (i still like the fleshed out HTML version for display). If we moving away from native conversion as in #72 or #94, why not drop it all together and provide documentation?

thomasdavis commented 8 years ago

Ahh I will purchase some more tokens now in the mean time.

On Thu, Nov 19, 2015 at 1:48 PM, Eric Paul notifications@github.com wrote:

Getting the "No API tokens" error with native PDF conversion. The browser print option with a more-compact theme works good enough today for a one-page resume (i still like the fleshed out HTML version for display). If we moving away from native conversion as in #72 https://github.com/jsonresume/resume-cli/issues/72 or #94 https://github.com/jsonresume/resume-cli/issues/94, why not drop it all together and provide documentation?

— Reply to this email directly or view it on GitHub https://github.com/jsonresume/resume-cli/issues/94#issuecomment-157943135 .

Thomas Davis http://thomasdav.is

VP of Tech - Earbits - http://earbits.com Co-founder - Cdnjs - http://cdnjs.com Founder - Backbone Tutorials - http://backbonetutorials.com

PeterDaveHello commented 8 years ago

@thomasdavis what about taking @JamesPaden's suggestion?

cmdcolin commented 8 years ago

Getting "ERROR: No API conversion tokens available" for the past week or so (only just realized that by opening up the PDF to inspect contents). Would agree that a local conversion would be ideal

howardroark commented 8 years ago

If anyone is curious I have made a little build process with "npm scripts". It first builds as html file with resume-cli, then a pdf with wkhtmltopdf, and finally a png with imagemagick (for the README.md file). I'm on OSX and the install of imagemagick and wkhtmltopdf is very simple... https://github.com/howardroark/resume

I really like wkhtmltopdf because it preserves links and offers a nice looking PDF assuming the template has a good responsive layout.

In theory a binary for each of those two tools could be downloaded to match the architecture and used as an npm module.

Ezibenroc commented 8 years ago

@howardroark I tried to run wkhtmltopdf, but I got a bad looking pdf: resume.pdf

Any hint on how to produce a correct output? Note that I got similar bad-looking output if I open the html file in a browser and then print it. The html itself is rendered well in firefox and chrome.

howardroark commented 8 years ago

@Ezibenroc Does the index.html file look as expected? I was using a fork of the "flat" theme to omit website. Try removing the -fork part from this line ... https://github.com/howardroark/resume/blob/master/package.json#L6

That may help.

IwishIcanFLighT commented 8 years ago

Any update?

thomasdavis commented 8 years ago

Sorry guys, this one slipped through the cracks for me. It is an unpaid bill on pdfcrowd which I can't afford at the moment.

I originally set it up because it did a way better job at PDF conversion. But at this point I think I need to embed a conversion tool in the CLI. The problem being, it isn't so easy as others have pointed out.

It seems like we should add @howardroark solution to the cli tool, think you could link us some examples of output?

howardroark commented 8 years ago

I think the trick would be finding wkhtmltopdf binaries for each major system, hosting them, and then building an npm module that downloaded the correct one and sort of "wrapped" it.

thomasdavis commented 8 years ago

So if it runs on Linux well enough I can move PDF conversion to the Theme server until we have cross platform local PDF export..

IwishIcanFLighT commented 8 years ago

Or maybe give another free API a try? http://www.html2pdfrocket.com/ for example.

howardroark commented 8 years ago

I have updated my template to include binaries for OSX. I may try my hand at a module that offers the wkhtmltopdf binary to the node bin path. That way I can leave out the binaries and just count on npm install to do everything.

dbkaplun commented 8 years ago

Have you considered html-pdf? It's quite good. Here I am using it to generate http://dbkaplun.com/resume.pdf from http://dbkaplun.com/resume.json automatically.

howardroark commented 8 years ago

That is pretty slick! Certainly a better install process. Though for me I really enjoy how wkhtmltopdf preserves links. If phantomjs did that it would be awesome!

amingilani commented 8 years ago

Aw man, I was creating my first json-resume for my girlfriend, and now I can't export to pdf and show her

igorkulman commented 8 years ago

@thomasdavis you mention pdfcrowd so what about adding the ability to provide a custom API token using the cli? Looking at pdfcrowd, they offer a trial with 100 tokens so each of us can just register and get those 100 conversions for ourselves.

Sigurthorb commented 6 years ago

Is there no hope the pdf export? I really love this project and the simplicity of it but the external transformation of html to pdf is just doesn't look good enough

apexdodge commented 6 years ago

I run https://www.api2pdf.com and I would be happy to give you guys free credit so that you can re-enable your pdf export feature. Just let me know.

gdabli commented 6 years ago

I installed cli. getting error while invoking clie

/usr/local/lib/node_modules/resume-cli/lib/export-resume/index.js:41 console.error(JSON Resume does not support the ${format} format); ^ SyntaxError: Unexpected token ILLEGAL at exports.runInThisContext (vm.js:73:16) at Module._compile (module.js:443:25) at Object.Module._extensions..js (module.js:478:10) at Module.load (module.js:355:32) at Function.Module._load (module.js:310:12) at Module.require (module.js:365:17) at require (module.js:384:17) at Object. (/usr/local/lib/node_modules/resume-cli/lib/index.js:6:19) at Module._compile (module.js:460:26) at Object.Module._extensions..js (module.js:478:10) at Module.load (module.js:355:32) at Function.Module._load (module.js:310:12) at Module.require (module.js:365:17) at require (module.js:384:17) at Object. (/usr/local/lib/node_modules/resume-cli/index.js:5:11) at Module._compile (module.js:460:26)