0

How to show line by line data in div when reading the data from large pdf file?

I have created an application, where I import large pdf file and append data line by line in div but application displays all lines after whole process of for loop.

But I want line by line display in div instead of whole at end of the process.

user1528468
  • 33
  • 2
  • 9
  • You would have to call the javascript function for every line of the PDF you want to generate rather than keep appending until the function is finished running once...not sure how that would work with generating the PDF visually though – Rinktacular Mar 16 '17 at 13:38
  • Check this out: http://stackoverflow.com/questions/672732/prevent-long-running-javascript-from-locking-up-browser – yts Mar 16 '17 at 13:40
  • @yts thank you for suggesting the link, it helped me. – user1528468 May 14 '17 at 16:43

2 Answers2

0

You have to dynamically update your div. To do so you need to use javascript or jQuery. Parsing of the file would happen in the backend, by batches of x lines and jquery would receive batches and update the div with the value of the processed batch. Then everything depends on how you parse your file, but given the amount of details you provide that's the best i can advise

Vincent Teyssier
  • 2,146
  • 5
  • 25
  • 62
0

You will have to wrap the lines that update your div with setTimeout, This way you can "release" the javascript context switch to deal with your UI for each line. You can also play with animation or use fade effect with little delay for fun :)

for(var i=0; i<10; i++){
  setTimeout(function(a) {
    console.log('This is line number: ', a+1);
  }, 1000*i, i);
}
EfiBN
  • 408
  • 2
  • 11