Skip to content

Add UI button to convert PDF files to EPUB format#43

Draft
Copilot wants to merge 4 commits intoPDF-to-EPUBfrom
copilot/sub-pr-42
Draft

Add UI button to convert PDF files to EPUB format#43
Copilot wants to merge 4 commits intoPDF-to-EPUBfrom
copilot/sub-pr-42

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Dec 19, 2025

  • Add Convert to EPUB button for PDF-only media items
  • Fix read-only filesystem error in serverless environment
    • Configured EPub library to use /tmp directory for temporary files
    • This prevents EROFS errors in Vercel's read-only filesystem
  • Fix ENOENT error for missing CSS template files
    • Added inline CSS to EPub options to avoid dependency on external template files
    • Prevents "no such file or directory" errors for template.css

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@vercel
Copy link
Copy Markdown

vercel Bot commented Dec 19, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
secret-library Ready Ready Preview, Comment Dec 19, 2025 6:54pm

Copilot AI changed the title [WIP] Add PDF to EPUB conversion functionality Answer user question about PDF to EPUB conversion trigger mechanism Dec 19, 2025
Copilot AI requested a review from andrepetsch December 19, 2025 18:10
@andrepetsch
Copy link
Copy Markdown
Owner

@copilot Please add a button to trigger the conversion on media, that only has a pdf file.

Co-authored-by: andrepetsch <56927999+andrepetsch@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Dec 19, 2025

@copilot Please add a button to trigger the conversion on media, that only has a pdf file.

Added a "Convert to EPUB" button in commit d2948f7. The button:

  • Only appears for media items with a single PDF file (no EPUB yet)
  • Only visible to the media owner (same permissions as Edit/Delete)
  • Shows "Converting..." state while processing
  • Appears as a full-width indigo button below the Edit/Delete row
  • Calls /api/media/convert-pdf-to-epub with the media ID
  • Refreshes the media list after successful conversion

The button will be displayed on library cards that have only a PDF file, making it easy to convert them to EPUB format with one click.

Copilot AI changed the title Answer user question about PDF to EPUB conversion trigger mechanism Add UI button to convert PDF files to EPUB format Dec 19, 2025
@andrepetsch
Copy link
Copy Markdown
Owner

@copilot The Button is good, but I'm now getting this error:

    at sM.render (.next/server/chunks/[root-of-the-server]__414d0d4e._.js:7:294147)
    at sj (.next/server/chunks/[root-of-the-server]__414d0d4e._.js:19:4127)
    at async sz (.next/server/chunks/[root-of-the-server]__414d0d4e._.js:33:1978)
    at async sW (.next/server/chunks/[root-of-the-server]__414d0d4e._.js:33:500)
    at async m (.next/server/chunks/[root-of-the-server]__414d0d4e._.js:33:5733)
    at async o (.next/server/chunks/[root-of-the-server]__414d0d4e._.js:33:6779) {
  errno: -30,
  code: 'EROFS',
  syscall: 'mkdir',
  path: '/var/task/.next/server/assets/tempDir'
}

Please check if the file is not stored anywhere else then the blob storage.

Co-authored-by: andrepetsch <56927999+andrepetsch@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Dec 19, 2025

@copilot The Button is good, but I'm now getting this error:

    at sM.render (.ne...

Fixed the read-only filesystem error in commit 714d2f1.

The issue was that the @lesjoursfr/html-to-epub library was creating temporary directories in a read-only location. I added tempDir: '/tmp' to the EPub configuration to force all temporary files to use /tmp, which is writable in serverless environments.

All files are now:

  • Temporarily written to /tmp during conversion
  • Uploaded to Vercel Blob storage (no local storage)
  • Cleaned up after conversion completes

The conversion should now work correctly in your Vercel deployment.

@andrepetsch
Copy link
Copy Markdown
Owner

@copilot Please have a look at this error:

Co-authored-by: andrepetsch <56927999+andrepetsch@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Dec 19, 2025

@copilot Please have a look at this error:

Fixed the ENOENT error in commit 6f8c77b.

The issue was that the @lesjoursfr/html-to-epub library was trying to access CSS template files that don't exist in the build output. I added inline CSS directly to the EPub options using the css property, which provides the styling without requiring external template files.

The EPUB files will now be generated with clean, readable formatting using a serif font and proper spacing.

@andrepetsch andrepetsch linked an issue Dec 28, 2025 that may be closed by this pull request
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

Successfully merging this pull request may close these issues.

Create EPUBs based on PDFs

2 participants