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

Empty pdf pages #1245

Closed
tiredElephant opened this issue Jan 9, 2024 · 6 comments · Fixed by #1247
Closed

Empty pdf pages #1245

tiredElephant opened this issue Jan 9, 2024 · 6 comments · Fixed by #1247

Comments

@tiredElephant
Copy link

Describe the bug
running npx slidev export --per-slide --format pdf gives me a pdf with empty pages

To Reproduce
try running npx slidev export --per-slide --format pdf although it seems more like a misconfiguration of my part

Desktop (please complete the following information):

  • OS: Win 11
  • Browsers: not relevant
  • Slidev version: v0.46.1
@ev45ive
Copy link
Contributor

ev45ive commented Jan 10, 2024

Same here.

new project generated with
npm init slidev projectname

then:
npm i -D playwright-chromium
and
npm run export


  ●■▲
  Slidev  v0.43.15 

  theme       @slidev/theme-seriph
  css engine  unocss
  entry       C:\Projects\testslidev\slides.md
  ✓ exported to ./slides-export.pdf

[slides-export.pdf](https://github.com/slidevjs/slidev/files/13882287/slides-export.pdf)

and PDF slides-export.pdf is 1KB one empty page (included)

package.json:

{
  "name": "projectname",
  "private": true,
  "scripts": {
    "build": "slidev build",
    "dev": "slidev --open",
    "export": "slidev export"
  },
  "dependencies": {
    "@slidev/cli": "^0.43.1",
    "@slidev/theme-default": "latest",
    "@slidev/theme-seriph": "latest"
  },
  "devDependencies": {
    "playwright-chromium": "^1.40.1"
  }
}

@ev45ive
Copy link
Contributor

ev45ive commented Jan 10, 2024

OK. Found it.

  1. Export doesn`t work because VueJS fails to start insde ChromePupetteer breaking whole client - so => empty page => so empty PDF

  2. If you comment out server.close() + process.exit in CLI.mjs you can connect on port 12445+ and see that:

runtime-core.esm-bundler.js?v=093764c6:8112 Uncaught ReferenceError: __VUE_PROD_DEVTOOLS__ is not defined
    at runtime-core.esm-bundler.js?v=093764c6:8112:55
(anonymous) @ runtime-core.esm-bundler.js?v=093764c6:8112

going inside vue its:

const version = "3.4.7";
const warn = !!("production" !== "production") ? warn$1 : NOOP;
const ErrorTypeStrings = ErrorTypeStrings$1 ;                /// IT BREAKES vvv HERE vvv
const devtools = !!("production" !== "production") || __VUE_PROD_DEVTOOLS__ ? devtools$1 : void 0;
const setDevtoolsHook = !!("production" !== "production") || __VUE_PROD_DEVTOOLS__ ? setDevtoolsHook$1 : NOOP;
const _ssrUtils = {

problem is because inside node_modules@slidev\cli\dist\cli.mjs there is

cli.command(
  "export [entry..]",
  "Export slides to PDF",
  (args) => exportOptions(commonOptions(args)).strict().help(),
  async (args) => {
    const { entry, theme } = args;
    process.env.NODE_ENV = "production";  /// <<<<<<<<<<============= THIS LINE 
    const { exportSlides, getExportOptions } = await import("./export-LYIOCUF2.mjs");

comment it out @tiredElephant (YES, inside node_modules@slidev\cli\dist\cli.mj unfortunately... ;-( )
/// process.env.NODE_ENV = "production"; /// <<<<<<<<<<============= THIS LINE

restart export and it should work.

I can't see the reason why this line is there. Is there one @antfu ?

@ev45ive
Copy link
Contributor

ev45ive commented Jan 10, 2024

Or else Vite needs this defined as constant so its gets replaced:

export default defineConfig({
  plugins: [ ... ],
  define: {
    __COMMIT__: JSON.stringify(commit),
    __VUE_PROD_DEVTOOLS__: JSON.stringify(true),
  }

@antfu
Copy link
Member

antfu commented Jan 17, 2024

I am not able to reproduce it on my side, can anyone share a reproduction repo?

@Bellfalasch
Copy link

@antfu This repo gives you white exports. It uses bun, but you could just do npm as usual and still get blank pages on npm run export as well as bun run export. https://github.com/Bellfalasch/frontend-forum

Tried a few combos of latest playwright devDep and sli.dev, all coming up as white page of PDF (the latest test is with --per-slide giving loads of white pages).

@AkifumiSato
Copy link

I too am facing this problem.

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 a pull request may close this issue.

5 participants