Skip to content

Commit

Permalink
Fix pdfjs -> Use pdfjs from obsidian
Browse files Browse the repository at this point in the history
  • Loading branch information
joleaf committed Jun 16, 2023
1 parent 5788aff commit 5fdd2c6
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 10 deletions.
7 changes: 2 additions & 5 deletions main.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import {parseYaml, Plugin, TFile} from "obsidian";
import {parseYaml, Plugin, loadPdfJs} from "obsidian";
import {BetterPdfSettings, BetterPdfSettingsTab} from "./settings";
import * as pdfjs from "pdfjs-dist";
import pdfjsWorker from 'pdfjs-dist/build/pdf.worker.entry';

interface PdfNodeParameters {
range: Array<number>;
Expand All @@ -23,8 +21,6 @@ export default class BetterPDFPlugin extends Plugin {
this.settings = Object.assign(new BetterPdfSettings(), await this.loadData());
this.addSettingTab(new BetterPdfSettingsTab(this.app, this));

pdfjs.GlobalWorkerOptions.workerSrc = pdfjsWorker;

this.registerMarkdownCodeBlockProcessor("pdf", async (src, el, ctx) => {
// Get Parameters
let parameters: PdfNodeParameters | null = null;
Expand All @@ -45,6 +41,7 @@ export default class BetterPDFPlugin extends Plugin {
parameters.url = folderPath + "/" + parameters.url.substring(2, parameters.url.length);
}
//Read Document
const pdfjs = await loadPdfJs();
const arrayBuffer = await this.app.vault.adapter.readBinary(parameters.url);
const buffer = new Uint8Array(arrayBuffer);
const document = await pdfjs.getDocument(buffer).promise;
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "better-pdf-2",
"name": "Better PDF 2",
"version": "2.0.2",
"version": "2.0.3",
"minAppVersion": "0.15.0",
"description": "Goal of this Plugin in to implement a native PDF handling workflow",
"author": "JoLeaf",
Expand Down
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "better-pdf-2",
"version": "2.0.2",
"version": "2.0.3",
"description": "Goal of this Plugin in to implement a native PDF handling workflow",
"main": "main.js",
"scripts": {
Expand All @@ -22,7 +22,6 @@
"typescript": "4.7.4"
},
"dependencies": {
"canvas": "^2.11.2",
"pdfjs-dist": "^2.16.105"
"canvas": "^2.11.2"
}
}
1 change: 0 additions & 1 deletion typings/index.d.ts

This file was deleted.

0 comments on commit 5fdd2c6

Please sign in to comment.