Page 1 of 2
Does RevPrintText Support A Page Break?
Posted: Sat Dec 19, 2020 7:45 pm
by TerryL
Merry Christmas. I'm making a report using revPrintText but can't force a page break other than an exact number of returns. Print break works with printing cards so I tried variations of <%print break%> and <%break%> added to the text but no luck. There is an html tag <p style="page-break-before: always"> but not sure how to use it. Does revPrintText support a page break? Terry
Re: Does RevPrintText Support A Page Break?
Posted: Sat Dec 19, 2020 9:50 pm
by hpsh
as far I get, it is a constant you can put in the text called formfeed that will force a page break
assume you have the text like you want in a string called mytext you should be able to just write it like this
put formfeed after mytext
sadly I cannot test it, because my old wreck of a printer, no longer will connect to my computers
merry Xmas
HPSH
Re: Does RevPrintText Support A Page Break?
Posted: Sun Dec 20, 2020 12:22 am
by dunbarx
Hi.
I think HPSH may be on to something. I cannot test it right now, but maybe you can. The "formFeed" constant is equivalent to ASCII 12. Try printing a relatively short body of text, but include that char somewhere in the middle of it. If you get two pages of output, you are golden.
Craig
Re: Does RevPrintText Support A Page Break?
Posted: Sun Dec 20, 2020 1:55 am
by hpsh
you are correct Craig, formfeed is ASCII 12 according to the dictionary of LiveCode
I know I have done it in Borland c version 2 on my old XT computer, but did not remember what the code was, is some time ago LOL
HPSH
Re: Does RevPrintText Support A Page Break?
Posted: Sun Dec 20, 2020 3:09 am
by dunbarx
But does it actually work?
Craig
Re: Does RevPrintText Support A Page Break?
Posted: Sun Dec 20, 2020 4:43 am
by hpsh
hi Craig
actually, nope, it doesn´t did test it by sending the print to pdf, and seem it just translated it to carriage return?
on the other hand, this
Code: Select all
repeat 3 times
RevPrintText "Hello World"
end repeat
creates 3 pages with a single line of "hello world"
Re: Does RevPrintText Support A Page Break?
Posted: Sun Dec 20, 2020 5:22 am
by dunbarx
creates 3 pages with a single line of "hello world"
Um, er, come again?
Craig
Re: Does RevPrintText Support A Page Break?
Posted: Sun Dec 20, 2020 9:08 am
by hpsh
hi Craig, what I mean is that it look at what you send to RevPrintText, as a single print job, and it will eject the page after a print job.
pretty sure this has a billion solutions but doesn't get why this formfeed thingy doesn't work? make no sense according to the help function for me.
Re: Does RevPrintText Support A Page Break?
Posted: Sun Dec 20, 2020 4:53 pm
by dunbarx
Ah. I see. Yes, the way you wrote it, three separate print jobs were created.
But within a single job how does the system "know" to start a new page? It does so automatically when it "sees" that the current print job will not fit, and does not need a special character embedded in the text to do so. If you look at the print dialog, you can see that the text has already been separated into printable pages, depending on the length of the text, before you actually click the "print" button.
There has to be a way to force a page break even if the current text will fit on the current page.
Anyone Know?
Craig
Re: Does RevPrintText Support A Page Break?
Posted: Sun Dec 20, 2020 5:13 pm
by richmond62
Erm . . .
-
-
And, Frankly, put your text into a field and then use
revPrintField.
You may find life suddenly getting easier.
But, on the other hand if this:
Print break works with printing cards
means you are trying to print CARDS, why not consider something else?
Digging around in the Dictionary entry for revPrintText (always a good idea to read right down to the end

) I found this:
"To show the standard print dialog box, use the revShowPrintDialog command before the
revPrintText command."
Yes, I know that's a pain in the bum because it's not entirely automatic.

