Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

176
Vistas
pdfjs cannot use function 'getPageIterator'

I am trying to follow the documentation for pdfjs found here https://www.pdftron.com/documentation/core/guides/features/manipulation/remove/ in an attempt to remove a page from a PDF I have uploaded to my html page. Here is my html code:

<script src="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/2.2.228/pdf.js"></script>
<input type="file" id="input"/>
<script>
    document.getElementById('input').addEventListener('change', function(e){
        var reader = new FileReader()
        reader.onload = function(x){
            window['pdfjs-dist/build/pdf'].getDocument({data:x.target.result}).promise.then(function(doc){
                doc.pageRemove(doc.getPageIterator(5));
                console.log(doc.numPages)
            })}
        reader.readAsBinaryString(e.target.files[0])
    }, false)
</script>

which gives this console error when I upload a PDF file to the page:

removeDemo.html:10 Uncaught (in promise) TypeError: doc.getPageIterator is not a function 

The PDF I am uploading has more than 5 pages, so asking to remove the 5th page in particular shouldn't be the problem. Other functionality does seem to work however, for example, I have a line in the above code that prints the number of pages of the document. This works fine when I comment out the 'getPageIterator' line. So it seems to be a problem with this specific function, rather than a more general problem. I would like to know what is causing this problem. In case this is relevant, I am running this in chromium on a macbook pro.

Please let me know if there is something in the above question that I can further clarify.

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

Mozilla led pdf.js is primarily a browser plugin pdf viewer, without editor functions.

The function your calling doc.pageRemove(doc is for use with PDFTron webview / edit SDK and thus specific to that commercial JavaScript library.

about 4 years ago · Juan Pablo Isaza Denunciar

0

The documentation you linked to, from PDFTron, has nothing to do with PDF.js, it is a completely separate SDK. This is why you get an error making a SDK API call on a different SDK.

Since PDF.js does not support removing pages from a PDF (nor editing in general), then I assume your intention is to use PDFTron SDK to remove (or edit in other ways) a PDF file in the browser client side.

In which case you want to do the following.

See this sample: https://www.pdftron.com/documentation/web/samples/pdf-manipulation/#page-operations

See here to get started with the SDK: https://www.pdftron.com/documentation/web/get-started/

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda