{= include("templates.util.base_util"); include("lib.sdd.table"); include("lib.sdd.graphic_object"); include("lib.sdd.render_pdf"); #include("lib.sdd.values"); # KHP 04/Mar/2011 - Only allow root_admin access bool is_root_admin = get_is_root_admin(); if (is_root_admin) then ( bool tabletest = true; # Create a new PDF node pdf = new_pdf(); node sdd = new_sdd(); # Create a page box, which surrounds the entire page. node page_box = new_box_sdd(sdd, sddfloat(0), sddfloat(792), sddfloat(612), sddfloat(792)); # Create a content box, which is within the page box, but with a 20-unit margin node content_box = new_box_sdd(page_box, 0, 0, 0, 0); set_sdd_bounds_offset(content_box, page_box, 20, 20, -20, -20); node timesRoman = new_type1_font(pdf, "/Times-Roman", "/MacRomanEncoding"); v.timesRoman = ""; set_node_type('v.timesRoman', 'node'); v.timesRoman = timesRoman; node timesBold = new_type1_font(pdf, "/Times-Bold", "/MacRomanEncoding"); # Create a text box at the top of the content box node text = new_text_sdd(content_box, "Sawmill Document Description Demo", timesRoman, 30, true); text{"alignment"} = "center"; set_sdd_position_upper_left(text, content_box); # Add a spacer after text node spacer = new_box_sdd(content_box, sddfloat(20), sddfloat(20), sddfloat(20), sddfloat(20)); set_sdd_position_next(spacer, content_box); remove_sdd_stroke_color(spacer); # Create a text box below "text" string textstring2 = "This is an example of wrapped text. This text is passed to the SDD library as a single string; it is wrapped onto multiple lines automatically."; node text2 = new_text_sdd(content_box, textstring2, timesRoman, 24, true); set_sdd_dimensions_full_width_text(text2, content_box); set_sdd_position_next(text2, content_box); # Add a spacer after textstring2 node spacer = new_box_sdd(content_box, sddfloat(20), sddfloat(20), sddfloat(20), sddfloat(20)); set_sdd_position_next(spacer, content_box); remove_sdd_stroke_color(spacer); #set_sdd_stroke_color(spacer, 1, 0, 0); #set_sdd_fill_color(spacer, 0, 0, 1); # Create a text box below "text" #string textstring3 = "Now is the time for all good people to come ot the aid of their country."; string textstring3 = "Call me Ishmael. Some years ago - never mind how long precisely - having little or no money in my purse, and nothing particular to interest me on shore, I thought I would sail about a little and see the watery part of the world. It is a way I have of driving off the spleen, and regulating the circulation. Whenever I find myself growing grim about the mouth; whenever it is a damp, drizzly November in my soul; whenever I find myself involuntarily pausing before coffin warehouses, and bringing up the rear of every funeral I meet; and especially whenever my hypos get such an upper hand of me, that it requires a strong moral principle to prevent me from deliberately stepping into the street, and methodically knocking people's hats off - then, I account it high time to get to sea as soon as I can. This is my substitute for pistol and ball. With a philosophical flourish Cato throws himself upon his sword; I quietly take to the ship. There is nothing surprising in this. If they but knew it, almost all men in their degree, some time or other, cherish very nearly the same feelings towards the ocean with me.";node text3 = new_text_sdd(content_box, textstring3, timesRoman, 12, true); #set_sdd_position_next(text3, content_box); set_sdd_bounds_next_text(text3, content_box); # Put a box around text #node box1 = new_box_sdd(text, sddleft(text), sddtop(text), sddwidth(text), sddheight(text)); # Put a box around text2 #node box2 = new_box_sdd(text2, sddleft(text2), sddtop(text2), sddwidth(text2), sddheight(text2)); # Add a spacer #node spacer = new_box_sdd(content_box, sddfloat(20), sddfloat(20), sddfloat(20), sddfloat(20)); #set_sdd_position_next(spacer, content_box); # Add an image node img = new_image_sdd(content_box, "LogAnalysisInfo/WebServerRoot/picts/error.png"); set_sdd_position_next(img, content_box); # Add an image node img2 = new_image_sdd(content_box, "LogAnalysisInfo/WebServerRoot/picts/error.png"); set_sdd_position_upper_right(img2, img); ## ## TABLE TEST ## if (tabletest) then ( # Create a table int num_rows = 10; int num_columns = 4; node tbl = new_table_sdd(content_box, num_rows, num_columns); set_sdd_position_next(tbl, content_box); for (int row = 0; row < num_rows; row++) ( for (int column = 0; column < num_columns; column++) ( node contents = new_group_box_sdd(0, 0, 0); remove_sdd_stroke_color(contents); if (row == 0) then ( node text = new_text_sdd_minimum_dimensions(contents, " Header" . column . " ", timesBold, 30, false); set_sdd_position_upper_left(text, contents); ); else ( if (column == 0) then ( node img = new_image_sdd(contents, "LogAnalysisInfo/WebServerRoot/picts/error.png"); set_sdd_position_upper_left(img, contents); node text = new_text_sdd_minimum_dimensions(contents, " Page" . row . " ", timesRoman, 30, false); set_sdd_position_upper_right(text, img); ); else ( node text = new_text_sdd_minimum_dimensions(contents, " 123 ", timesRoman, 30, false); set_sdd_position_upper_left(text, contents); @text{"alignment"} = "right"; #echo("text: " . node_as_string(text)); ); ); set_table_cell_contents(tbl, row, column, contents); ); ); # Put a box around the table, two pixels out # node box_around_table = new_box_sdd(page_box, 0, 0, 0, 0); # set_sdd_bounds_offset(box_around_table, tbl, -2, -2, 2, 2); ); # tabletest sdd_to_pdf(sdd, pdf, "sdd.pdf"); ) else ( # No permission to view this resource (URL) display_no_permission_html(); ); =}