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

PDF export ignores include files #593

Closed
ioannisstavrakakis opened this issue Jul 5, 2022 · 24 comments · Fixed by #596
Closed

PDF export ignores include files #593

ioannisstavrakakis opened this issue Jul 5, 2022 · 24 comments · Fixed by #596
Labels
👀 investigating ⬜ windows Issues related to Microsoft's Windows

Comments

@ioannisstavrakakis
Copy link

Description

When exporting a PDF using "AsciiDoc: Export document as PDF" quick command, the resulting PDF does not include the included adoc files. The PDF states the following error message:

Unresolved directive in - include::test.adoc[tag=guide]

System Information

VSCode: 1.68.1
OS: Windows_NT x64 10.0.19044
AsciiDoc v3.0.0.

To Reproduce

Steps to reproduce the issue:

  1. Open the command palette - ctrl+shift+p or F1 (Mac: cmd+shift+p)
  2. Select AsciiDoc: Export document as PDF
  3. Choose the folder and filename for the generated PDF

Additional Context

Running the asciidoctor-pdf bash command renders the PDF as expected.

@ggrossetie
Copy link
Member

Are you using Asciidoctor PDF or wkhtmltopdf? Could you please share the workspace structure (i.e., where is located test.adoc, where is located the file you are exporting to PDF? etc...)

@ioannisstavrakakis
Copy link
Author

I am using the asciidoctor-pdf engin, as checked in the extensions settings.
Both adoc files are under the same folder.

@ggrossetie
Copy link
Member

Both adoc files are under the same folder.

And both AsciiDoc files are at the root of the workspace or inside a sub-directory? Do you use a custom asciidoctor-pdf command? Did you install asciidoctor-pdf locally using Bundler when the extension asks you or did you have asciidoctor-pdf already installed?

@ioannisstavrakakis
Copy link
Author

ioannisstavrakakis commented Jul 5, 2022

I tried both moving the files at the root, and in subfolders, but it is the same result.
I use a custom command which I have configured also in the extensions settings, i.e.:

asciidoctor-pdf -r asciidoctor-lists master.adoc -a pdf-theme=styles/theme.yml -a pdf-fontsdir=styles/assets -a source-highlighter=coderay --trace

I had already installed asciidoctor-pdf.

If I run the command in bash, everything works fine.
And the Export PDF function works fine if the adoc does not contain include files.

@ioannisstavrakakis
Copy link
Author

ioannisstavrakakis commented Jul 5, 2022

I created a minimal master adoc and a minimal include adoc, without much content, nor formatting or document attributes, but it still does not work.

test.zip

Have a go and let me know if you managed to produce a PDF like this one using the Export PDF wuick command:
testmaster.pdf

@ggrossetie
Copy link
Member

Thanks for your input, I will try to reproduce. For reference, what is the absolute path to your workspace and to your AsciiDoc file? My guess is that the base directory is wrong and thus Asciidoctor PDF cannot resolve the target test.adoc.

@ioannisstavrakakis
Copy link
Author

Not sure I understand. This is what I have:

image

@ggrossetie
Copy link
Member

I meant the absolute path such as c:\path\to\workspace and c:\path\to\workspace\folder\test.adoc

@ggrossetie
Copy link
Member

I cannot reproduce this issue.
Though, I found a bug in how we detect if a command is available or not.

Could you please share your settings? @ext:asciidoctor.asciidoctor-vscode pdf

@ioannisstavrakakis
Copy link
Author

I tried to move the files to another folder, and I got this:
Unable to get the workspace folder, aborting.

@ggrossetie
Copy link
Member

I tried to move the files to another folder, and I got this:
Unable to get the workspace folder, aborting.

That's expected, if your AsciiDoc file is not in a workspace folder we cannot continue. We are using the workspace folder to set the base directory.

@ioannisstavrakakis
Copy link
Author

ioannisstavrakakis commented Jul 5, 2022

image

Same settings for User and Workspace.

@ioannisstavrakakis
Copy link
Author

I meant the absolute path such as c:\path\to\workspace and c:\path\to\workspace\folder\test.adoc

C:\Users\istavrak\product_documentation\testmaster.adoc

@ggrossetie
Copy link
Member

ok

@ggrossetie
Copy link
Member

C:\Users\istavrak\product_documentation\testmaster.adoc

Your path does not contain any special character... but maybe it's a Windows related issue 🤔
Do you notice anything different between what I'm doing and what you are doing?

@ioannisstavrakakis
Copy link
Author

Nothing different I am afraid... and again, it works perfectly for any other adoc that does not have include adocs.

And it should not be a problem of the asciidoctor-pdf because running the command from bash works perfectly.

This is really strange.. it is definitely a Windows thing.

I also selected and unselected the "asciidoc.useWorkspaceRootAsBaseDirectory" setting, but all the same.

@ioannisstavrakakis
Copy link
Author

Shouldn't the Export to PDF work also in the web VSC? There is not that option:

image

@ioannisstavrakakis
Copy link
Author

I managed to solve this by using the absolute path to the file:

include::C:\Users\istavrak\product_documentation\testinclude.adoc[]

It is not ideal, and I am not sure if this will cause any problems later when we will develop our Antora-based portal, but at least it works this way.

@ggrossetie
Copy link
Member

Shouldn't the Export to PDF work also in the web VSC? There is not that option:

The export relies on a binary (asciidoctor-pdf or wkhtmltopdf) and we cannot execute binary in VS Code Web. So it's intented.

I managed to solve this by using the absolute path to the file:
include::C:\Users\istavrak\product_documentation\testinclude.adoc[]
It is not ideal, and I am not sure if this will cause any problems later when we will develop our Antora-based portal, but at least it works this way.

You shouldn't do that.
I might have an idea of why it's not working on Windows.

@ggrossetie ggrossetie added the ⬜ windows Issues related to Microsoft's Windows label Jul 5, 2022
@ggrossetie
Copy link
Member

I can reproduce it on Windows. As expected, the base directory is wrong, we are using:

const baseDirectory = path.join(docUri.root, docUri.dir)

On Windows, docUri.root is equals to c:\\ and docUri.dir is c:\\path\\to\\workspace. In the end, the baseDirectory is c:\\c:\\path\\to\\workspace.

Not sure why we do that, I will fix/simplify the code.

@ioannisstavrakakis
Copy link
Author

Thank you very much!

@ioannisstavrakakis
Copy link
Author

Yes, it works! Many thanks!

BTW, nice touch to have this prompt:
generating_pdf

Much appreciated!

@ggrossetie
Copy link
Member

I'm glad you've noticed this small detail 😄

@ioannisstavrakakis
Copy link
Author

Are you kidding me? I live for such details 😅😅😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
👀 investigating ⬜ windows Issues related to Microsoft's Windows
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants