Skip to content

Printing function #77

Open
Open
@ondras

Description

@ondras

From [email protected] on March 12, 2010 11:23:46

(new feature request)

Hi,

There is something really missing in wwwsqldesigner : the option to
download the designed database as PDF (or something else for printing).

I tried the "print" function built in the browser, but in chrome I have
very bad results and with firefox I have partial schema with random
behavior.

My tests drove me to something pretty well working. The idea is to send
XML + tables coords & dimensions + relations coords & dimensions to a PHP
script.

To achieve so on my test installation I reused some FPDF work I wrote in
the past, with a Bezier implementation that mostly matches what you did in
the JS file.

Have a look : http://maintenance.netsoins.org/dbdesign/ (topright button
"print" or "Imprimer").

There is some few bugs (bottom borders are too large, relations doesnt
match perfectly the row...).

I can't give you the PHP code since it is under licence, but the idea is to
use the DOM, since all work has already been done on the client side.

Best regards,
Geompse

PS : in the JS file, I did this :

SQL.IO.prototype.print = function() {
var xml = this.owner.toXML();
var bp = this.owner.getOption("xhrpath");
var url = bp + "print.php";
var relations = this.owner.relations;
var tables = this.owner.tables;

var data = 'xml='+encodeURIComponent(xml);
for(var i=0; i<relations.length; i++)
{
    var r = relations[i];
    if(r.hidden)
        continue;
    data += 

'&rel[]='+r.drawType+'|'+r.p1[0]+'|'+r.p1[1]+'|'+r.p2[0]+'|'+r.p2[1]+'|'+r.
px+'|'+encodeURIComponent(r.color);
}
for(var i=0; i<tables.length; i++)
{
var t = tables[i];
data +=
'&tbl[]='+encodeURIComponent(t.getTitle())+'|'+t.x+'|'+t.y+'|'+t.dom.contai
ner.offsetWidth+'|'+t.dom.container.offsetHeight;
}
OZ.Request(url,
function(x){if(x=='OK')document.location=url.replace('.php','.pdf');else
alert(x);}, {method:"post", data:data});
}

(Note that it requires type,p1,p2,x(actually half or x),color to be stored
in the SQL.Relation, and that the php file is "print.php" and the pdf file
is stored server-side under "print.pdf")

Original issue: http://code.google.com/p/wwwsqldesigner/issues/detail?id=70

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions