Skip to content

Any way to extract images from the pdf itself on the front end? #165

Answered by TaTo30
chronicadventure asked this question in Q&A
Discussion options

You must be logged in to vote

Based on: https://stackoverflow.com/questions/18680261/extract-images-from-pdf-file-with-javascript

I've did a small test and this seems to work only when raster images are embebed in the document (eg. 9.pdf):

<script setup lang="ts">
import pdf14 from "@samples/42.pdf";

import { VuePDF, usePDF } from "@tato30/vue-pdf";
import * as PDFJS from "pdfjs-dist";

const { pdf } = usePDF(pdf14);

function getPageImages(page: number) {
  pdf.value?.promise.then(async (document) => {
    const pageProxy = await document.getPage(page);
    const ops = await pageProxy.getOperatorList();
    const objs = [];
    for (var i = 0; i < ops.fnArray.length; i++) {
      if (ops.fnArray[i] == PDFJS.OPS.pain…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@chronicadventure
Comment options

Answer selected by chronicadventure
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants