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

text not wrap correctly

Open DrMisQ opened this issue 3 years ago • 16 comments

I'm using Arabic font for my pdf, everything works fine except when I have long text that needs to be wrapped, it wrap incorrectly (from down to up) instead of wrapping from up to down, any idea how can I fix the problem?

Note: English text wrap correctly without any problem, only Arabic wrap in reverse lines

Screen Shot 2021-07-06 at 3 10 25 AM

DrMisQ avatar Jul 06 '21 00:07 DrMisQ

Hey @DrMisQ which font family did you use to render arabic text. Tried a few fonts and none seem to work for me

GlennFernandes avatar Jul 07 '21 12:07 GlennFernandes

i have same problem with wrapping text @GlennFernandes what is your font?

Shabnam-Veranloo avatar Jul 07 '21 13:07 Shabnam-Veranloo

Helvetica gave me garbled text as mentioned here https://github.com/diegomura/react-pdf/issues/732 . Roboto and D-Din gave me empty squares. I finally switched to Lateef . Its a google font, so downloaded the ttf file and registered it

GlennFernandes avatar Jul 07 '21 13:07 GlennFernandes

@GlennFernandes thanks to your response i try Lateef and other font but still i have this problem :((

Shabnam-Veranloo avatar Jul 07 '21 13:07 Shabnam-Veranloo

This seems to be related to RTL support (https://github.com/diegomura/react-pdf/issues/747). This is not something we support right now, although I made some progress already.

diegomura avatar Jul 25 '21 21:07 diegomura

++RTL!

buskerone avatar Aug 25 '21 20:08 buskerone

any updates?

ahmadf16 avatar Nov 23 '21 09:11 ahmadf16

updates ?

klay964 avatar Nov 30 '21 05:11 klay964

Any updates?

fr60 avatar Dec 07 '21 14:12 fr60

any Updates or suggestion to solve this problem?

DrMisQ avatar Jan 06 '22 00:01 DrMisQ

Any Updates related to RTL issue? @diegomura . I am stuck because of this problem. I really appreciate your help regarding this issue

bondai-fahad avatar Jan 29 '22 18:01 bondai-fahad

Any solutions??

sadam-hussien avatar Feb 09 '22 10:02 sadam-hussien

Any updates pls?

kassah-mahmoud avatar Feb 16 '22 08:02 kassah-mahmoud

no,but iam create function which return the array of number of words in array to made each array of words inside Text tag.[image: Capture.PNG]

On Wed, Feb 16, 2022 at 10:59 AM Mahmoud Kassah @.***> wrote:

Any updates pls?

— Reply to this email directly, view it on GitHub https://github.com/diegomura/react-pdf/issues/1394#issuecomment-1041260426, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOEYEN2IQXLTANAWXTE5E63U3NROXANCNFSM473QUOFA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you commented.Message ID: @.***>

sadam-hussien avatar Feb 17 '22 22:02 sadam-hussien

I'm using Arabic font for my pdf, everything works fine except when I have long text that needs to be wrapped, it wrap incorrectly (from down to up) instead of wrapping from up to down, any idea how can I fix the problem?

Note: English text wrap correctly without any problem, only Arabic wrap in reverse lines

Screen Shot 2021-07-06 at 3 10 25 AM

Any updates? has anyone found a solution?

Hi, I found a way Test the code below, it might work for you too.

Store the list of words in the array

const [splitedText, setSplitedText] = useState([])
useEffect(()=>{
   const _splitedText = text.split(" ");
   setSplitedText(_splitedText)
},[])

now we need styles to show the all word correctly inside a <View> tag

const styles = StyleSheet.create({
  flexRowReverse: {
      flexDirection: "row-reverse"
  },
  flexWrap: {
      flexWrap: "wrap"
  },
  ml1: {
      marginLeft: "2pt"
  }
})

then map splitedText inside View tag

<View style={[styles.flexRowReverse, styles.flexWrap]}>
      {
          splitedText.map((word, idx) => {
              return (
                <Text style={styles.ml1} key={idx}>
                  {word}
                </Text>
              );
          })
      }
</View>

X3rom-S avatar Jun 29 '22 15:06 X3rom-S

Thank you ❤

في الأربعاء، ٢٩ يونيو ٢٠٢٢ ٥:٥١ م Sina @.***> كتب:

I'm using Arabic font for my pdf, everything works fine except when I have long text that needs to be wrapped, it wrap incorrectly (from down to up) instead of wrapping from up to down, any idea how can I fix the problem?

Note: English text wrap correctly without any problem, only Arabic wrap in reverse lines [image: Screen Shot 2021-07-06 at 3 10 25 AM] https://user-images.githubusercontent.com/37986642/124525801-42b28600-de09-11eb-9945-b6717f58686e.png

Any updates? has anyone found a solution?

Hi, I found a way Test the code below, it might work for you too.

Store the list of words in the array

const [splitedText, setSplitedText] = useState([]) useEffect(()=>{ const _splitedText = text.split(" "); setSplitedText(_splitedText) },[])

now we need styles to show the all word correctly inside a tag

const styles = StyleSheet.create({ flexRowReverse: { flexDirection: "row-reverse" }, flexWrap: { flexWrap: "wrap" }, ml1: { marginLeft: "2pt" } })

then map splitedText inside View tag

<View style={[styles.flexRowReverse, styles.flexWrap]}> { splitedText.map((word, idx) => { return ( <Text style={styles.ml1} key={idx}> {word} </Text> ); }) } </View>

— Reply to this email directly, view it on GitHub https://github.com/diegomura/react-pdf/issues/1394#issuecomment-1170157982, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOEYENZYEALP3GPMYDHGBOLVRRWGRANCNFSM473QUOFA . You are receiving this because you commented.Message ID: @.***>

sadam-hussien avatar Jun 30 '22 15:06 sadam-hussien

const [splitedText, setSplitedText] = useState([])
useEffect(()=>{
   const _splitedText = text.split(" ");
   setSplitedText(_splitedText)
},[])

This can be a regular simple const splitedText = text.split(" "); (:

  • without useState and without useEffect (https://beta.reactjs.org/learn/you-might-not-need-an-effect)

It doesn't need to be a state, even if there are many renders, it's a realy easy proccess to do every render it's not worth a state (:

shanike avatar May 02 '23 14:05 shanike

Notice that if you had textAlign: "center", using @X3rom-S 's workaround you need to change it to justifyContent: "center" on the View

shanike avatar May 02 '23 14:05 shanike

RTL support ?

canimnazli avatar Sep 28 '23 11:09 canimnazli

I need rtl

abolfazl-zare avatar Nov 05 '23 13:11 abolfazl-zare

Splitting the words works but makes loading the document TOO SLOW since it has to load a Text component for each word.

Please someone add the feature to support RTL. It is important for so many people.

dashty94 avatar Nov 06 '23 11:11 dashty94