Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PDF -> SVG #7901

Closed
doublex opened this issue Dec 18, 2016 · 3 comments
Closed

PDF -> SVG #7901

doublex opened this issue Dec 18, 2016 · 3 comments

Comments

@doublex
Copy link

doublex commented Dec 18, 2016

Problems to save a PDF to SVG.
Steps to reproduce:
wget https://github.com/coolwanglu/pdf2htmlEX/raw/master/test/browser_tests/fontfile3_opentype.pdf
node ./examples/node/pdf2svg.js /tmp/fontfile3_opentype.pdf

Result:
writeToFile() is never called - so result directory 'svgdump' remains empty.

@timvandermeij
Copy link
Contributor

timvandermeij commented Dec 18, 2016

The console reports:

(node:5841) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): ReferenceError: Image is not defined
(node:5841) DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
(node:5841) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): ReferenceError: Image is not defined

It's only triggered by this particular PDF file as other files I tested work just fine. Moreover, the file renders when the SVG back-end is used, so this issue appears to be caused by the conversion script.

@liangwenzhong
Copy link

+1

@doublex
Copy link
Author

doublex commented Apr 4, 2017

Patch to fix:

*** src/shared/util.js-old      2017-04-04 14:35:02.500401720 +0200
--- src/shared/util.js  2017-04-04 14:35:27.622323458 +0200
*************** MessageHandler.prototype = {
*** 1398,1403 ****
--- 1398,1407 ----
  };
  
  function loadJpegStream(id, imageUrl, objs) {
+   if (/^data:/.test(imageUrl)) {
+     objs.resolve(id, imageUrl);
+     return;
+   }
    var img = new Image();
    img.onload = (function loadJpegStream_onloadClosure() {
      objs.resolve(id, img);

Call stack:

(node:12256) ReferenceError: testimageUrl is not defined
    at loadJpegStream (/tmp/pdf.js/build/dist/build/pdf.js:1131:21)
    at WorkerTransport.transportObj (/tmp/pdf.js/build/dist/build/pdf.js:3068:13)
    at MessageHandler.messageHandlerComObjOnMessage (/tmp/pdf.js/build/dist/build/pdf.js:1076:19)
    at FakeWorkerPort.<anonymous> (/tmp/pdf.js/build/dist/build/pdf.js:2710:20)
    at Array.forEach (native)
    at FakeWorkerPort.<anonymous> (/tmp/pdf.js/build/dist/build/pdf.js:2709:25)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants