0

I'm wondering how I can accomplish horizontal scrolling of the pages of a PDF using JavaScript. Is it better to:

  1. Convert the pages of the PDF into HTML files and then click left-right between iframes where src="...each page.html"?
  2. Convert the pages of the PDF into some other HTML element besides iframe (e.g., DIV?) and then click left-right between elements containing the contents of each page.

I'd like to ensure that the PDF's text is searchable so I don't want to make its pages into images. I'm also skeptical of using iframes because of the formatting challenges of having multiple iframes in a single webpage. I've already tested this approach after converting the PDF to HTML using "PDFtoHTML" linux-based software and find that in general this is a suboptimal solution.

It seems like option 2 is the way to go but wouldn't know how to programmatically parse a PDF into multiple DIVs. Besides JavaScript, I'm familiar with PHP and Linux but not other languages if that would be helpful in thinking of solutions.

user229044
  • 232,980
  • 40
  • 330
  • 338
tim peterson
  • 23,653
  • 59
  • 177
  • 299

2 Answers2

0

PDF plugin intercepts mouse events so there is no way to control it directly from the browser / JavaScript.

Your other method, converting to html, is feasible.

Joshua
  • 3,615
  • 1
  • 26
  • 32
0

Converting a PDF page to a HTML file is more or less the exact same thing as "parsing it into a <div>". If you already found a tool that can do it for you ("PDFtoHTML"), just use that, and strip away everything except what's inside the <body> of the .html it outputs.

millimoose
  • 39,073
  • 9
  • 82
  • 134