Skip to content
This repository has been archived by the owner on Apr 4, 2023. It is now read-only.

Return result instead of render #135

Open
xiki808 opened this issue Nov 25, 2022 · 3 comments
Open

Return result instead of render #135

xiki808 opened this issue Nov 25, 2022 · 3 comments

Comments

@xiki808
Copy link

xiki808 commented Nov 25, 2022

Hi! Thank you for this library! Is there a way how to return the formatted result rather than just applying the book to the bottom of the page immediately on load?

One thing I tried is to pass autorun false, but I would still get a blank ( 100vh ) space at the bottom of the page. Further more, if I run makeBook on the result I get empty pages.

let book = await Bindery.makeBook({
    autorun: false,
    content: '.display-content .test',
    pageSetup: {
      size: { width: '793.688px', height: '1122.520px' },
      margin: { top: '0px', inner: '0px', outer: '0px', bottom: '0px' },
    },
    rules: [
      Bindery.PageBreak({ selector: 'h2', position: 'before' }),
      Bindery.FullBleedSpread({ selector: '.big-figure' }),
    ],
  })
    .makeBook(images.value)
@evnbr
Copy link
Owner

evnbr commented Dec 3, 2022

Hi @xiki808 . There's not currently a way to do that— bindery puts the book in a consistent position at the bottom of the page, because that makes it much easier to print consistently.

Can you share what specifically you are trying to achieve?

@xiki808
Copy link
Author

xiki808 commented Dec 19, 2022

Sorry for my late reply. I need to convert html content into SVG. I'm using bindery more specifically to be able to split my content into pages, as the content can change on user input. Thanks to bindery html content organization into pages is working perfectly.

For my scenario though I don't need any other features, like selecting grid and more specifically I need to place the preview of the pages inside another element. In order to do so I'm removing bindery's root element each time I generate the book ( on every user input ), and then use the rawPages elements from the generated book instance, to grab the pages and place them where I need. Here's a simplified version of what I'm doing:

const book = await Bindery.makeBook({
    autorun: false,
    content: content
  }).makeBook(content);
  
const bookRootElement = document.querySelector('.📖-root');
const bookMeasureElement = document.querySelector('.📖-measure-area');

if (bookRootElement) bookRootElement.remove();
if (bookMeasureElement) bookMeasureElement.remove();

book?.rawPages.forEach(page => {
    display.appendChild(page.element.cloneNode(true));
});

Would really appreciate if you can add an option feature which when enabled, the book is not added to the DOM, but rather it's up to the developer to use the book instance as needed.

@evnbr
Copy link
Owner

evnbr commented Jan 12, 2023

Got it, that makes sense. Directionally I plan to better split the page-creation step from the viewer. Unfortunately I am swamped with other work so can't give any timeline, although I am happy to accept PRs.

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

No branches or pull requests

2 participants