Discussion:
V13 Printing advice: Generating one document with multiple variable-size objects
(too old to reply)
David Adams
2014-01-09 03:14:54 UTC
Permalink
It's rare that I print anything out of 4D. So rare that the V13 printing
feature set is almost completely novel to me. So far, I like what I've
found:

* Print object is very handy.

* PRINT RECORD does just fine.

* SET PRINT OPTION to PDF on OS X works beautifully.

I need to collate information from a range of fields and tables and produce
a single document. What's hanging me up is that I've got variable-length
text fields and, potentially, list boxes with variable numbers of rows.
I've done a bit of experimenting, and it looks like if I've got a "print
variable frame" text field that static values below it don't print when
using PRINT RECORD. The docs say that there is no way to have
dynamic-height variables using Print form.

So, given me somewhat disjointed description, can anyone offer some
suggestions on printing strategies for 4D V13, OS X only where you need to
assemble a lot of variable sized details somewhat neatly? (If I could
reliably print form a WebArea, that would be a though but I've not gotten
that working in the past.)

If it helps to make it clearer, the goal is to pull together a summary of
everything a student applying to a graduate program has submitted in
summary form. So, bits are free-text answers ("what have you been doing
since undergrad", "what are your goals"), some are fixed-length (name,
email, phone, etc.), some are tabular (test and degree dates, scores, and
percentiles) and some are tabular + variable in length (different
collections of documents and test results.) That's my current problem, but
it's easy to imagine a similar situation with patient data, customer data,
equipment purchase history and service records, etc. Pretty much...anything
I guess.

Thanks in advance for suggestions.

**********************************************************************
4D v13 is available now - with more than 200 new features to make
your applications richer and faster
http://www.4d.com/products/new.html

