I used the pdf package in my Flutter web project. It is completely working while I run it in debug or release mode, but when the web is deployed, it is not working. We can see it is clickable, but nothing happens after clicking.
Currently, when I click on the button, I can see it is clicked, but nothing happens. I want to generate a pdf while clicking, and this problem only arises when the web is deployed.
I tried to put this code in the index.html file, but nothing happened.
<script type="text/javascript">
pdfjsLib.GlobalWorkerOptions.workerSrc =
"https://cdn.jsdelivr.net/npm/[email protected]/build/pdf.worker.min.js";
pdfRenderOptions = {
// where cmaps are downloaded from
cMapUrl: "https://cdn.jsdelivr.net/npm/[email protected]/cmaps/",
// The cmaps are compressed in the case
cMapPacked: true,
// any other options for pdfjsLib.getDocument.
// params: {}
};
</script>
-
Please also share the current behaviour and expected behaviour so that ppl can help.ToraCode– ToraCode2024年05月02日 09:27:09 +00:00Commented May 2, 2024 at 9:27
1 Answer 1
I had used a font in my code as
static getGujaratiFont() async {
final font = await rootBundle.load("fonts/NotoSansGujarati.ttf");
gujaratiFont = pw.Font.ttf(font);
}
and my path in pubspec.yaml file is
assets:
- assets/fonts/NotoSansGujarati.ttf
so, there is 'rootBundle' is take automatic assets while debugging web but when web is deployed i have to set path in my font as rootBundle.load("assets/fonts/NotoSansGujarati.ttf"); then it is working