Comments (6)
@squeezeboxhuf can you check which version of svelte-pdfjs you're using? I was experimenting with some stuff on the alpha versions so if you have those it'll not work. The latest stable version 0.3.4 should work.
from svelte-pdfjs.
I have made some progress! I discovered that I had to have a sveltekit project with TypeScript, then I modded my svelte.config.js and tsconfig.json to match your additional aliases, then copied the component parts from this repository src/lib into my src/lib folder and Hey Presto, I see a PDF document!
from svelte-pdfjs.
I'm glad you found a way to make it work somehow but that's not how the package is meant to be used.
If it's not too much of a bother to you, can you install version 0.3.4 with npm i [email protected] pdfjs-dist
and see if the issue persists? Thanks. 🙂
from svelte-pdfjs.
Yes that did the trick! So I reverted my tsconfig and svelte.config, removed the src/lib additions and I am still getting PDFs displayed! Thank you.
One extra question! I have some multi-page documents, so I am using a {#each} loop for maxPages numbers to repeat the <Page>
component within the <Document>
... like this...
{#if browser}
<Document
{file}
on:loadsuccess={(e) => console.log((maxPages = e.detail.numPages))}
on:loaderror={console.log}
>
{#each Array.from({ length: maxPages }, (_, i) => i + 1) as num}
<p class="separator">page {num} || <span on:click={handleRotate}>rotate</span></p>
<div>
<Page
{scale}
{num}
{renderTextLayer}
{rotation}
getViewport={preferThisWidth(targetWidth)}
/>
</div>
{/each}
</Document>
{/if}
But this results in an error after the first page (first page displays OK) : "PageCanvas.svelte? [sm]:9 Uncaught (in promise) TypeError: Cannot set properties of undefined (setting 'width') at render_page (PageCanvas.svelte? [sm]:9:17)". So I put the each loop around the <Document>
component and it's OK. Effectively I'm creating a <Document>
with a <Page>
within it, for each page. Is that what you'd expect to be needed? My first presumption was to iterate just the <Page>
elements.
I've discovered it might be my page separator paragraph interfering... It's OK to iterate just the <Page>
as long as I don't put any other objects in the loop... I've tried putting separator para before and after but it still seems to upset the subsequent pages.
For now, I've left it iterating each containing <Document>
and <Page>
.
Thanks
from svelte-pdfjs.
I just published 0.3.7 to npm which should fix it.
@squeezeboxhuf Upgrade and let me know if it works or not.
from svelte-pdfjs.
Yes - that's great. Thank you.
from svelte-pdfjs.
Related Issues (12)
- Implement text layer rendering
- npm run build gives error HOT 7
- Dispatch an event when a page has finished loading
- SSR compatibility
- Text rendering is broken in build mode
- getDocument is undefined; unexpected keyword export HOT 6
- Flash of unwanted content if both the doc url and page number are changed at the same time
- Make the component compatible with SSR HOT 1
- Rethink onMount abstraction HOT 2
- Support local file path or array buffer HOT 2
- Expose PDFDocumentProxy, or some other way of accessing document info HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from svelte-pdfjs.