How to reference pdf.js library in React?How to validate an email address in JavaScriptHow do JavaScript closures work?How do I check if an element is hidden in jQuery?How do I remove a property from a JavaScript object?How do I redirect to another webpage?How do I include a JavaScript file in another JavaScript file?How to replace all occurrences of a string?How to check whether a string contains a substring in JavaScript?How do I remove a particular element from an array in JavaScript?How do I return the response from an asynchronous call?

Is refreshing multiple times a test case for web applications?

What would happen to an adventurer's personal identity when turning into a God?

How do we avoid CI-driven development...?

Traveling from Germany to other countries by train?

Did WWII Japanese soldiers engage in cannibalism of their enemies?

What word can be used to describe a bug in a movie?

Is TA-ing worth the opportunity cost?

Acceptable to cut steak before searing?

Is The Lion King live action film made in motion capture?

Why couldn't soldiers sight their own weapons without officers' orders?

Why are the inside diameters of some pipe larger than the stated size?

How can I tell if a flight itinerary is fake?

Blocking people from taking pictures of me with smartphone

Can an actual attack instead of a feint be used as the distraction for a Help action?

How to write "upright" integrals with automatic sizing

"How do you solve a problem like Maria?"

How to display a duet in lyrics?

Improving software when the author can see no need for improvement

How quickly could a country build a tall concrete wall around a city?

During the Space Shuttle Columbia Disaster of 2003, Why Did The Flight Director Say, "Lock the doors."?

Is multiplication of real numbers uniquely defined as being distributive over addition?

How to realistically deal with a shield user?

Infeasibility in mathematical optimization models

Why should public servants be apolitical?



How to reference pdf.js library in React?


How to validate an email address in JavaScriptHow do JavaScript closures work?How do I check if an element is hidden in jQuery?How do I remove a property from a JavaScript object?How do I redirect to another webpage?How do I include a JavaScript file in another JavaScript file?How to replace all occurrences of a string?How to check whether a string contains a substring in JavaScript?How do I remove a particular element from an array in JavaScript?How do I return the response from an asynchronous call?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I am trying to reference PDF.js (by Mozilla) into my React project. However, it is throwing 'Unexpected identifier' error.



I have placed the PDF.js in the public folder and referenced it in my index.html.



File structure:



public
- index.html
- pdftojs
- parsejs.js // < parseFile method in this file will be called
- pdf-parse.js
- misc..
src
- pdftotext
- parsepdf.js // < page to parse PDF



pdf-parse.js



var PDFJS = null
function render_page(pageData) ... // Untouched
async function PDF(...) ... // Untouched

exports.pdf = PDF; // Changed this line


parsejs.js from the original library:



8 import pdf from 'pdf-parse.js';
9 const pdfjsLib = require('pdfjs-dist'); // 'require' is undefined too so I don't know what is the correct way
10
11 function parseFile(file)

...
45


This file throws Unexpected identifier on Line 8



Parse PDF Page (parsepdf.js)



 process(file) 
parseFile(file); // calling method in parsejs.js
...



which gives 'parseFile' is not defined










share|improve this question
























  • Have you checked github.com/mozilla/pdf.js/wiki/Setup-pdf.js-in-a-website ? Are you using some bundler like webpack ?

    – jgoday
    Mar 27 at 7:08


















0















I am trying to reference PDF.js (by Mozilla) into my React project. However, it is throwing 'Unexpected identifier' error.



I have placed the PDF.js in the public folder and referenced it in my index.html.



File structure:



public
- index.html
- pdftojs
- parsejs.js // < parseFile method in this file will be called
- pdf-parse.js
- misc..
src
- pdftotext
- parsepdf.js // < page to parse PDF



pdf-parse.js



var PDFJS = null
function render_page(pageData) ... // Untouched
async function PDF(...) ... // Untouched

exports.pdf = PDF; // Changed this line


parsejs.js from the original library:



8 import pdf from 'pdf-parse.js';
9 const pdfjsLib = require('pdfjs-dist'); // 'require' is undefined too so I don't know what is the correct way
10
11 function parseFile(file)

...
45


This file throws Unexpected identifier on Line 8



Parse PDF Page (parsepdf.js)



 process(file) 
parseFile(file); // calling method in parsejs.js
...



which gives 'parseFile' is not defined










share|improve this question
























  • Have you checked github.com/mozilla/pdf.js/wiki/Setup-pdf.js-in-a-website ? Are you using some bundler like webpack ?

    – jgoday
    Mar 27 at 7:08














0












0








0








I am trying to reference PDF.js (by Mozilla) into my React project. However, it is throwing 'Unexpected identifier' error.



I have placed the PDF.js in the public folder and referenced it in my index.html.



File structure:



public
- index.html
- pdftojs
- parsejs.js // < parseFile method in this file will be called
- pdf-parse.js
- misc..
src
- pdftotext
- parsepdf.js // < page to parse PDF



pdf-parse.js



var PDFJS = null
function render_page(pageData) ... // Untouched
async function PDF(...) ... // Untouched

exports.pdf = PDF; // Changed this line


parsejs.js from the original library:



8 import pdf from 'pdf-parse.js';
9 const pdfjsLib = require('pdfjs-dist'); // 'require' is undefined too so I don't know what is the correct way
10
11 function parseFile(file)

...
45


This file throws Unexpected identifier on Line 8



Parse PDF Page (parsepdf.js)



 process(file) 
parseFile(file); // calling method in parsejs.js
...



which gives 'parseFile' is not defined










share|improve this question














I am trying to reference PDF.js (by Mozilla) into my React project. However, it is throwing 'Unexpected identifier' error.



I have placed the PDF.js in the public folder and referenced it in my index.html.



File structure:



public
- index.html
- pdftojs
- parsejs.js // < parseFile method in this file will be called
- pdf-parse.js
- misc..
src
- pdftotext
- parsepdf.js // < page to parse PDF



pdf-parse.js



var PDFJS = null
function render_page(pageData) ... // Untouched
async function PDF(...) ... // Untouched

exports.pdf = PDF; // Changed this line


parsejs.js from the original library:



8 import pdf from 'pdf-parse.js';
9 const pdfjsLib = require('pdfjs-dist'); // 'require' is undefined too so I don't know what is the correct way
10
11 function parseFile(file)

...
45


This file throws Unexpected identifier on Line 8



Parse PDF Page (parsepdf.js)



 process(file) 
parseFile(file); // calling method in parsejs.js
...



which gives 'parseFile' is not defined







javascript reactjs pdfjs






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 27 at 6:56









xtotheawnxtotheawn

12 bronze badges




12 bronze badges















  • Have you checked github.com/mozilla/pdf.js/wiki/Setup-pdf.js-in-a-website ? Are you using some bundler like webpack ?

    – jgoday
    Mar 27 at 7:08


















  • Have you checked github.com/mozilla/pdf.js/wiki/Setup-pdf.js-in-a-website ? Are you using some bundler like webpack ?

    – jgoday
    Mar 27 at 7:08

















Have you checked github.com/mozilla/pdf.js/wiki/Setup-pdf.js-in-a-website ? Are you using some bundler like webpack ?

– jgoday
Mar 27 at 7:08






Have you checked github.com/mozilla/pdf.js/wiki/Setup-pdf.js-in-a-website ? Are you using some bundler like webpack ?

– jgoday
Mar 27 at 7:08













0






active

oldest

votes










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55371402%2fhow-to-reference-pdf-js-library-in-react%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes




Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.







Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55371402%2fhow-to-reference-pdf-js-library-in-react%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해