page break not working in phpdocx library - phpdocx

I am using PHPDocx library.Basically I'm having an issue with page-break Here is my code
$html_body .= 'Lorem Ipsum is simply dummy text of the printing and typesetting industry';$html_body .= 'Lorem Ipsum is simply dummy text of the printing and typesetting industry';
i just want to break page so that both the paragraph appear on different page.
Please help me out.
Thanks

If you are using embedHTML() method the only way you can achieve this, is separating you html code, and adding an use addBreak() method between. Something like this:
require_once '../../../classes/CreateDocx.inc';
$docx = new CreateDocx();
$paragraph1 = '<p>Lorem Ipsum is simply dummy text of the printing and type setting industry</p>';
$paragraph2 = '</br><p>Lorem Ipsum is simply dummy text of the printing and typesetting industry</p>';
$docx->embedHTML($paragraph1);
$docx->addBreak(array('type' => 'page'));
$docx->embedHTML($paragraph2);
$docx->createDocx('example_embedHTML_1');

Related

vue-i18n: component interpolation with html tags

i'm using component interpolation as described here but also have some html tags in my translation string for formatting purposes. how should i deal with this?
<i18n
path="description"
tag="p"
:places="{ value1, value2, routerLink }"
/>
the corresponding key in my .yml file look like:
description: Lorem ipsum <nobr><strong>{value1} %</strong></nobr> some more text <nobr><strong>{value2} %</strong></nobr> and some more text. Go to {routerLink} for more info.
Try use v-html directive
<i18n
v-html="description"
tag="p"
:places="{ value1, value2, routerLink }"
/>
An alternative is can be use a computed that interprets HTML entities see this

Can one insert a collapsible list in an outlook email?

Is it possible to insert collapsible text in an Outlook email ?
[+] header name
When the reader clicks the [+] he will expand the text.
Tried these methods
Making collapsible text without Java and attaching as text. Imports fine into an outlook email. But expansion doesn't work.
Tried with Outlook VBA. Works fine with the .docm format outside of Outlook in Word. But doesn't work in Outlook.
H Mayan,
This can't be done in Outlook as it does not support the CSS required.
You can implement the practice of progressive enhancement whereby you code a CSS-only solution like this:
#toggle {
display: none;
font-size:14px;
}
#toggle:target {
display: block;
}
#toggle:target + .close {
display: block;
}
.close {
display: none;
}
REVEAL +
<p id="toggle">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
<a href="#" class="close">HIDE -</span>
And then use a media query, usually #media screen and (max-width:480px) to show/hide on supported devices and mso conditional css to give a simple fallback for Outlook.
just another ideea to through your way. What about a macro that creates a table with 2 columns, first column contains a trigger/toggle, second contains the expandable area. When you click on the toggle, the entire row toggles between height = autosize and height = 1 row.

BeautifulSoup get_text() not returning all text

I'm trying to scrape from a forum site that is littered with random silly html gems, and am unable to get everything I need from it. Most of the content scrapes just fine (when the html isn't too ugly) but for the problematic posts, I'm only getting the text from the first tag. Can you help me figure out how to get all the text from the entire post? Thank you!
The HTML for the post looks something like this:
This is all contained in a tag from a
<div class="PostMessageBody">Mike,</div>
<div> </div>
<div>
"lorem ipsum, lorem ipsum"
</div>
<div> </div>
<div>
"lorem ipsum, lorem ipsum"
</div>
</div>
Most of the posts make use of the tag, but every once in a while, this gem pops up instead. When it does, the only part that gets scraped by BS is the first div, and the string "Mike," is the only part that gets scraped, however I am also needing to scrape the "lorem ipsum" content.
I'm using beautifulsoup and requests as follows (this is inside a loop that is reading content and writing rows to file, so I'm trying to extract the relevant pieces of code here):
import requests
import re as regex
from bs4 import BeautifulSoup
url = "http://www.example.com/community/default.aspx?f=35&m=5555555&p=3"
r = requests.get(url)
soup = BeautifulSoup(r.text)
posts = soup.find_all('table', class_='PostBox')
if not posts:
break
for k in posts:
tds = k.find_all('td')
userField = tds[0].get_text()
temp1 = regex.split(userField)
userName = temp1[0]
joinDate, postCount = temp1[-1].split("Total Posts : ")
post = str(tds[3].find('div', class_='PostMessageBody'))
postMessage, postSig = tds[3].find('div', class_='PostMessageBody').get_text(), ""
postMessage = postMessage.encode('ascii','ignore')
postSig = postSig.encode('ascii','ignore')
writer.writerow([site, userName, joinDate, postCount, postMessage, postSig])
Thanks for the help!

