Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » How to print diagram name in header or footer?
How to print diagram name in header or footer? [message #226473] Tue, 14 November 2006 08:43 Go to next message
Eclipse UserFriend
Originally posted by: shruthi.cn.in.bosch.com

Hello everybody,

I have a ScrollingGraphicalViewer viewer which displays some GEF diagrams.
I want to print the diagram name in either header or footer.
This is the code that i use for printing.

PrintDialog dialog = new PrintDialog(shell, SWT.NULL);
PrinterData data = dialog.open();
if (data != null) {
PrintGraphicalViewerOperation op = new PrintGraphicalViewerOperation(
new Printer(data), baseViewer);
op.setPrintMode(PrintFigureOperation.FIT_PAGE);
op.run("test");
}

In the above code, baseViewer is of type ScrollingGraphicalViewer.

How can i print the diagram name in header or footer.
Please help me.

Thank you,
Best Regards
Shruthi
Re: How to print diagram name in header or footer? [message #226506 is a reply to message #226473] Tue, 14 November 2006 21:27 Go to previous messageGo to next message
David Cummings is currently offline David CummingsFriend
Messages: 8
Registered: July 2009
Junior Member
Hi Shruthi,

GEF does not provide a way to print headers and footers on diagram
printouts.

If you are interested in printing a header and footer you'll have to
extend GEF's printing support which will involve some SWT work.

You could implement your own print operation class (perhaps something
like PrintGraphicalViewerWithHeaderOperation) that extends
PrintGraphicalViewerOperation. This class would have a constructor that
accepts a string describing the header.

You would also need to override the printPages() method and provide your
own implementation. This is where you'll print the header and/or
footer. I'd suggest taking the code from
PrintFigureOperation#printPages, pasting it into your new method and
modifying it to print the header and/or footer.

For some ideas on how to output text to a printer and how to position
it, you can have a look at the code snippet in the description of
http://bugs.eclipse.org/bugs/show_bug.cgi?id=96674. It is basically the
SWT hello world example modified to output to a printer.

David


shruthi wrote:
> Hello everybody,
>
> I have a ScrollingGraphicalViewer viewer which displays some GEF
> diagrams. I want to print the diagram name in either header or footer.
> This is the code that i use for printing.
>
> PrintDialog dialog = new PrintDialog(shell, SWT.NULL);
> PrinterData data = dialog.open();
> if (data != null) {
> PrintGraphicalViewerOperation op = new PrintGraphicalViewerOperation(
> new Printer(data), baseViewer);
> op.setPrintMode(PrintFigureOperation.FIT_PAGE);
> op.run("test");
> }
>
> In the above code, baseViewer is of type ScrollingGraphicalViewer.
>
> How can i print the diagram name in header or footer.
> Please help me.
>
> Thank you,
> Best Regards
> Shruthi
>
Re: How to print diagram name in header or footer? [message #237772 is a reply to message #226506] Wed, 08 August 2007 15:00 Go to previous message
Alexander Haag is currently offline Alexander HaagFriend
Messages: 119
Registered: July 2009
Senior Member
Hi shruti,

I've got a very similar problem. I want to print the graphic of my
GEF-Editor with a footer on each page.

Unfortunately I haven't been able to print my footer yet, although I
tried the hints mentioned below. I wrote my own PrintAction which starts
my own PrintGraphicalViewerWithFooterOperation.
In the Operation I tried modifying the code of the printPages()-method
but with no effect except that I got quite more pages than the graphic
originally needed (needes 3 pages I got 89!!)

I tried the code of the Bug mentioned below but all I got was some
errors while instantiating the GC (graphicsContext) with the printer I used.
So this code hasn't been much use.

Have you been able to print a header/footer yet?
If so, could you provide some code-snippets for me?

Thanks in advance
Alex Haag


David Cummings schrieb:
> Hi Shruthi,
>
> GEF does not provide a way to print headers and footers on diagram
> printouts.
>
> If you are interested in printing a header and footer you'll have to
> extend GEF's printing support which will involve some SWT work.
>
> You could implement your own print operation class (perhaps something
> like PrintGraphicalViewerWithHeaderOperation) that extends
> PrintGraphicalViewerOperation. This class would have a constructor that
> accepts a string describing the header.
>
> You would also need to override the printPages() method and provide your
> own implementation. This is where you'll print the header and/or
> footer. I'd suggest taking the code from
> PrintFigureOperation#printPages, pasting it into your new method and
> modifying it to print the header and/or footer.
>
> For some ideas on how to output text to a printer and how to position
> it, you can have a look at the code snippet in the description of
> http://bugs.eclipse.org/bugs/show_bug.cgi?id=96674. It is basically the
> SWT hello world example modified to output to a printer.
>
> David
>
>
> shruthi wrote:
>> Hello everybody,
>>
>> I have a ScrollingGraphicalViewer viewer which displays some GEF
>> diagrams. I want to print the diagram name in either header or footer.
>> This is the code that i use for printing.
>>
>> PrintDialog dialog = new PrintDialog(shell, SWT.NULL);
>> PrinterData data = dialog.open();
>> if (data != null) {
>> PrintGraphicalViewerOperation op = new PrintGraphicalViewerOperation(
>> new Printer(data), baseViewer);
>> op.setPrintMode(PrintFigureOperation.FIT_PAGE);
>> op.run("test");
>> }
>>
>> In the above code, baseViewer is of type ScrollingGraphicalViewer.
>>
>> How can i print the diagram name in header or footer.
>> Please help me.
>>
>> Thank you,
>> Best Regards
>> Shruthi
>>
Previous Topic:Re: How to drag and drop coaches(cars) smoothly?
Next Topic:KeyHandler
Goto Forum:
  


Current Time: Tue Nov 30 14:41:00 GMT 2021

Powered by FUDForum. Page generated in 0.02328 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top