joshy / striprtf

Stripping rtf to plain old text
http://striprtf.dev
BSD 3-Clause "New" or "Revised" License
92 stars 27 forks source link

Fail pop from empty list #3

Closed gazzola closed 5 years ago

gazzola commented 5 years ago

Hi, I'm have error my code using striprtf Can someone help me?

~\AppData\Local\Continuum\anaconda3\lib\site-packages\striprtf\striprtf.py in rtf_to_text(text)
     86             elif brace == '}':
     87                 # Pop state
---> 88                 ucskip,ignorable = stack.pop()
     89         elif char: # \x (not a letter)
     90             curskip = 0

IndexError: pop from empty list
joshy commented 5 years ago

Hi, can you provide the rtf file?

gazzola commented 5 years ago

RTF file is:

{\rtf1\ansi\ansicpg1252\uc1\deff1{\fonttbl
{\f0\fnil\fcharset0\fprq2 Arial;}
{\f1\froman\fcharset0\fprq2 Cambria;}
{\f2\fswiss\fcharset0\fprq2 Arial;}
{\f3\froman\fcharset2\fprq2 Symbol;}}
{\colortbl;\red0\green0\blue0;}
{\stylesheet{\s0\itap0\widctlpar\f1\fs24 Normal;}{\*\cs10\additive Default Paragraph Font;}{\s16\itap0\nowidctlpar\f0\fs24 [Normal];}{\s17\itap0\widctlpar\sa120\f1\fs24\sbasedon0 Body Text;}}
{\*\generator TX_RTF32 18.0.541.501;}
\paperw11905\paperh15307\margl1440\margt1440\margr1440\margb1440\deftab1134\widowctrl\lytexcttp\formshade
{\*\background{\shp{\*\shpinst\shpleft0\shptop0\shpright0\shpbottom0\shpfhdr0\shpbxmargin\shpbxignore\shpbymargin\shpbyignore\shpwr0\shpwrk0\shpfblwtxt1\shplid1025{\sp{\sn shapeType}{\sv 1}}{\sp{\sn fFlipH}{\sv 0}}{\sp{\sn fFlipV}{\sv 0}}{\sp{\sn fillColor}{\sv 16777215}}{\sp{\sn fFilled}{\sv 1}}{\sp{\sn lineWidth}{\sv 0}}{\sp{\sn fLine}{\sv 0}}{\sp{\sn fBackground}{\sv 1}}{\sp{\sn fLayoutInCell}{\sv 1}}}}}\sectd
\headery720\footery720\pgwsxn11905\pghsxn15307\marglsxn1440\margtsxn1440\margrsxn1440\margbsxn1440\pgbrdropt32\pard\s16\itap0\nowidctlpar\tx567\tx1134\tx1701\tx2268\tx2835\tx3402\tx3969\tx4536\tx5103\tx5670\tx6237\tx6804\tx7371\plain\f2\fs18\cf1 A\tab produto de RTU de bexiga\par B\tab uretra  prost\loch\f2\hich\f2\'e1tica\par C\tab assoalho vesical\par D\tab base da les\'e3o de assoalho\par\plain\f2\fs18\cf1}}
joshy commented 5 years ago

Hi, I uploaded a new version https://github.com/joshy/striprtf/releases/tag/v0.0.5 which should fix it. I am not 100% sure how this could happen. What program created the rtf? Please try and close it if it fixes your issue.

joshy commented 5 years ago

Closing because of inactivity.