Skip to content

bug: printPdf() does not use the full file:// path passed in the path parameter #10

@Mr-Rayman

Description

@Mr-Rayman

Bug Report

Capacitor Version

Latest Dependencies:

@capacitor/cli: 8.3.0
@capacitor/core: 8.3.0
@capacitor/android: 8.3.0
@capacitor/ios: 8.3.0

Installed Dependencies:

@capacitor/ios: not installed
@capacitor/cli: 8.2.0
@capacitor/core: 8.2.0
@capacitor/android: 8.2.0

Plugin Version

● Node: v24.14.0

● Installed Dependencies:

● @capgo/cli: 7.88.9

● @capawesome/capacitor-android-edge-to-edge-support: 8.0.6

● @capgo/capacitor-printer: 8.0.11

◇ Latest Dependencies:

● @capgo/cli: 7.88.9

● @capawesome/capacitor-android-edge-to-edge-support: 8.0.6

● @capgo/capacitor-printer: 8.0.11

Platform: Seen in Android (Emulator API 35) and physical device

Description:
printPdf() does not use the full file:// path passed in the path parameter. Instead, it appears to extract only the filename and resolve it against the app's internal /files/ directory, ignoring the actual directory in the path.

For example, when the file is stored in the cache directory, the plugin still looks in /files/.

Steps to reproduce:
Pass a URI like this to Printer.printPdf({ path: 'file:///data/user/0/<appId>/cache/print_temp.pdf' })

Expected: Printer opens /data/user/0/<appId>/cache/print_temp.pdf

Logcat evidence:
The path passed to the plugin is correct:

pluginId: Printer, methodName: printPdf, methodData: {"path":"file:///data/user/0/<appId>/cache/print_temp.pdf"}

But the error shown on device references the wrong directory:

/data/user/0/<appId>/files/print_temp.pdf: open failed: ENOENT (No such file or directory)

Workaround:
Using ../ path traversal to escape the /files/ directory works:

file:///data/user/0/<appId>/files/../cache/print_temp.pdf

Feature Request: Would it be possible for printPdf() to also directly print from a given URL? e.g. printPdf('https://domain/file.pdf") ?

Thanks,
Stefan

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions