Problem
I am writing a VS Code extension for VS Code 1.94.2 which shall open a PDF file side-by-side and I got this far using vscode.openWith
:
vscode.commands.executeCommand(
'vscode.openWith',
uri_pointing_to_my_pdf_file,
'default',
vscode.ViewColumn.Beside
)
This opens an editor just as expected but the editor says:
The file is not displayed in the text editor because it is either binary or uses an unsupported text encoding.
If I click the Open Anyway
button, I am offered the two options:
- Text Editor – Active (
Built-In
) - Pdf Preview – Default (
vscode-pdf
)
Choosing vscode-pdf
then lets the side-by-side editor show the PDF. However, I have to manually choose that every time.
Question
How can I change my code so that the editor will show the PDF without the user choosing the vscode-pdf
editor manually every time?
Unsuccessful Attempts
change viewId
Changing the viewId
from 'default'
to 'vscode-pdf'
had no effect. Documentation says:
viewId
– Custom editor view id or ‘default’ to use VS Code’s default editor
'vscode.open'
command
Using the 'vscode.open'
command will open an editor which shows the PDF properly. But the editor opens in a new tab and not side-by-side.
You need to sign in to view this answers
Leave feedback about this