I'm hoping that there are some more options for formatting simple emails formatted as text (not HTML) when using a mailer in a Rails app.
By trial and error, I've found that this markup works in the mailer view (i.e. example_mailer_view.text.erb):
This will be regular text.
==
This text will be formatted in the large, standard HTML Header1 format.
==
The space at the left side of this line will cause it to be smaller text.
>The bracket on the left side of this line will cause it to be indented once.
>>This text is indented twice.
>>This text is indented three times.
_Italicized text_
*This text will be bold.*
Multiple returns...
...between these two lines get compressed into just one blank row.
Is there full documentation of all markup options? Do you know of other markup options that are not listed here? It would be great to have heading2, heading3, etc. Thanks!
Simple text emails are, by definition, simple text. They cannot be formatted. There is no bold simple tyext, nor large simple text, nor italicised simple text. If you see them so, it is because your mail agent is choosing to interpret your plain text emails as if they were written in Markdown; but know that users with other user agents will most likely not see them so. The only way to get rich text emails (i.e. formatted emails) in every email agent (apart from text-only agents such as mutt) is to use an HTML body.
Related
I'd like to add an automatic page break to a libHaru PDF in iOS.
I do have several text fields in the app which contain the user filled data. when i generate the pdf i first measure the expected size of the text-rect going to be created. if it exceeds the remaining space i trigger a hpdf_new_page event and put the text on an new page. i'd like to have this just in part automatically. so if the text exceeds the space on the current page it should split and continue on a new page without me checking or doing anything.
unfortunately i can't find anything like this in the documentation.
Line counting using fgets() may help. When your print program opens a file to print, each line can be copied to the pdf file and checked for a form feed character
or
if the line count has reached a limit.
Another possible solution is to use a character count limit with "while(getc(file) != EOF)".
This link uses libharu to print basic text files with PCL commands to change the font.
https://github.com/DaDaDadeo/GetCycle/blob/master/pcl_to_pdf.c
The form feed character '\f' (ascii 12) and 61 lines will trigger a new page. There are other conditions in the program to restrict a new page but the general idea is illustrated.
The results are the same as a printer using telnet raw 9100 protocol. The pcl commands are limited to just a couple of font changes so it is not too complicated.
Libharu is rather low-level library, and I could not even expect of appearing such automatic page splitting in newer versions due to number of reasons. Hereafter I state two of them:
There is no good, preferred strategy how to place remaining of non-fitting text on the next page. In some cases it could be even impossible at all.
There is no good, preferred strategy for text splitting.
Why?
Consider your font is extremely large, and just one letter (for instance, wide one as "W") does not fit into the page. Where we are supposed to place it? On the next page? Ok, we add new page... oops, it does not fit this page too - as soon as all our pages have the same size. Dead-end without any good, straightforward way out.
In other words, there should be a user-defined strategy for these cases. Almosy every naive implementation will have such a corner cases.
libharu does not know where it should split your text automatically. It does not know hyphenation rules of your language, it does not know whether it should respect spaces or not (wrap whole words only or not), and so on. It's up to you to specify these rules.
So, you should call HPDF_Font_MeasureText for some part of your text string, decide if it fits into your page (excluding margins, footers - which also out of libharu's internal knowledge) and render it. And note that there is no simple formula for text size depending on its length. String "wwww" is more than twice wider than "iiii", of course if your font is not mono-spaced.
I'm writing the text version of a Rails mailer email (an example.text.erb file) and I'd like it to display for the recipient with clean breaks after an arbitrary number of characters, say 70. Sublime lets you select a number of paragraphs and break them at the ruler or a fixed char point using Edit >> Wrap >> "Wrap Paragraph at Ruler" but this also includes all the erb code that I've put in (so it's counting the <%= link_to example... %> and not the actual link text output).
This makes the resulting text email that gets sent to the recipient uneven and disjointed because the erb code takes up a number of characters unrelated to the length of its text output.
What's the best way to wrap the text in a *.text.erb file with hard line breaks AFTER the erb has run?
Thanks!
It sounds like you're looking to process the text after it's run through ERB. My initial thought is you could 1) create a custom template handler or 2) hack something together to run a file through ERB and then work on the resulting text.
Also of note is the TextHelper#word wrap method which may be of help to you:
http://api.rubyonrails.org/classes/ActionView/Helpers/TextHelper.html#method-i-word_wrap
I would like to build invoice text base to have following format:
https://gist.github.com/samnang/9d35a8622af5779a9228
But when I try to render as text format from my controller, then I find out it's very to control how it look because those text are dynamic like company name could be short or long. I don't want to other texts move position depend on something else because those format will be sent to print company to match print out paper.
Is there any examples, gems, or suggestions how to build invoice text base?
You are going to have to truncate some fields to fit into the defined tab area. If you allocate 20 characters of description data, then you need to only allow 20 characters on the output your_text[0..19]
I think working in text for this type of work is going to be overly complex, and you should look at converting the output to pdf to have more control. Take a look at https://github.com/prawnpdf/prawn
Using Crystal Reports 11, I want to report on the number of characters within a memo field. The problem is that it is feeding through HTML from the System.
I want to remove all text that is within "<" and ">" and am having some problems doing this.
I guessed that my best way of doing this was a Replace formula, but it only seems to allow specific characters or group of characters to be replaced. I tried the following:
Replace ({Field_Name},"","")
Basically I want to be able to remove all text within the "<>" symbols to then be able to view the remaining data.
I know that there is an option to format the field with HTML which will then display only the text, but when a count is done on the field, it still includes the HTML text in the character count.
Any help wouldbe great.
Thanks
Dave
After struggling for # a wk. to try to remove HTML from my emails, I decided to go into system restore and went back to a date when I thought this had happened (a wk) and voila - gone! Nada! No HTML! Problem solved so easily.
Here's what I have:
Quarter Sheet Flyer (4 per page) as a PSD or JPG
Text file with one entry of text per line.
What I want to do:
Print out 100 flyers (on 25 pieces of paper)
Somehow automate the process of adding the text to the image, either via some scripting language or a Photoshop automated task. Then format the pages to print, either to generate a 25 page PDF file or generate four at a time and send them to the printer page by page.
Anyone have any experience with something like this or have any recommendations on how I should go about doing this?
Thanks for your help!
You can use Microsoft Word automation to generate a word file with the correct text and image, and then just print it.
This would be one of the simpler solutions, you can implement the entire thing as a word macro (VBA).
A more complex solution would be to use VB6 or .net to print the text and the image into the form and then print the form.
You can write a script that will generate an html page with the image and the text, and then print out the html using a browser.