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

<ImageComponent /> not working when rendering to memory #27

Open
hstandaert opened this issue Sep 9, 2020 · 1 comment
Open

<ImageComponent /> not working when rendering to memory #27

hstandaert opened this issue Sep 9, 2020 · 1 comment

Comments

@hstandaert
Copy link

hstandaert commented Sep 9, 2020

When I add the <ImageComponent /> to the word-memory.js file, the process silently fails... The same document does work when rendering to a file directly.

word-memory.js
import fs from 'fs';
import React, { Component } from 'react';
import TextComponent from '../examples/Text';
import { render, Document, Text } from '../src/';

// Uncomment any of the below component to see what they render

import FooterComponent from '../examples/Footer';
import HeaderComponent from '../examples/Header';
import HrComponent from '../examples/Hr';
import LineBreakComponent from '../examples/LineBreak';
import PageBreakComponent from '../examples/PageBreak';
import TableComponent from '../examples/Table';
import ListComponent from '../examples/List';
import ImageComponent from '../examples/Image';

class MyDocument extends Component {
  render() {
    return (
      <Document>
        <TextComponent />
        <ImageComponent />
      </Document>
    );
  }
}

render(<MyDocument />).then((stream) => {
  fs.open('./demo/Memory.docx', 'w+', stream.length, (err, fd) => {
    if (err) {
      console.log(err);
    }
    fs.write(fd, stream.toBuffer(), (writeErr) => {
      if (writeErr) {
        console.log(writeErr);
      }
      console.log('Docx generated and saved to ./demo/Memory.docx');
    });
  });
});
CLI output

Screenshot 2020-09-09 at 17 15 25

@hstandaert
Copy link
Author

This also seems to be the case for HeaderComponent and FooterComponent

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

1 participant