Re: Does RevPrintText Support A Page Break?
Posted: Sun Dec 20, 2020 7:42 pm
by jacque
The command should be (no quotes)
This forces a page break, but I think it only works when the handler is in complete control of the print process. It is not limited to cards only. The revPrint functions may not be changeable, you may have to go back to the old way before we had the rev print commands.
That requires more scripting. You open printing, calculate the page content, print it, print break, print the next page, print break, close printing. See all the print functions in the dictionary.
The revPrint commands do all this automatically but you have less control.
Re: Does RevPrintText Support A Page Break?
Posted: Sun Dec 20, 2020 8:50 pm
by TerryL
Hi all. Thanks for the suggestions.
1) The "formfeed" in text idea didn't force a page break. Interestingly <%formfeed%> printed an upArrow but no page break.
2) The open/close printing with print break idea didn't work either. LC throws an error on second revPrintText : execution error at line 16 (Chunk: no such object) near "A", char 42.
3) Repeating revPrintText, 1 printjob/pg does work for printing, but creates multiple pdfs.
I had high hopes. A revPrintField and revPrintText page break is a reasonable feature to add.
Could someone volunteer to file a request? Terry
Here's the code I was testing with:
Code: Select all
on mouseUp --print text to pdf
local tReport
put fld "A" into tReport --two lines of text, try to print 1 line/pg
set the printmargins to 36,36,36,36 --L,T,R,B (.25"=18, .5"=36, 1"=72)
set the printPaperOrientation to "portrait" --or landscape
revShowPrintDialog false,false --no printer or page setup dialogs
answer "Please select your" &"e& "Print-To-PDF/XPS" "e&& "program instead of your printer." &cr&cr& the availablePrinters with "OK"
answer printer --choose printer
if result() = "Cancel" then exit to top
----
revPrintText tReport,,,the long name of fld "A" --use fld "A" font/size/style
end mouseUp
Re: Does RevPrintText Support A Page Break?
Posted: Sat Dec 26, 2020 8:03 pm
by TerryL
@ hpsh and Dunbarx. You were right on track with numToChar(12), but the short answer appears: no, LiveCode doesn't support a formfeed char. There is a workaround.
You can force a page break in a .txt plain text file. LiveCode's value(formfeed), ASCII numToChar(12) [v6.7.11-], or Unicode numToCodePoint(U+000C) [v7.0+] produce the page break (formfeed) symbol as a short upArrow. Paste into a compatible text editor. On Windows10: WordPad doesn't show the symbol but it's there and prints two pages. EditPad changes the symbol to a blue horizontal line and prints two pages. NotePad throws an error, replaces the symbol with a "-", and prints 1 page. LiveCode fields show the symbol but ignore it printing one page with print card, revPrintText, or revPrintField.
The text file method: save a report (with forced page breaks) to a .txt file, then open and print with a Win10 text editor like WordPad, NotePad++, EditPad, or LibreOffice Writer.
Code: Select all
on mouseUp --report to .txt with forced page break
local tReport, tPath
answer "Export Report to text file on desktop?" with "Cancel" or "OK" titled "Export Report"
if it = "Cancel" then exit to top
--forced page break: value(formfeed), numToChar(12) [v6.7.11-], or numToCodePoint(U+000C) [v7.0+]
put "Page1" &cr& value(formfeed) & "Page2" into tReport
put specialFolderPath("desktop") &"/"& "MyReport.txt" into tPath
put tReport into url ("file:" & tPath) --text file
set the itemDel to "/"
if result() <> empty then answer "Sorry, there was a problem writing to a text file." with "OK" titled "Error"
else answer "Successfully exported text file" &"e& item -1 of tPath "e&& "to the desktop." with "OK" titled "Export Report"
end mouseUp
Re: Does RevPrintText Support A Page Break?
Posted: Sat Dec 26, 2020 10:21 pm
by jacque
dunbarx wrote: ↑Sun Dec 20, 2020 4:53 pm
There has to be a way to force a page break even if the current text will fit on the current page.
Typically you create a substack specifically for printing, with a field that will contain the text. The field should be placed close to the top and left of the stack edges because printers will add their own margins to the printout, but some testing will allow you to adjust the field placement if necessary. You can set the font properties of the field to anything you want. There are also LC commands that will set printer margins. Once you get it working, you can keep the substack hidden while you print; it doesn't need to be visible. Another advantage is that you can have different fonts, sizes, and styles in the printout just by placing fields on the printing card for headers, footers, captions, etc. It's easiest to make the printing stack the same size in pixels as the paper you will print to so that the layout is WYSIWYG.
Then you place the first text block into the field, open printing, print card, print break. Replace the text with the next block and print the card again. Continue untill all text is printed, then close printing, which sends the whole job to the printer. This works if you already know how much text will fit into the field, or how much text you want to display per page.
If you don't know how much text will fit on a page, get the pageHeights of the field. This tells you how much text will fit on each page. With this method you place all the text into the field at once and scroll it for each print card command. See the pageHeights property in the dictionary for an explanation on how to do it. It's basically just print card, print break, scroll the field, print card, print break, scroll again, etc.
Scripting the printout gives you more control than the built-in rev print commands. If you search for "print" in the dictionary you'll see dozens of ways to the control the printout. It can be a simple or complex as you want. Using scripted printing, I have done complex printouts that include headers, footers, images, graphics, and text that all change on every page. It's more work and requires a lot of test printing (I send to Preview to avoid using paper) but the results are professional.
Re: Does RevPrintText Support A Page Break?
Posted: Sat Dec 26, 2020 11:01 pm
by FourthWorld
LC's flexibility is admirable, where it's needed.
Here, everything revPrintText does is just fine, except that the OP also needs a page break method.
Maybe we can come up with an enhancement to the LC printing library for this?
It's all script, so doable by anyone where with sufficient interest and available time.