christopherdro / react-native-html-to-pdf

Convert html strings to PDF documents using React Native
MIT License
434 stars 264 forks source link

How To Slice a String which Contain HTML tag with it and slice With respect to opening and closing tag #279

Closed birjubhatt closed 1 year ago

birjubhatt commented 2 years ago

I have a html as string(with Tag in it as shown below in p tag ) and I want to slice only contain data but problem is slice method divide the string with html tag and that can't generate required output.

So I Want to slice the String with opening and closing tag of the html and divide the content into section with tags and their styling should not be removed.

My Present function slice with static value with index of interval like slice(0,500), slice(500, 1000) and so on. In doing that I divide the string with their respective styling properties also because of that styling is divide into two parts and for that reason it does not apply on the tag.

<p style="margin: 0px 0px 15px; font-size: 14px;">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, "</p> <h3 style="margin: 15px 0px; padding: 0px; font-size: 14px; color: rgb(0, 0, 0); font-family: &quot;Open Sans&quot;, Arial, sans-serif;">Section 1.10.32 of "de Finibus Bonorum et Malorum", written by Cicero in 45 BC</h3>

I am generating pdf from html in react-native. I want To divide the above html string into different pages so I am using the slice method to divide into sections and then applying page break but it divide the string with respect to tags and style property.

i post this also in stack overflow link is https://stackoverflow.com/questions/73036936/how-to-slice-a-string-which-contain-html-tag-with-it-and-slice-with-respect-to-o

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.