THPrint

Here is where the magnanimous folks that create externals post them (.zip archives only please).

THPrint

Postby sctell » Mon Mar 05, 2012 11:24 am

I have been working on a Cocoa project and it was necessary to create a class that would print out a table of data.

While working on this I thought it may be useful to SC developers so I have wrapped it in an external.

What does it do ?

It takes table data that is tab delimited for columns and return delimited for rows and allows you to print this data in a table without resorting to setting out fields etc in SC.

Here is the script for the print button from the example project.

Code: Select all
on mouseUp
global gData

-- just creates some data which must be tab delimited for columns and return delimited for rows
createSomeData


-- Setup the external for printing
-- line space is the height allocated for drawing the title row and the data rows
put 40.0 into tLeftMargin
put 40.0 into tRightMargin
put 30.0 into tTopMargin
put 30.0 into tBottomMargin
put 40.0 into tLineSpace
put THPrint("initForPrint",gData,tLeftMargin,tRightMargin,tTopMargin,tBottomMargin,tLineSpace) into cd fld "result"

--Tell the external the specification for the titles
put true into tShowTitles
put "No.,Firstname,Surname" into tTitles                         -- comma delimited titles
put "center,left,left" into tAlignment                           -- the alignment for the titles left,right or center
put "ComicSansMS" into tFontName                                 -- the font name
put 12 into tFontSize                                            -- the font size
put "0.9,0.9,0.9,1.0" into tFillColor                            -- the fill color r,g,b,a between 0.0 and 1.0
put "1.0,1.0,1.0,1.0" into tBorderColor                          -- the border color r,g,b,a between 0.0 and 1.0
put THPrint("setTitleSpec",tShowTitles,tTitles,tFontName,tFontSize,tAlignment,tFillColor,tBorderColor) into cd fld "result"

--Tell the external the specification for each data row
put false into tAlternateRowColors                               -- show the colors alternating
put "center,left,left" into tAlignment                           -- the alignment for the data rows left,right or center
put "Helvetica" into tFontName                                   -- the font name
put 10 into tFontSize                                            -- the font size
put "20,40,40" into tColPercentages                              -- the percentage of the available paper width for each column
put "0.957,0.965,0.98,1.0" into tColorA                          -- this is either the fill color or the odd color depending on tAlternateRowColors being true or false
put "1.0,1.0,1.0,1.0" into tColorB                               -- this is either the border color or the odd color depending on tAlternateRowColors being true or false
put THPrint("setColumnSpec",tAlternateRowColors,tFontName,tFontSize,tAlignment,tColPercentages,tColorA,tColorB) into cd fld "result"

--Print it all with a job title to show in the header
put true into tShowHeader                                        -- show the header or not
put "MyUntitled" into tJobTitle
put THPrint("print",tShowHeader,tJobTitle) into tInfo

end mouseUp
----------------------
on createSomeData
global gData
put "" into gData
repeat with n = 1 to 100
put n & tab & "Terry" & tab & "Heaford"  into line n of gData
end repeat
end createSomeData
----------------------



I hope you find it useful.

If any bugs are found or enhancements required then please post here.


THPrint.zip
(26.67 KiB) Downloaded 217 times


All the best

Terry
Last edited by sctell on Fri Oct 05, 2012 3:10 am, edited 1 time in total.
sctell
 
Posts: 1143
Joined: Sun Jul 06, 2008 10:41 am

Re: THPrint

Postby marksch » Thu Mar 08, 2012 4:51 pm

Very interesting. I might have an actual use for this. Thanks Terry.

Mark
We have time for new projects. Go to my homepage to contact me.

Follow me on Facebook https://www.facebook.com/marksch
User avatar
marksch
 
Posts: 79
Joined: Fri Aug 22, 2008 4:51 am

Re: THPrint

Postby sctell » Fri Oct 05, 2012 3:14 am

Hi,

I have just uploaded an update to this external. It can be found at the top of the thread.

I noticed a coding error and have now corrected it.

This update results in a major increase in formatting the document for printing and if you print to pdf the size of the pdf document is significantly reduced.

For example it will be 3x faster if the document contains 3 pages

and 20x faster if the document contains 20 pages and so on.

All the best

Terry
sctell
 
Posts: 1143
Joined: Sun Jul 06, 2008 10:41 am


Return to XCmds, XFcns, and XRtns

Who is online

Users browsing this forum: No registered users and 1 guest