0

Describe the bug I develop a PDFfile and display those PDFfile by using PdfViewer on a page. When I develop on a local, it works well. But When I build a page, PDFViwer and any Pdf don't display. I don't know how to fix this. In the production page, created pdf doesn't appear, but in the local, all pdf works well....

To Reproduce

//temp.tsx 
import React, { useState } from "react";
import TempPDF from "../../src/components/printBarcode/temp";

const index = () => {
  return <TempPDF />;
};

export default index;
import React, { useEffect, useState } from "react";
import dynamic from "next/dynamic";
import TempDocument from "./TempDocument";

const PDFViewer = dynamic(
  import("@react-pdf/renderer").then((module) => module.PDFViewer),
  {
    loading: ({ error, isLoading, pastDelay, retry }) => {
      return <div>{isLoading}</div>;
    },
    ssr: false,
  }
);

function TempPDF() {
  return (
    <div>
      <PDFViewer
        //@ts-ignore
        width="100%"
        height="660px"
      >
        <TempDocument />
      </PDFViewer>
    </div>
  );
}

export default TempPDF;
import React from "react";
import {
  Document,
  Font,
  Page,
  View,
  StyleSheet,
  Text,
} from "@react-pdf/renderer";

Font.register({
  family: "Nanum Gothic",
  fonts: [
    { src: "/static/font/NanumGothic.ttf" },
    { src: "/static/font/NanumGothic-Bold.ttf", fontWeight: "bold" },
  ],
});

const TempDocument = () => {
  const styles = StyleSheet.create({});

  return (
    <Document>
      <Page wrap={false} break size={[80, 60]}>
        <View>
          <Text>Please display</Text>
        </View>
      </Page>
    </Document>
  );
};

export default TempDocument;

  • OS: [MacOS]
  • Browser [chrome]
  • React-pdf version [^2.1.1]
  • vercel
MIAㅜ_ㅜ
  • 71
  • 1
  • 7
  • Do you get any errors in production? Can you reproduce the issue when building the app for production locally (`next build && next start`)? – juliomalves May 02 '22 at 16:00
  • yes, Alos it was the same! And I add "swcMinify: false" in next.config.js then solve it! – MIAㅜ_ㅜ May 04 '22 at 08:51

0 Answers0