react-pdf icon indicating copy to clipboard operation
react-pdf copied to clipboard

border css property not working

Open serkyen opened this issue 8 years ago β€’ 9 comments

OS: macOS 10.14 Mojave

React-pdf version: 1.0.0-alpha.19

Description: Ever since upgrading to 1.0.0-alpha.19, borders do not work anymore.

How to replicate issue including code snippet (if applies):

import { StyleSheet } from '@react-pdf/renderer/dist/react-pdf.browser.cjs.js';
export const styles = StyleSheet.create({
  page: {
    backgroundColor: '#FFF',
    padding: 10,
    fontSize: 10,
  },
  viewBox: {
    fontSize: 10,
    display: 'flex',
    alignItems: 'flex-start',
    border:'1px solid #000',
    flexDirection: 'row',
  },
});

import { styles } from '../pdf/Styles.js';
...
<Document title="Order">
              <Page wrap size="A4" style={styles.page}>
                 <View style={styles.viewBox}>
                     <Image cache={false} style={{width:150, height:150}} src={this.state.image} />
                </View>
              </Page>
</Document>

When the PDF renders, there is no border. Prior to version 1.0.0-alpha.19, it was working.

serkyen avatar Oct 28 '18 14:10 serkyen

and what about font-weight?

SzymonNiemiec avatar Oct 28 '18 15:10 SzymonNiemiec

Hey @serkyen ! I just checked this out. Please use 1pt (or just 1 because points are the default unit) instead of 1px. I should have never support the px unit, since there are no pixels in the pdf. You can also use in, mm or cm now

diegomura avatar Oct 29 '18 04:10 diegomura

@diegomura Thanks...borders working, but fontWeight : 1 or fontWeight: 20 has no effect.

serkyen avatar Oct 30 '18 00:10 serkyen

That’s because fontWeight was never supported 😊. You should use different fontFamilies to make bold or light texts

diegomura avatar Oct 30 '18 01:10 diegomura

Hi, I am trying to display my resume as pdf to be in center. but its displaying on the left side. Can you please help me fix this. Thanks

nehamod avatar Oct 01 '20 02:10 nehamod

import React from 'react'; import resume from "./resume/resume.pdf"; import { Document, Page, pdfjs } from 'react-pdf';

class Resume extends React.Component { constructor(props) { super(props); pdfjs.GlobalWorkerOptions.workerSrc = //cdnjs.cloudflare.com/ajax/libs/pdf.js/${pdfjs.version}/pdf.worker.js;

    this.state = { numPages: null, pageNumber: 1 }
}

onDocumentLoad = ({ numPages }) => {
    this.setState({ numPages });
}
render() {
    const { pageNumber, numPages } = this.state;

    return (
        <div className="App">
            <Document file={resume} onLoadSuccess={this.onDocumentLoad}>



                <Page pageNumber={pageNumber} size="A4" style={{ textAlign: 'center' }} > </Page>
                <Page pageNumber={pageNumber} size="A4" style={{ textAlign: 'center' }} > </Page>


            </Document>
            <p> Page {pageNumber} of {numPages}</p>

        </div>
    )
}

}

export default Resume;

nehamod avatar Oct 01 '20 02:10 nehamod

I can't seem to be able to render a border on my page component... is there a workaround for this. const styles = StyleSheet.create({ page: { flexDirection: 'column', backgroundColor: '#FFFFFF', margin: 10, borderTop: 3, borderBottom: 3, borderLeft: 3, borderRight: 3, borderColor: '#22618F', BorderStyle: 'solid', }, });

PhilObi avatar Jan 27 '21 19:01 PhilObi

For me, border was not coming when viewed in PDF X-change-Editor, but when I viewed the file in Chrome, border was coming. I wasted my 1 day in fixing an issue that didn't exist..

vineethasimon avatar Feb 09 '22 09:02 vineethasimon

      borderColor: 'black',
      borderBottom: 1,   and '1pt' and '1mm', '1in'
      borderStyle: 'solid',

it's works only in pdf viewer but not wotk after save file. PDF without borders

Sergey-lang avatar Feb 15 '24 12:02 Sergey-lang