How to print diagram name in header or footer? [message #226473] |
Tue, 14 November 2006 08:43 |
Eclipse User |
|
|
|
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 #237772 is a reply to message #226506] |
Wed, 08 August 2007 15:00 |
Alexander Haag 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
>>
|
|
|
Powered by
FUDForum. Page generated in 0.04013 seconds