Getting inner tag text whilst using a filter in BeautifulSoup

I have:
... html
<div id="price">$199.00</div>
... html
How do I get the $199.00 text. Using
soup.findAll("div",id="price",text=True)
does not work as I get all the innet text from the whole document.
Find div tag, and use text attribute to get text inside the tag.
>>> from bs4 import BeautifulSoup
>>>
>>> html = '''
... <html>
... <body>
... <div id="price">$199.00</div>
... </body>
... </html>
... '''
>>> soup = BeautifulSoup(html)
>>> soup.find('div', id='price').text
u'$199.00'
You are SO close to make it work.
(1) How to search and locate the tag that you are interested:
Let's take a look at how to use find_all function:
find_all(self, name=None, attrs={}, recursive=True, text=None, limit=None, **kwargs):...
name="div":The name attribute will contains the tag name
attrs={"id":"price"}: The attrs is a dictionary who contains the attribute
recursive: a flag whether dive into its children or not.
text: could be used along with regular expressions to search for tags which contains certain text
limit: is a flag to choose how many you want to return limit=1 make find_all the same as find
In your case, here are a list of commands to locate the tags playing with different flags:
>> # in case you have multiple interesting DIVs I am using find_all here
>> html = '''<html><body><div id="price">$199.00</div><div id="price">$205.00</div></body></html>'''
>> soup = BeautifulSoup(html)
>> print soup.find_all(attrs={"id":"price"})
[<div id="price">$199.00</div>, <div id="price">$205.00</div>]
>> # This is a bit funky but sometime using text is extremely helpful
>> # because text is actually what human will see so it is more reliable
>> import re
>> tags = [text.parent for text in soup.find_all(text=re.compile('\$'))]
>> print tags
[<div id="price">$199.00</div>, <div id="price">$205.00</div>]
There are many different ways to locate your elements and you just need to ask yourself, what will be the most reliable way to locate a element.
More Information about BS4 Find, click here.
(2) How to get the text of a tag:
tag.text will return unicode and you can convert to string type by using tag.text.encode('utf-8')
tag.string will also work.

Emmet coding lorem ipsum, not starting with lorem

Well I just started with emmet scripting/coding. So I found out you can easily generate lorem ipsum
div>lorem20
Only problem I am having I am using lots of lorem ipsum and every thing on the page starts with lorem ipsum. I tried to look if there is a way to say i want lorem ipsum but not starting with lorem ipsum and I can't find any answer to this question.
So the question is, can I easily generate lorem ipsum with emmet but don't let it start with lorem ipsum. (I know that I can remove it but that would be a waste of the syntax using
It might be a new version now. But if I try it (in PHPStorm) with
div>lorem5*10
I get
<div>
<div>Lorem ipsum dolor sit amet.</div>
<div>Ea ipsam laboriosam recusandae voluptatibus?</div>
<div>Animi laborum nam quaerat sequi!</div>
<div>Obcaecati quos ratione tempora totam.</div>
<div>Aspernatur porro possimus repellat suscipit?</div>
<div>Harum incidunt ipsam iste vero?</div>
<div>Architecto dolorem magni numquam voluptas?</div>
<div>Porro recusandae totam ut veritatis.</div>
<div>Dolorum earum laudantium magnam maiores.</div>
<div>Non obcaecati sit veritatis voluptatibus.</div>
</div>
Every sentence starts with a different text.
You can create a copy of Lorem Ipsum generator and put it into Extensions folder.
In your copy of generator, update paragraph() function: simply set startWithCommon = false; somewhere at the top of function body.
Even though the solution is needed for PHPstorm, I'd like to post a solution for Sublime Text 3. I haven't found anything on the Internet for this problem:
1. Write a js-File into the extensions location defined in your `Emmet.sublime-settings` File.
(the default path is ~/emmet, which is a folder called "emmet" in your OS-user directory)
2. Copy the following code into the file and save:
.
emmet
.require('lorem')
.addLang('en', ['all', 'the', 'words', 'you', 'want', 'to', 'use']);
You could also define another language, but I haven't found out, how to change this setting. Maybe it's the Editor's language. This will simply overwrite the default language.