Open anki247 opened 6 years ago
@anki247 same with me. i was able to configure webpack to include pdf files and I can get the file using the filesystem. However when setting it to the src nothing happens, online url works tho. Have you got any workarounds?
unfortunately not...
there is this fork here: https://www.nsplugins.com/plugin/nativescript-pdf-view-bundling-enabled https://github.com/Essent/nativescript-pdf-view but some of it is outdated compared to this main branch. @Merott any chance of a merge for the feature?
Okay that fork didnt work and seems it's changes may have been merged anyway, but I found this solution:
First I had to make sure the files where being included by adding my resources folder to webpack.config.ts (you could also add |pdf to the previous line to include all pdfs)
new CopyWebpackPlugin([
{ from: "fonts/**" },
{ from: "**/*.+(jpg|png)" },
{ from: "resources/**/*" },
{ from: "assets/**/*" },
], { ignore: [`${relative(appPath, appResourcesFullPath)}/**`] }),
Then I used the following to get a direct path to the PDF and bound that to the PDFView component
import { knownFolders, Folder, File, path } from "tns-core-modules/file-system";
this.appFolder = knownFolders.currentApp();
this.FAQPDF = path.normalize(this.appFolder.path + "/resources/myfile.pdf");
<PDFView :src="FAQPDF" @onLoad="voidEvent"></PDFView>
Hope this helps.
Showing local files work as expected, but not if you bundle the project with Webpack. Online PDF works also with bundle...