4D Internet Users Group (4D iNUG)
FAQ: http://lists.4d.com/faqnug.html
Archive: http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub: mailto:4D_Tech-Unsubscribe-d2/MUvgItPNWk0Htik3J/***@public.gmane.org
**********************************************************************
Julio Carneiro
2014-01-09 03:30:38 UTC
Permalink
what about generating the report as HTML and use an external tool to convert it to pdf?
you can even use PHT to generate the report from a template.

hth
julio
Post by David Adams
It's rare that I print anything out of 4D. So rare that the V13 printing
feature set is almost completely novel to me. So far, I like what I've
* Print object is very handy.
* PRINT RECORD does just fine.
* SET PRINT OPTION to PDF on OS X works beautifully.
I need to collate information from a range of fields and tables and produce
a single document. What's hanging me up is that I've got variable-length
text fields and, potentially, list boxes with variable numbers of rows.
I've done a bit of experimenting, and it looks like if I've got a "print
variable frame" text field that static values below it don't print when
using PRINT RECORD. The docs say that there is no way to have
dynamic-height variables using Print form.
So, given me somewhat disjointed description, can anyone offer some
suggestions on printing strategies for 4D V13, OS X only where you need to
assemble a lot of variable sized details somewhat neatly? (If I could
reliably print form a WebArea, that would be a though but I've not gotten
that working in the past.)
If it helps to make it clearer, the goal is to pull together a summary of
everything a student applying to a graduate program has submitted in
summary form. So, bits are free-text answers ("what have you been doing
since undergrad", "what are your goals"), some are fixed-length (name,
email, phone, etc.), some are tabular (test and degree dates, scores, and
percentiles) and some are tabular + variable in length (different
collections of documents and test results.) That's my current problem, but
it's easy to imagine a similar situation with patient data, customer data,
equipment purchase history and service records, etc. Pretty much...anything
I guess.
Thanks in advance for suggestions.
**********************************************************************
4D v13 is available now - with more than 200 new features to make
your applications richer and faster
http://www.4d.com/products/new.html
4D Internet Users Group (4D iNUG)
FAQ: http://lists.4d.com/faqnug.html
Archive: http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
**********************************************************************
**********************************************************************
4D v13 is available now - with more than 200 new features to make
your applications richer and faster
http://www.4d.com/products/new.html

4D Internet Users Group (4D iNUG)
FAQ: http://lists.4d.com/faqnug.html
Archive: http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub: mailto:4D_Tech-Unsubscribe-d2/MUvgItPNWk0Htik3J/***@public.gmane.org
**********************************************************************
David Adams
2014-01-09 03:38:49 UTC
Permalink
Post by Julio Carneiro
what about generating the report as HTML and use an external tool to convert it to pdf?
you can even use PHT to generate the report from a template.
That's reasonably appealing. I've looked in that directly a bit before and
not found a tool for OS X that I could run locally. Do you know of such a
tool?

**********************************************************************
4D v13 is available now - with more than 200 new features to make
your applications richer and faster
http://www.4d.com/products/new.html

4D Internet Users Group (4D iNUG)
FAQ: http://lists.4d.com/faqnug.html
Archive: http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub: mailto:4D_Tech-Unsubscribe-d2/MUvgItPNWk0Htik3J/***@public.gmane.org
**********************************************************************
Julio Carneiro
2014-01-09 14:14:01 UTC
Permalink
wkpdf? http://code.google.com/p/wkhtmltopdf/
Post by Julio Carneiro
Post by Julio Carneiro
what about generating the report as HTML and use an external tool to
convert it to pdf?
Post by Julio Carneiro
you can even use PHT to generate the report from a template.
That's reasonably appealing. I've looked in that directly a bit before and
not found a tool for OS X that I could run locally. Do you know of such a
tool?
**********************************************************************
4D v13 is available now - with more than 200 new features to make
your applications richer and faster
http://www.4d.com/products/new.html

4D Internet Users Group (4D iNUG)
FAQ: http://lists.4d.com/faqnug.html
Archive: http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub: mailto:4D_Tech-Unsubscribe-d2/MUvgItPNWk0Htik3J/***@public.gmane.org
**********************************************************************
miyako
2014-01-09 14:38:23 UTC
Permalink
as a proof- of concept,

I've posted a wkhtmltopdf plugin:

https://github.com/miyako/4d-plugin-html-converter

but as the author of wkhtmltopdf admits, pages breaks is one of is (few) weaknesses.

miyako
Post by Julio Carneiro
wkpdf? http://code.google.com/p/wkhtmltopdf/
**********************************************************************
4D v13 is available now - with more than 200 new features to make
your applications richer and faster
http://www.4d.com/products/new.html

4D Internet Users Group (4D iNUG)
FAQ: http://lists.4d.com/faqnug.html
Archive: http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub: mailto:4D_Tech-Unsubscribe-d2/MUvgItPNWk0Htik3J/***@public.gmane.org
**********************************************************************
Lee Hinde
2014-01-09 23:02:52 UTC
Permalink
Post by Julio Carneiro
Post by Julio Carneiro
what about generating the report as HTML and use an external tool to
convert it to pdf?
Post by Julio Carneiro
you can even use PHT to generate the report from a template.
That's reasonably appealing. I've looked in that directly a bit before and
not found a tool for OS X that I could run locally. Do you know of such a
tool?
https://github.com/Kozea/WeasyPrint



**********************************************************************
4D v13 is available now - with more than 200 new features to make
your applications richer and faster
http://www.4d.com/products/new.html

4D Internet Users Group (4D iNUG)
FAQ: http://lists.4d.com/faqnug.html
Archive: http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub: mailto:4D_Tech-Unsubscribe-d2/MUvgItPNWk0Htik3J/***@public.gmane.org
**********************************************************************
David Adams
2014-01-10 00:40:14 UTC
Permalink
Thanks Lee! I've now got three different HTML-->PDF tools to try. This is
good news for me as when I've gone down that road in the past I ran out of
fuel before I got anywhere. Then night fell and I could hear the wolves
howling....
Post by Lee Hinde
Post by Julio Carneiro
Post by Julio Carneiro
what about generating the report as HTML and use an external tool to
convert it to pdf?
Post by Julio Carneiro
you can even use PHT to generate the report from a template.
That's reasonably appealing. I've looked in that directly a bit before
and
Post by Julio Carneiro
not found a tool for OS X that I could run locally. Do you know of such a
tool?
https://github.com/Kozea/WeasyPrint
**********************************************************************
4D v13 is available now - with more than 200 new features to make
your applications richer and faster
http://www.4d.com/products/new.html
4D Internet Users Group (4D iNUG)
FAQ: http://lists.4d.com/faqnug.html
Archive: http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
**********************************************************************
**********************************************************************
4D v13 is available now - with more than 200 new features to make
your applications richer and faster
http://www.4d.com/products/new.html

4D Internet Users Group (4D iNUG)
FAQ: http://lists.4d.com/faqnug.html
Archive: http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub: mailto:4D_Tech-Unsubscribe-d2/MUvgItPNWk0Htik3J/***@public.gmane.org
**********************************************************************
Kirk Brooks
2014-01-09 04:37:33 UTC
Permalink
Hi David,

Some thoughts about this. If you already have code that assembles the data
for printing with the web area just write the html to a file and open it
for printing in your web browser instead of web area.

Another thing you can do is use PRINT FORM and OBJECT BEST HEIGHT.
Theoretically you could do all your printing using a single form this way.
Of course with this approach you are having to do all the work to get the
page break right and so forth (meaning if you have large blocks of text
that may span a page break you'll have to manage that yourself) but it's
pretty cool for being able to expand/shrink fields or variables on the fly.

Another approach I used in the past is to create a report table where you
put each bit of text into a field and print using PRINT SELECTION. Then 4D
manages the page breaks for you.
--
Kirk Brooks
San Francisco, CA
=======================

**********************************************************************
4D v13 is available now - with more than 200 new features to make
your applications richer and faster
http://www.4d.com/products/new.html

4D Internet Users Group (4D iNUG)
FAQ: http://lists.4d.com/faqnug.html
Archive: http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub: mailto:4D_Tech-Unsubscribe-d2/MUvgItPNWk0Htik3J/***@public.gmane.org
**********************************************************************
miyako
2014-01-09 14:42:24 UTC
Permalink
the best offer is definitely
Print object+OBJECT BEST HEIGHT+OBJECT GET COORDINATES.

you can even combine it with OPEN PRINTING JOB ("") to 'print' off-line,
to calculate the final page count, for example.

miyako
Post by Kirk Brooks
Another thing you can do is use PRINT FORM and OBJECT BEST HEIGHT.
Theoretically you could do all your printing using a single form this way.
**********************************************************************
4D v13 is available now - with more than 200 new features to make
your applications richer and faster
http://www.4d.com/products/new.html

4D Internet Users Group (4D iNUG)
FAQ: http://lists.4d.com/faqnug.html
Archive: http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub: mailto:4D_Tech-Unsubscribe-d2/MUvgItPNWk0Htik3J/***@public.gmane.org
**********************************************************************
Chip Scheide
2014-01-09 06:13:41 UTC
Permalink
i have not tried printing listboxes -
however, using print selection
you can get the variable frame object to size as you need.

you can create a record in a utility table, build everything as needed
make that one record (or however many you may need) the current selection and print
Post by David Adams
I need to collate information from a range of fields and tables and produce
a single document. What's hanging me up is that I've got variable-length
text fields and, potentially, list boxes with variable numbers of rows.
I've done a bit of experimenting, and it looks like if I've got a "print
variable frame" text field that static values below it don't print when
using PRINT RECORD. The docs say that there is no way to have
dynamic-height variables using Print form.
**********************************************************************
4D v13 is available now - with more than 200 new features to make
your applications richer and faster
http://www.4d.com/products/new.html

4D Internet Users Group (4D iNUG)
FAQ: http://lists.4d.com/faqnug.html
Archive: http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub: mailto:4D_Tech-Unsubscribe-d2/MUvgItPNWk0Htik3J/***@public.gmane.org
**********************************************************************
Bernd Fröhlich
2014-01-09 08:12:01 UTC
Permalink
Post by David Adams
So, given me somewhat disjointed description, can anyone offer some
suggestions on printing strategies for 4D V13, OS X only where you need to
assemble a lot of variable sized details somewhat neatly?
Since quite some time I do all of this kind of assembling data and printing with 4D Write.
It can get a bit tricky with formatting multi-line text side by side but that´s not a very big problem.
I´m still on V12 so I use the hmFree Plugin from Heubach Media to do the calculations for line-breaks. V13 has (at last) a native command to do that.
So once you have set up some basic tool-methods it becomes pretty easy to create very flexible reports.
Plus I like the fact that there is no need to fiddle with multiple layouts. All that´s needed for a report is in one method.

Greetings from Germany,
Bernd Fröhlich

P.S.: I know, some people say that 4D Write is dead. If that´s really the case I´m done with 4D because 4D Write (while admittedly a bit old) is a great tool to have inside a database and one of the main resons to use 4D.

**********************************************************************
4D v13 is available now - with more than 200 new features to make
your applications richer and faster
http://www.4d.com/products/new.html

4D Internet Users Group (4D iNUG)
FAQ: http://lists.4d.com/faqnug.html
Archive: http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub: mailto:4D_Tech-Unsubscribe-d2/MUvgItPNWk0Htik3J/***@public.gmane.org
**********************************************************************
Reiner Kief
2014-01-09 08:23:09 UTC
Permalink
No, it's not dead yet. It's complete functionality will be replaced by the more and more growing capabilities of multistyle textfields.
Until then, 4D Write will be with us. That is what I have been told from 4D officials during the german DevCon 2013. I use 4D Write also and learned to love it.

Wakanda needs a kind of 4D Write!
Post by Bernd Fröhlich
P.S.: I know, some people say that 4D Write is dead. If that´s really the case I´m done with 4D because 4D Write (while admittedly a bit old) is a great tool to have inside a database and one of the main resons to use 4D.
--
Reiner Kief
Software & IT-Consulting
Weinbergstrasse 45
63853 Moemlingen
Germany

www.kief-online.de

Member of the german developer network www.die4dwerkstatt.de




**********************************************************************
4D v13 is available now - with more than 200 new features to make
your applications richer and faster
http://www.4d.com/products/new.html

4D Internet Users Group (4D iNUG)
FAQ: http://lists.4d.com/faqnug.html
Archive: http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub: mailto:4D_Tech-Unsubscribe-d2/MUvgItPNWk0Htik3J/***@public.gmane.org
**********************************************************************
Peter Jakobsson
2014-01-09 08:48:19 UTC
Permalink
Post by David Adams
I need to collate information from a range of fields and tables and produce
a single document
Isn't Canvas what you need ? Just slap everything onto a board positioned to the exact pixel and size where you want it as if you were using keynote.

Isn't Canvas to 4D what CSS is to HTML ?

http://www.pluggers.nl/products/canvas-plugin/

I've not used it myself but have always thought the possibilities of Canvas look amazing.

Peter


**********************************************************************
4D v13 is available now - with more than 200 new features to make
your applications richer and faster
http://www.4d.com/products/new.html

4D Internet Users Group (4D iNUG)
FAQ: http://lists.4d.com/faqnug.html
Archive: http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub: mailto:4D_Tech-Unsubscribe-d2/MUvgItPNWk0Htik3J/***@public.gmane.org
**********************************************************************
Kirk Brooks
2014-01-09 18:21:26 UTC
Permalink
Well CSS is free and ubiquitous; Canvas isn't.
Post by Peter Jakobsson
Isn't Canvas to 4D what CSS is to HTML ?
--
Kirk Brooks
San Francisco, CA
=======================

**********************************************************************
4D v13 is available now - with more than 200 new features to make
your applications richer and faster
http://www.4d.com/products/new.html

4D Internet Users Group (4D iNUG)
FAQ: http://lists.4d.com/faqnug.html
Archive: http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub: mailto:4D_Tech-Unsubscribe-d2/MUvgItPNWk0Htik3J/***@public.gmane.org
**********************************************************************
David Adams
2014-01-09 22:25:28 UTC
Permalink
Wow. I'm impressed with both the range and quality of the responses this
question generated.

Thank you all!

I've also now going to give up on my long-standing reluctance to use 4D's
printing features. It's kind of fun in V13.

For today, I'm on a short deadline so I'll try to bang out something that
works. Over time, I want to go back and try out each of the major ideas
proposed here and, I'm sure, some of the variants.

**********************************************************************
4D v13 is available now - with more than 200 new features to make
your applications richer and faster
http://www.4d.com/products/new.html

4D Internet Users Group (4D iNUG)
FAQ: http://lists.4d.com/faqnug.html
Archive: http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub: mailto:4D_Tech-Unsubscribe-d2/MUvgItPNWk0Htik3J/***@public.gmane.org
**********************************************************************
Timothy Penner
2014-01-10 00:19:46 UTC
Permalink
Post by Peter Jakobsson
Isn't Canvas to 4D what CSS is to HTML ?
I was thinking style sheets are to 4D what CSS is to HTML...
David Adams
2014-01-10 00:40:57 UTC
Permalink
Post by Timothy Penner
I was thinking style sheets are to 4D what CSS is to HTML...
Apples and Orangutans.

**********************************************************************
4D v13 is available now - with more than 200 new features to make
your applications richer and faster
http://www.4d.com/products/new.html

4D Internet Users Group (4D iNUG)
FAQ: http://lists.4d.com/faqnug.html
Archive: http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub: mailto:4D_Tech-Unsubscribe-d2/MUvgItPNWk0Htik3J/***@public.gmane.org
**********************************************************************
David Adams
2014-01-10 02:44:40 UTC
Permalink
Speaking of HTML --> PDF solutions, 4D doesn't have 'offscreen' WebAreas. I
can use an old suggestion of David Dancy's to use a tiny window with a form
or something...I can work around that. So, assuming that's a go, is anyone
using a package that does _not_ require admin install on each individual
workstation?

I haven't yet examined the three packages suggested, although I've
downloaded them...I've been doing other stuff. Given the basically lazy
nature of my question, please only answer if it's off the top of your head.
Or if you're bored. Or far too kind. In any case, I'm looking for something
self-contained that doesn't require installs everywhere.

P.S. In the past, I've managed LEP with small programs stored inside of the
4D folder structure on Windows. This is Mac only, so I'm not sure if that's
an option. Probably not...kind of doesn't fit the security model.

**********************************************************************
4D v13 is available now - with more than 200 new features to make
your applications richer and faster
http://www.4d.com/products/new.html

4D Internet Users Group (4D iNUG)
FAQ: http://lists.4d.com/faqnug.html
Archive: http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub: mailto:4D_Tech-Unsubscribe-d2/MUvgItPNWk0Htik3J/***@public.gmane.org
**********************************************************************
Ortwin Zillgen
2014-01-09 08:55:31 UTC
Permalink
QuickTime Player <http://www.loopinsight.com/2014/01/08/your-macs-built-in-screen-recorder/>
Screenium <http://www.syniumsoftware.com/en/screenium/>



Regards
O r t w i n Z i l l g e n
---------------------------------------------
<mailto:info-x85BCD9UzoazQB+***@public.gmane.org> <http://dddd.mettre.de?4713>
<feed://dddd.mettre.de/dddd.xml> <https://twitter.com/Ozett>
member of developer-network <http://www.die4dwerkstatt.de>


**********************************************************************
4D v13 is available now - with more than 200 new features to make
your applications richer and faster
http://www.4d.com/products/new.html

4D Internet Users Group (4D iNUG)
FAQ: http://lists.4d.com/faqnug.html
Archive: http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub: mailto:4D_Tech-Unsubscribe-d2/MUvgItPNWk0Htik3J/***@public.gmane.org
**********************************************************************
Arnaud de Montard
2014-01-09 08:58:11 UTC
Permalink
Post by David Adams
It's rare that I print anything out of 4D.
It's rare I like to write printing, and often I have to do :-(

For my own, since v12 i'm very found of two approaches:
- print object, really powerful whereas quite time consuming
- use of flat xml files (.fodt, .fods…) created with OpenOffice or LibreOffice as templates to fill with PROCESS 4D TAGS
--
Arnaud de Montard




**********************************************************************
4D v13 is available now - with more than 200 new features to make
your applications richer and faster
http://www.4d.com/products/new.html

4D Internet Users Group (4D iNUG)
FAQ: http://lists.4d.com/faqnug.html
Archive: http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub: mailto:4D_Tech-Unsubscribe-d2/MUvgItPNWk0Htik3J/***@public.gmane.org
**********************************************************************
Keith White
2014-01-09 09:35:06 UTC
Permalink
Post by David Adams
That's reasonably appealing. I've looked in that directly a bit before and
not found a tool for OS X that I could run locally. Do you know of such a
tool?

PhantomJS will silently render any HTML page and run Javascripts, so you can render the page into other formats using JS. I've used it to render Highcharts for emailing server side (I rendered to PNG to include as an embedded image in HTML email)

http://phantomjs.org/

It's a single executable and you use LEP to launch it.

Best regards

Keith White
Synergist Express Ltd, UK.



**********************************************************************
4D v13 is available now - with more than 200 new features to make
your applications richer and faster
http://www.4d.com/products/new.html

4D Internet Users Group (4D iNUG)
FAQ: http://lists.4d.com/faqnug.html
Archive: http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub: mailto:4D_Tech-Unsubscribe-d2/MUvgItPNWk0Htik3J/***@public.gmane.org
**********************************************************************
bob.miller-8bIZtXaliEfQT0dZR+
2014-01-09 13:56:37 UTC
Permalink
Dave,

I'm positively thrilled to have something that might be of value to you!
You've helped me so many times over the years.

This requirement to print variable length text and yet maintain format
control is one of the very first things we used 4D for, back in version
1.0.2. It required a plugin at the time, but finally in v13 it is
possible to create an all-4D solution.

The trick is to use Text To Array, and then take each array element, pop
it into a variable that's on a form you will print using PRINT FORM, and
keep track of the number of pixels you've printed. When you've come up to
a number of pixels where the page is "full" (you can leave room for
footers and such), call PAGE BREAK.

Here is an example of code:

//print header boilerplate, if there is any
HandleTextData
("Get";->[QuoteEntryHeader]BoilerplateTextID;->vHeaderBoilerplate) //I
populate vHeaderBoilerplate with text, this could be many lines

If (vHeaderBoilerplate#"")
PrintQuoteSection ("GeneralNotes") `See below for code for
PrintQuoteSection; the argument tells this procedure
`what to print using PRINT FORM; in this case, I'm printing a static
section heading

ARRAY TEXT($aPrintText;0)
TEXT TO ARRAY(vHeaderBoilerplate;$aPrintText;521;"Times New Roman";10;0)
`here's the magic; by converting the text to an array that's sized
horizontally to contain one printable line (Text To Array takes care of
line breaks), you can
`then reduce the problem to simply printing one line at a time

$Size:=Size of array($aPrintText)`this is how many lines we will print

For ($m;1;$Size)

pQuoteMsg2:=$aPrintText{$m}`pQuoteMsg2 is the variable on the form we will
print

PrintQuoteSection ("MessageLine")`this prints a particular layout using
PRINT FORM

End for

End if //vHeaderBoilerplate


I have code like this for each "section" I need to print; I've laid out my
document so I have sections such as:
Page1 Header
PageN Header
Page1 Title
General Notes
QuoteLine Introduction
QuoteLine Pricing
QuoteLine Comments

...then I simply loop through my records and call each page section as
appropriate for the various fields and record types.


Code for PrintQuoteSection (I find it easier to abstract the various form
parts using names that are passed as arguments to PrintQuoteSection):

//RLM 12/17/02 PrintQuoteSection - prints portion of Quote form passed
as $1;
//Decrements pPixelsLeft (which is initialized if $1 = "Start"

// PrintQuoteSection( "SectionName" )

C_STRING(20;$1;$Section)
$Section:=$1

C_LONGINT($PrintSize;$FooterArea;$MinQuoteLineSize;$SignOffSize;$MinMessageSize)
$FooterArea:=20+20 //size of our footer (size of "ContinuationRight",
plus 20 (generous size
//of any line to be printed)

$MinQuoteLineSize:=210 //min amount of space that must be left on page to
start printing a quote line
$SignOffSize:=104 //min amount of space that must be left on page to
print signoff (form is 104)
$MinMessageSize:=24+(12*5) //size of GeneralNotes, plus 5 lines of
MessageLine

Case of

: ($Section="Start")
PAGE SETUP([QuoteEntryHeader];"PrintQuote")
GET PRINTABLE AREA(pPixelsLeft)
vPageNo:=0 //will increment to 1 when we print first page


: ($Section="End") //called when we are completely finished printing
PAGE BREAK


: ($Section="PageBreak") //Note: Print1, Print10, and ContinuationRight
//must all be in this Case Statement, not the following one, or the
routine will
//recurse because we haven't cleared the PageBreak condition yet.

pContinuationMsg:="Quote "+[QuoteEntryHeader]QuoteNo+" continued on Page
"+String(vPageNo+1)+" -->" //appears in footer, if needed
PrintQuoteSection ("ContinuationRight")

Repeat //burn up remaining space at end of page
If ((pPixelsLeft>=10) & (pPixelsLeft-10>=$FooterArea)) //we don't want to
go from 19 to 9, if $FooterArea is 15
PrintQuoteSection ("Print10")
Else
PrintQuoteSection ("Print1")
End if
Until (pPixelsLeft<=$FooterArea)

PAGE BREAK(>)
GET PRINTABLE AREA(pPixelsLeft)
PrintQuoteSection ("PageHeader")

PrintQuoteSection ("Print10") //print 10 pixels



: ($Section="Print1") //print 1 pixel of empty space
$PrintSize:=Print form([QuoteEntryHeader];"PrintQuote3";Form Header7)

: ($Section="Print10") //print 10 pixels of empty pace
$PrintSize:=Print form([QuoteEntryHeader];"PrintQuote";Form Header10)


//````````````````````````````````````````````
Else //another argument was passed; first, check if there is room; else
PageBreak

//this is where I do some widow-orphan control; do I have enough room left
on the page to start the next section?
Case of
: ((pPixelsLeft<$SignOffSize) & ($Section="SignOff")) //try not to do a
page break just to get the signoff block in
PrintQuoteSection ("PageBreak")

: (((pPixelsLeft-$FooterArea)<$MinQuoteLineSize) &
($Section="LineItemHeader")) //we're about to print a new line item
PrintQuoteSection ("PageBreak")

: (((pPixelsLeft-$FooterArea)<$MinMessageSize) &
($Section="GeneralNotes")) //we're about to print boilerplate
PrintQuoteSection ("PageBreak")


: (pPixelsLeft<=$FooterArea) //we're at the bottom of the page; we
reserve $FooterArea number of pixels so
//we can print a footer that contains the document name and page number,
legends, logos, etc.

PrintQuoteSection ("PageBreak")
End case


Case of
//General-Purpose
: ($Section="PageHeader")
vPageNo:=vPageNo+1
pPageNo:="Page "+String(vPageNo)

$PrintSize:=Print form([QuoteEntryHeader];"PrintQuote";Form Header1)
//this is our company logo


: ($Section="GeneralHeader")
$PrintSize:=Print form([QuoteEntryHeader];"PrintQuote2";Form Footer)

// there are dozens of other sections, they behave exactly the same as
above

Else
MyAlert ("Unknown parameter on PrintQuoteSection: "+$1)
End case


End case

pPixelsLeft:=pPixelsLeft-$PrintSize //this is key; we track the pixels
left on the page so we can
//detect when to insert a page break, increment the page number, print a
form header, and then reset the pixel counter

//



I then have several forms that have multiple sections in them, each has
lines, logos, or in some cases just text variables. I stitch them all
together per the above to "weave" my tapestry.

Hope this helps - contact me privately if you'd like to have this code in
a little sample database.

Bob Miller
Chomerics, a division of Parker Hannifin Corporation


"PLEASE NOTE: The preceding information may be confidential or
privileged. It only should be used or disseminated for the purpose
of conducting business with Parker. If you are not an intended
recipient, please notify the sender by replying to this message and
then delete the information from your system. Thank you for your
cooperation."

**********************************************************************
4D v13 is available now - with more than 200 new features to make
your applications richer and faster
http://www.4d.com/products/new.html

4D Internet Users Group (4D iNUG)
FAQ: http://lists.4d.com/faqnug.html
Archive: http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub: mailto:4D_Tech-Unsubscribe-d2/MUvgItPNWk0Htik3J/***@public.gmane.org
**********************************************************************
Leonard Soloniuk
2014-01-10 06:12:00 UTC
Permalink
With the tools that 4D now has, it is possible to print extremely complex reports.

However, writing print reports is tedious and the programs tend to be fragile, breaking when a field size changes or a new field is added.

Because of this, I have written a series of routines that is almost a meta-language that I can write my reports with.

I went with using OBJECT GET BEST SIZE, TEXT TO ARRAY, and Print Object rather than generating the reports in HTML for 3 reasons: calculating the position of each object allows me to keep track of pages, re-print headers on each page, and avoid widows and orphans while printing.

It allows me to define page headers and footers with page numbers. Multiple side-by-side tables can be defined. Each table can have multiple columns. Each column has multiple rows. Each table and column can have headers that are re-printed if the table/column requires more than 1 page to be printed.

An object in a row can be specified as “Don’t-split” so that it will not be split between pages.

For each table, or column or object, margins, borders and padding can be defined (using the HTML/CSS definition of these terms).

It supports Multi-style tags, so that multiple font sizes, fonts, and text styles are supported. In addition, alignment (center, left, right) is supported.

It uses a lot of features of 4D, such as Multi-style tags, 2D arrays, PROCESS 4D TAGS, TEXT TO ARRAY

These routines are shared under the MIT freeware license.

https://www.dropbox.com/sh/gfnuncib8w5z72s/VNAzEjB1s7

Regards,
Leonard Soloniuk, MD
Post by David Adams
It's rare that I print anything out of 4D. So rare that the V13 printing
feature set is almost completely novel to me. So far, I like what I've
* Print object is very handy.
* PRINT RECORD does just fine.
* SET PRINT OPTION to PDF on OS X works beautifully.
I need to collate information from a range of fields and tables and produce
a single document. What's hanging me up is that I've got variable-length
text fields and, potentially, list boxes with variable numbers of rows.
I've done a bit of experimenting, and it looks like if I've got a "print
variable frame" text field that static values below it don't print when
using PRINT RECORD. The docs say that there is no way to have
dynamic-height variables using Print form.
So, given me somewhat disjointed description, can anyone offer some
suggestions on printing strategies for 4D V13, OS X only where you need to
assemble a lot of variable sized details somewhat neatly? (If I could
reliably print form a WebArea, that would be a though but I've not gotten
that working in the past.)
If it helps to make it clearer, the goal is to pull together a summary of
everything a student applying to a graduate program has submitted in
summary form. So, bits are free-text answers ("what have you been doing
since undergrad", "what are your goals"), some are fixed-length (name,
email, phone, etc.), some are tabular (test and degree dates, scores, and
percentiles) and some are tabular + variable in length (different
collections of documents and test results.) That's my current problem, but
it's easy to imagine a similar situation with patient data, customer data,
equipment purchase history and service records, etc. Pretty much...anything
I guess.
Thanks in advance for suggestions.
**********************************************************************
4D v13 is available now - with more than 200 new features to make
your applications richer and faster
http://www.4d.com/products/new.html
4D Internet Users Group (4D iNUG)
FAQ: http://lists.4d.com/faqnug.html
Archive: http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
**********************************************************************
**********************************************************************
4D v13 is available now - with more than 200 new features to make
your applications richer and faster
http://www.4d.com/products/new.html

4D Internet Users Group (4D iNUG)
FAQ: http://lists.4d.com/faqnug.html
Archive: http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub: mailto:4D_Tech-Unsubscribe-d2/MUvgItPNWk0Htik3J/***@public.gmane.org
**********************************************************************
Kirk Brooks
2014-01-10 23:28:02 UTC
Permalink
Leonard,
Nice job on first look. Very complete and powerful.

I've thought about doing something like this too but it's been a round-tuit
to which I did not get.

Thanks for posting.
--
Kirk Brooks
San Francisco, CA
=======================

**********************************************************************
4D v13 is available now - with more than 200 new features to make
your applications richer and faster
http://www.4d.com/products/new.html

4D Internet Users Group (4D iNUG)
FAQ: http://lists.4d.com/faqnug.html
Archive: http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub: mailto:4D_Tech-Unsubscribe-d2/MUvgItPNWk0Htik3J/***@public.gmane.org
**********************************************************************
Keith White
2014-01-10 08:21:00 UTC
Permalink
Post by David Adams
4D doesn't have 'offscreen' WebAreas
PhantomJS is exactly this and it's a small self-contained executable on both platforms. Launch with LEP.

I've said this twice before on this list, maybe my posts don't get much attention ;-)

Best regards

Keith White
Synergist Express Ltd, UK.




**********************************************************************
4D v13 is available now - with more than 200 new features to make
your applications richer and faster
http://www.4d.com/products/new.html

4D Internet Users Group (4D iNUG)
FAQ: http://lists.4d.com/faqnug.html
Archive: http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub: mailto:4D_Tech-Unsubscribe-d2/MUvgItPNWk0Htik3J/***@public.gmane.org
**********************************************************************
David Adams
2014-01-10 08:50:37 UTC
Permalink
Post by Keith White
PhantomJS is exactly this and it's a small self-contained executable on
both platforms. Launch with LEP.

I downloaded it and had a short look at the docs and it sounds really
promising. Are you saying that if I put PhantomJS in a path I can reach
with LEP, it should execute? If you don't have time to answer, I can check
myself in the morning.
Post by Keith White
I've said this twice before on this list, maybe my posts don't get much attention ;-)
Yes, we took a vote on it during that day you weren't monitoring the list
;-)

Thanks again!
Post by Keith White
Post by David Adams
4D doesn't have 'offscreen' WebAreas
PhantomJS is exactly this and it's a small self-contained executable on
both platforms. Launch with LEP.
I've said this twice before on this list, maybe my posts don't get much attention ;-)
Best regards
Keith White
Synergist Express Ltd, UK.
**********************************************************************
4D v13 is available now - with more than 200 new features to make
your applications richer and faster
http://www.4d.com/products/new.html
4D Internet Users Group (4D iNUG)
FAQ: http://lists.4d.com/faqnug.html
Archive: http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
**********************************************************************
**********************************************************************
4D v13 is available now - with more than 200 new features to make
your applications richer and faster
http://www.4d.com/products/new.html

4D Internet Users Group (4D iNUG)
FAQ: http://lists.4d.com/faqnug.html
Archive: http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub: mailto:4D_Tech-Unsubscribe-d2/MUvgItPNWk0Htik3J/***@public.gmane.org
**********************************************************************
miyako
2014-01-11 13:43:59 UTC
Permalink
Yes,

PhantomJS exactly fits the bill.

but JPR revealing during his Summit Pre-Class that the "Execute JS" command already exists in 4D, just not exposed, yet,
otherwise I would have been tempted to port PhantomJS as a plugin. Thankfully there is no need for that. :)

km
Post by Keith White
PhantomJS is exactly this and it's a small self-contained executable on both platforms. Launch with LEP.
**********************************************************************
4D v13 is available now - with more than 200 new features to make
your applications richer and faster
http://www.4d.com/products/new.html

4D Internet Users Group (4D iNUG)
FAQ: http://lists.4d.com/faqnug.html
Archive: http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub: mailto:4D_Tech-Unsubscribe-d2/MUvgItPNWk0Htik3J/***@public.gmane.org
**********************************************************************
David Adams
2014-01-11 20:47:48 UTC
Permalink
Post by miyako
but JPR revealing during his Summit Pre-Class that the "Execute JS"
command already exists in 4D, just not exposed, yet,

I guess it's nice to know that 4D has been working on this functionality
for some time. Otherwise, I have to file this tidbit under "information
with no possible use."

As you say, PhantonJS exactly fits the bill when you need to render an HTML
page. If only 4D had a WebKit engine built-in! But it does...what I would
still hope to see is:

WA PRINT

And, ideally:

WA New offscreen area
WA DELETE OFFSCREEN AREA

...and even

WA AREA TO PDF

4D and PhantomJS both have integrated WebKit rendering engines...but there
are a lot of versions of WebKit out there. It would be nice to have display
and print handled by the same version. It would also be nice to avoid LEP.

Still, I am very, very happy to have PhantonJS in my toolkit.
Post by miyako
Yes,
PhantomJS exactly fits the bill.
but JPR revealing during his Summit Pre-Class that the "Execute JS"
command already exists in 4D, just not exposed, yet,
otherwise I would have been tempted to port PhantomJS as a plugin.
Thankfully there is no need for that. :)
km
Post by Keith White
PhantomJS is exactly this and it's a small self-contained executable on
both platforms. Launch with LEP.
**********************************************************************
4D v13 is available now - with more than 200 new features to make
your applications richer and faster
http://www.4d.com/products/new.html
4D Internet Users Group (4D iNUG)
FAQ: http://lists.4d.com/faqnug.html
Archive: http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
**********************************************************************
**********************************************************************
4D v13 is available now - with more than 200 new features to make
your applications richer and faster
http://www.4d.com/products/new.html

4D Internet Users Group (4D iNUG)
FAQ: http://lists.4d.com/faqnug.html
Archive: http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub: mailto:4D_Tech-Unsubscribe-d2/MUvgItPNWk0Htik3J/***@public.gmane.org
**********************************************************************
Keith White
2014-01-10 14:50:24 UTC
Permalink
Post by David Adams
4D doesn't have 'offscreen' WebAreas
PhantomJS is exactly this and it's a self-contained executable on both platforms. Launch with LEP.



I've said this twice before on this list, maybe my posts don't get much attention ;-)



Best regards



Keith White

Synergist Express Ltd, UK.


**********************************************************************
4D v13 is available now - with more than 200 new features to make
your applications richer and faster
http://www.4d.com/products/new.html

4D Internet Users Group (4D iNUG)
FAQ: http://lists.4d.com/faqnug.html
Archive: http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub: mailto:4D_Tech-Unsubscribe-d2/MUvgItPNWk0Htik3J/***@public.gmane.org
**********************************************************************
Keith White
2014-01-10 15:15:47 UTC
Permalink
Are you saying that if I put PhantomJS in a path I can reach with LEP, it should execute? If you don't have time to answer, I can check myself in the morning.
Sorry to everyone for double posting of last post. I got a non-delivery report, so sent again.

Yes, that's what I'm doing. I wrote a wrapper for it which I've altered for posting here to remove some standard generic methods we use. You pass 2 parameters ($1 is the script name and $2 is for parameters for the script). The script I think you need is something like rasterize.js which you'll find on their examples page.

Hope that helps.

Best regards

Keith White
Synergist Express Ltd, UK.

If (False)
// ----------------------------------------------------
//Creator: SYN_Keith
//Date & time: 03/01/2014 17:15:10
//Method Name: PhantomJS
//Description

//Parameters
//Declarations
// ----------------------------------------------------
//END OF HEADER

End if
C_TEXT($cScript;$1)
C_TEXT($cParms;$2)
C_TEXT($In;$Out;$Err)
C_TEXT($cPhantomJS)
C_LONGINT($nPos;$nLoop)
C_LONGINT($Platform)

$cScript:=$1
$cParms:=""
If (Count parameters>=2)
$cParms:=$2
End if

PLATFORM PROPERTIES($Platform)

If ($Platform=Windows)
$cPhantomJS:=Application file
$nPathLength:=Length($cPhantomJS)
$nPos:=0
For ($nLoop;$nPathLength;1;-1)
If (Substring($cPhantomJS;$nLoop;1)=Folder separator)
$nPos:=$nLoop
$nLoop:=0
End if
End for
$cPhantomJS:=Substring($cPhantomJS;1;$nPos)
$cPhantomJS:=$cPhantomJS+"phantomjs"+Folder separator+"phantomjs.exe"
Else
$cPhantomJS:=Application file
$cPhantomJS:=$cPhantomJS+Folder separator+"Contents"+Folder separator
$cPhantomJS:=Convert path system to POSIX($cPhantomJS)
$cPhantomJS:=$cPhantomJS+"phantomjs/bin/phantomjs"
End if
$cPhantomJS:=Char(Double quote)+$cPhantomJS+Char(Double quote)

$cPhantomJS:=$cPhantomJS+" "+$cScript
If ($cParms#"")
$cPhantomJS:=$cPhantomJS+" "+$cParms
End if

SET ENVIRONMENT VARIABLE("_4D_OPTION_HIDE_CONSOLE";"true")
LAUNCH EXTERNAL PROCESS($cPhantomJS;$In;$Out;$Err)

**********************************************************************
4D v13 is available now - with more than 200 new features to make
your applications richer and faster
http://www.4d.com/products/new.html

4D Internet Users Group (4D iNUG)
FAQ: http://lists.4d.com/faqnug.html
Archive: http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub: mailto:4D_Tech-Unsubscribe-d2/MUvgItPNWk0Htik3J/***@public.gmane.org
**********************************************************************
David Adams
2014-01-10 21:39:34 UTC
Permalink
Mind. Blown.

**********************************************************************
4D v13 is available now - with more than 200 new features to make
your applications richer and faster
http://www.4d.com/products/new.html

4D Internet Users Group (4D iNUG)
FAQ: http://lists.4d.com/faqnug.html
Archive: http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub: mailto:4D_Tech-Unsubscribe-d2/MUvgItPNWk0Htik3J/***@public.gmane.org
**********************************************************************
David Adams
2014-01-10 21:52:59 UTC
Permalink
A quick recap on the run of this broad and deep thread:

* 4D V13 (V12 too from the looks of things) has a wealth of printing
options.

* If you're on a clock, like me, there's not a lot of hope of figuring out
said wealth of options. The docs are okay and there are a couple of
examples and a fair few complicated tech notes. The problem is that a lot
of the commands are context dependent. As in, they work only in certain
situations and not others. At least, that's what the various commands seem
to say about calculating and setting heights, etc.

* There isn't any obvious way to set up a form with multiple
variable-height objects and get 4D to sort it out...which is what I need.

* You need to look past the print them and into the listbox theme, if
you're printing listboxes.

* Print object shows a lot of promise.

* If you know all of the printing commands and options, you can probably
pick the right collection of tools to do just about anything you like. If
you aren't equipped with that knowledge, it's easy to flounder around a lot.

In my mind I've broken down the major strategies outlined here into four
groups:

* 4D Write - not considering it. No time, feels like a dead end anyway for
new work. (No disrespect to people that are using the product!)

* PDF rendering. Looks great if you're already comfortable with HTML
production and don't need page headers and footers. (This could work for my
pressing problem.)

* Print object & lots of magic. Looks very powerful and very complicated. I
floundered a lot...got a lot working...kept finding new oddities....didn't
finish.

* Print form. Right! So that's where PRINT LAYOUT went. Despite its
sometimes reputation for being 'complicated' or 'advanced', it seems like
the most straightforward built-in tool. The rules are clear and what you
need to track (pixels available and consumed) is easily accessible.
Getting a 'mental model' for Print form seems much, much easier than with
Print object+magic. Dave Gradwell privately sent me a very nice example
including screenshots and object geometry code that made things click more
effectively than the manuals.

When you've got plenty of time, figuring complicated things out can be fun
and rewarding. That knowledge can then help you later when you're under a
time crunch. When you're under the gun it is hard and inefficient to learn
something big. So, I'll go with one of the easier-to-succeed options today
and try to carve out some time in the future for remedial work on the 4D
printing features.

My thanks again to everyone that's helped and respect to anyone that's
mastered this stuff.
Post by David Adams
Mind. Blown.
**********************************************************************
4D v13 is available now - with more than 200 new features to make
your applications richer and faster
http://www.4d.com/products/new.html

4D Internet Users Group (4D iNUG)
FAQ: http://lists.4d.com/faqnug.html
Archive: http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub: mailto:4D_Tech-Unsubscribe-d2/MUvgItPNWk0Htik3J/***@public.gmane.org
**********************************************************************
David Adams
2014-01-11 08:19:31 UTC
Permalink
Quick question on calling PhantomJS. I've got the code built to construct a
proper call that will run from Terminal when pasted in. Full posix paths,
all good.

When I call this with LEP, I always get back the following in stdout and no
PDF is generated:

phantomjs>

Presumably, I'm quoting something wrong or failing to include some sort of
termination. I've experimented with various quoting formats and line
endings but they've made no difference.

Any suggestions?

**********************************************************************
4D v13 is available now - with more than 200 new features to make
your applications richer and faster
http://www.4d.com/products/new.html

4D Internet Users Group (4D iNUG)
FAQ: http://lists.4d.com/faqnug.html
Archive: http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub: mailto:4D_Tech-Unsubscribe-d2/MUvgItPNWk0Htik3J/***@public.gmane.org
**********************************************************************
David Adams
2014-01-11 09:35:24 UTC
Permalink
Post by David Adams
Any suggestions?
Wait, I have one. Check the slow, error-prone peripheral that's inputing
data into the keyboard. It seems that's where the problem is located.

**********************************************************************
4D v13 is available now - with more than 200 new features to make
your applications richer and faster
http://www.4d.com/products/new.html

4D Internet Users Group (4D iNUG)
FAQ: http://lists.4d.com/faqnug.html
Archive: http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub: mailto:4D_Tech-Unsubscribe-d2/MUvgItPNWk0Htik3J/***@public.gmane.org
**********************************************************************
Continue reading on narkive:
Loading...