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

Crash when used in electron #33

Closed
hl-a-k opened this issue Apr 30, 2018 · 6 comments
Closed

Crash when used in electron #33

hl-a-k opened this issue Apr 30, 2018 · 6 comments
Labels

Comments

@hl-a-k
Copy link

hl-a-k commented Apr 30, 2018

  • Version: electron-builder@^19.19.1
  • Target: both Mac and windows7 32

My electron App run well by use:
yarn dev

but it crash after I built the app, and run it.

code cause crash:

 const HummusRecipe = require('hummus-recipe')
 const pdfDoc = new HummusRecipe('new', '/Users/zhouwenhan/workspace/yunmao/yunmao-kit/output4.pdf')
 pdfDoc
          // edit 1st page
 .createPage()
            // .text('Add some texts to an existing pdf file', 150, 300)
 .image(img, 150, 300)
 .overlay(pdf, 0, 0)
 .endPage()
 .endPDF()

I have use humus-recipe

 "rebuild": "electron-rebuild -f -w hummus-recipe"

 "dependencies": {
    "axios": "^0.16.1",
    "hummus-recipe": "^1.6.9",
    "vue": "^2.3.3",
    "vue-electron": "^1.0.6",
    "vue-router": "^2.5.3",
    "vuex": "^2.3.1"
  },

the crash log from MAC system:

yunmao-kit_2018-04-30-195058_zhoudeMacBook-Pro.crash.log

@chunyenHuang
Copy link
Owner

Hello I believe this is more related to the HummusJS. Do you have the build codes for electron?

@hl-a-k
Copy link
Author

hl-a-k commented May 1, 2018

this is my project:
https://github.com/hl-a-k/yunmao-kit

@hl-a-k
Copy link
Author

hl-a-k commented May 1, 2018

I found the reason:
.org.simulatedgreg.electron-vue.OeOWLv 0x000000011cb41297 PDFWriterDriver::GetFontForFile(v8::FunctionCallbackInfo<v8::Value> const&) + 1955 (PDFWriterDriver.cpp:541)

The electron-builder didn't copy fronts resources to destination.
After comment off code in node_module/hummus-recipe:
qq20180501-172505

It works now.

But I think is not the final solution

@chunyenHuang
Copy link
Owner

chunyenHuang commented May 1, 2018

你好 感謝你分享程式碼

Hello @hl-a-k
Thanks for sharing your codes.

You are right about the font path issue. My solution for you at this moment is to use your custom fonts in your electron repo, since that electron has it's own file system.

Here is my debug code

// LandingPage.vue line 40
     stamp () {
        // ...
        const path = require('path')
        const fontSrcPath = path.join(__dirname, '../assets/fonts')
        // I put a ttf file called `myfont.ttf` in the fonts directory 
        // `src/renderer/assets/fonts/myfont.ttf`
        // Dont forget to comment back the codes in `hummus-recipe/lib/vector.helper.js`
        const output = path.join(__dirname, 'output4.pdf')
        const HummusRecipe = require('hummus-recipe')
        const pdfDoc = new HummusRecipe('new', output, {
          fontSrcPath
        })
        pdfDoc
          .createPage()
          .text('Add some texts to an existing pdf file', 150, 300, {
            font: 'myfont'
          })
          .endPage()
          .endPDF()
    }

You can see more details in #32.

@hl-a-k
Copy link
Author

hl-a-k commented May 2, 2018

Thank you for your help.

@chunyenHuang
Copy link
Owner

Does it work?

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

No branches or pull requests

2 participants