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

Extra pages #5

Open
hatton opened this issue May 16, 2022 · 10 comments
Open

Extra pages #5

hatton opened this issue May 16, 2022 · 10 comments

Comments

@hatton
Copy link

hatton commented May 16, 2022

Using

npx docusaurus-prince-pdf -u https://docusaurus.io/docs/cli --selector '.pagination-nav__link--next'

I get a PDF in which every other page is empty:

image

I don't know if it matters, but I'm in the USA and the pages are coming out 8.5 x 11 in, not A4.

Any ideas?

@sparanoid
Copy link
Contributor

@hatton What version are you using?

npx docusaurus-prince-pdf --version

I've just released v1.0.7. Let me see if it works for you.

@joseantgv
Copy link

joseantgv commented May 19, 2022

I have the same problem.

And npx docusaurus-prince-pdf --version returns unkown

And it's only getting the first page. If the content is longer than one page, it only prints the first page and a blank page.

@sparanoid
Copy link
Contributor

sparanoid commented May 19, 2022

@joseantgv Can you try the latest docker version? This can ensure that the environments are the same across different platforms.

docker run --rm -it \
  -v $(pwd)/pdf:/app/pdf \
  openbayes/docusaurus-prince-pdf:master \
  -u https://docusaurus.io/docs/cli

The output:

docusaurus.io-docs-cli.pdf

@sparanoid
Copy link
Contributor

This is what I've got after some investigation according to Prince CLI docs.

A4 size:

docker run --rm -it \
           -v $(pwd)/pdf:/app/pdf \
           openbayes/docusaurus-prince-pdf:master \
           -u https://docusaurus.io/docs/api/misc/create-docusaurus --prince-args="--page-size='210mm 297mm'"

Output: docusaurus.io-docs-api-misc-create-docusaurus-a4.pdf

Letter size:

docker run --rm -it \
           -v $(pwd)/pdf:/app/pdf \
           openbayes/docusaurus-prince-pdf:master \
           -u https://docusaurus.io/docs/api/misc/create-docusaurus --prince-args="--page-size='215.9mm 279.4mm'"

Output: docusaurus.io-docs-api-misc-create-docusaurus-letter.pdf

@hatton Actually the default output is 8.5 x 11 in when no --page-size provided.

@joseantgv
Copy link

A couple of issues:

docker: Error response from daemon: create $(pwd)/pdf: "$(pwd)/pdf" includes invalid characters for a local volume name, only "[a-zA-Z0-9][a-zA-Z0-9_.-]" are allowed. If you intended to pass a host directory, use absolute path.

I'm running on Windows

So I tried:

docker run --rm -it -v d:\temp openbayes/docusaurus-prince-pdf:master -u http://localhost:3000/docs/

And the result:

Error: RequestError: connect ECONNREFUSED 127.0.0.1:3000 at ClientRequest.<anonymous> (file:///app/node_modules/got/dist/source/core/index.js:754:107)

I have "build && serve" my instance and it's accessible with the browser. Maybe it's not working in local environment?

Thanks for your effort 🙌

@sparanoid
Copy link
Contributor

Error: RequestError: connect ECONNREFUSED 127.0.0.1:3000 at ClientRequest.

If you need to generate PDF from localhost using Docker image. You need to replace localhost with host.docker.internal to make sure it can be access from inside the container.

@joseantgv
Copy link

Error: RequestError: connect ECONNREFUSED 127.0.0.1:3000 at ClientRequest.

If you need to generate PDF from localhost using Docker image. You need to replace localhost with host.docker.internal to make sure it can be access from inside the container.

Oh same problem :(

docker run --rm -it -v d:\temp openbayes/docusaurus-prince-pdf:master -u http://host.docker.internal:3000/docs/ Error: RequestError: getaddrinfo ENOTFOUND host.docker.internal at ClientRequest.<anonymous> (file:///app/node_modules/got/dist/source/core/index.js:754:107)

@sparanoid
Copy link
Contributor

@joseantgv This works for me on macOS :(

Try to deploy your site external so that program inside the container can access it.

Or you can try the latest npx version and make sure the --selector option match your site.

@joseantgv
Copy link

joseantgv commented May 20, 2022

@joseantgv This works for me on macOS :(

Try to deploy your site external so that program inside the container can access it.

Or you can try the latest npx version and make sure the --selector option match your site.

Ok, we move forward :) I have uploaded the content to a public site and it's fetched now.

But I get:

Executing command: prince --no-warn-css --style=/app/print.css --input-list=./pdf/XX.txt -o ./pdf/XX.pdf Error: Command failed: prince --no-warn-css --style=/app/print.css --input-list=./pdf/XX.txt -o ./pdf/XX.pdf /usr/local/bin/prince: exec: line 3: /usr/local/lib/prince/bin/prince: not found

If I execute prince in cmd:

>prince
Usage:
  prince [OPTIONS] doc.html              Convert doc.html to doc.pdf
  prince [OPTIONS] doc.html -o out.pdf   Convert doc.html to out.pdf
  prince [OPTIONS] FILES... -o out.pdf   Combine multiple files to out.pdf

Try 'prince --help' for more information.

@yevgenymakarov
Copy link

These blank pages are caused by long code blocks, to fix see #31.

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

No branches or pull requests

4 participants