How an agent typesets a book on its workspace, checks the PDF and prints it at Lulu on your own Lulu account. What the workspace is and what it costs is on Services.
The connect step is on Print on demand.
In the workspace, typeset manuscript.typ as a 6 by 9 inch book with Typst and write book.pdf.Every workspace has Typst, which turns plain text into a PDF. The agent runs it with stack_workspace_run:
typst compile book.typ book.pdfgs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dPDFSETTINGS=/prepress -dEmbedAllFonts=true -sOutputFile=book-print.pdf book.pdf
pdfinfo book-print.pdfpdfinfo prints the page count and the page size. Check both before you ask for a quote.
A book has a second PDF for the cover. Lulu gives the size it must have for each product and page count, and the agent makes the cover to that size with Typst, the same way, then checks it with pdfinfo. Ghostscript, qpdf and poppler are installed, so the agent can also merge, split and repair PDFs.
const ws = stack.accounts.workspace;
const interior = await ws.saveFile('acct_123', workspaceId, { path: 'book-print.pdf' }, { passportToken });
const cover = await ws.saveFile('acct_123', workspaceId, { path: 'cover.pdf' }, { passportToken });The tool is stack_workspace_save_file. It takes a file of any size the drive takes: see Workspace.
Lulu prints and ships books on demand. It prints from PDF files only. Lulu charges the card stored on the Lulu account you connected, and a new print job moves on from unpaid by itself. Quotes are in US dollars.
Connect it with the key and the secret of your Lulu account. The CLI reads them from a hidden prompt, or from the environment variables the command names, never from an argument. Only the owner or an admin can connect it:
npx @getstackrun/cli account making-connect-supplier luluFrom code: connectSupplier('lulu', { api_key, api_secret }). Lulu's sandbox is a separate Lulu account and host, and STACK uses the real one.
const design = await stack.accounts.making.uploadDesign('acct_123', {
drive_file_id: interior.drive_file_id,
}, { passportToken });
const { quotes } = await stack.accounts.making.quote('acct_123', {
design_id: design.id,
supplier: 'lulu',
spec: { quantity: 1, product: '0600X0900BWSTDPB060UW444MXX', page_count: 120 },
recipient: {
name: 'Anna Berg', email: 'anna@example.com', phone: '+14155550123',
address1: '1 Main St', city: 'San Francisco', state: 'CA', postal_code: '94102', country: 'US',
},
}, { passportToken });
const order = await stack.accounts.making.order('acct_123', quotes[0].id, { passportToken });npx @getstackrun/cli account making acct_123 quote --design mkd_abc123 --supplier lulu \
--quantity 1 --product 0600X0900BWSTDPB060UW444MXX --page-count 120 --recipient-file recipient.json
npx @getstackrun/cli account making acct_123 order mkq_abc123Ordering and approving work as in Print on demand. Lulu charges your account.
An order through STACK carries one file, and STACK sends it to Lulu as both the interior and the cover. A book with a separate cover cannot be ordered through STACK yet. The agent makes both PDFs and keeps them on the drive, and the order itself is placed on Lulu with your account.
Every field is on Making. Every tool is in the tool reference.