Open hatton opened 2 years ago
@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.
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.
@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:
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.
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 :raised_hands:
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.
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
withhost.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)
@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 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.
These blank pages are caused by long code blocks, to fix see #31.
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:
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?