Re: Print friendly panel (pdf)

2010-02-28 Thread Martin Makundi
Hi!

Ok.

Here is some bits and parts, hopefully useful:

/**
 * Convert HTML to PDF
 * @param in HTML
 * @param out PDF
 */
public static void html2pdf(InputStream in, OutputStream out) {
  try {
StringWriter sw = new StringWriter();
Tidy tidier = new Tidy();
{
  tidier.setInputEncoding(ENCODING);
  tidier.setQuiet(true);
tidier.setXHTML(true);
tidier.setTidyMark(false);
  tidier.parse(in, sw);
}
{
  ITextRenderer renderer = new ITextRenderer();
//String s = sw.getBuffer().toString();
//System.out.println(s);
  renderer.setDocumentFromString(sw.getBuffer().toString());
  renderer.layout();
  renderer.createPDF(out);
}
  } catch (Exception e) {
throw new RuntimeException(e);
  }
}


/**
   * Renders given page
   * @param pageClass to render
   * @param pageParameters to render with
   * @param clean
   * @return String of HTML produced
   */
  public static String renderPageToString(
  final Class pageClass,
  final PageParameters pageParameters, boolean clean) {
String webPageAsString;
{
  WebApplication webApplication = WebApplication.get();
  ServletContext servletContext = webApplication.getServletContext();
  MockHttpSession servletSession = new MockHttpSession(servletContext);
  servletSession.setTemporary(true);

  MockHttpServletRequest servletRequest = new MockHttpServletRequest(
  webApplication, servletSession, servletContext);
  MockHttpServletResponse servletResponse = new MockHttpServletResponse(
  servletRequest);
  servletRequest.initialize();
  servletResponse.initialize();

  WebRequest webRequest = new ServletWebRequest(servletRequest);

  BufferedWebResponse webResponse = new
BufferedWebResponse(servletResponse);
  webResponse.setAjax(true);

  WebRequestCycle htmlRequestCycle =
new WebRequestCycle(webApplication, webRequest, webResponse);

  BookmarkablePageRequestTarget htmlTarget =
new BookmarkablePageRequestTarget(pageClass, pageParameters);

  htmlRequestCycle.setRequestTarget(htmlTarget);

  try {
htmlRequestCycle.getProcessor().respond(htmlRequestCycle);

if (htmlRequestCycle.wasHandled() == false) {
  htmlRequestCycle.setRequestTarget(new WebErrorCodeResponseTarget(
  HttpServletResponse.SC_NOT_FOUND));
}
htmlRequestCycle.detach();
  } finally {
htmlRequestCycle.getResponse().close();
  }

  webPageAsString = webResponse.toString();
}

webPageAsString = Utils.replaceAll(webPageAsString,
WebPageConstants.SRC_URL_PATTERN, "file:///" +
WebApplication.get().getServletContext().getRealPath("/") + "/");

if (clean) {
  return escapeHighEnd(webPageAsString.replaceAll("", "")
  .replaceAll("", "").replaceAll("\\swicketpath=\".*?\"",
  ""));
}

return escapeHighEnd(webPageAsString);
  }

**
Martin

2010/2/28 Alex Rass :
> That's what google is doing to print (through a conversion on the back end).
> So if you contribute it, I am sure SOMEONE would want it :)
>
> - Alex
>
>
> -Original Message-
> From: Martin Makundi [mailto:martin.maku...@koodaripalvelut.com]
> Sent: Sunday, February 28, 2010 12:22 PM
> To: users@wicket.apache.org
> Subject: Re: Print friendly panel
>
> Hi!
>
> Anybody interested in pdf print script via wicket?
>
> **
> Martin
>
> 2010/2/28 nino martinez wael :
>> Yeah I agree this is the way it should be done. Works like a charm! And
> then
>> just have a simple js like this:
>>
>> 
>>  <!--
>>  function printpage() {
>>  window.print();
>>  }
>>  //-->
>> 
>>
>> on or link button or whatever..
>>
>>
>>
>> 2010/2/28 Riyad Kalla 
>>
>>> This is what I've done in the past as well, allows your user to just
>>> "print"
>>> the page they are staring at and have the browser do the right thing in
>>> using an alternative style sheet for rendering the page -- this includes
>>> using a lot of display:none to trim down the parts of the page that you
>>> don't want printing. This way all you need on your page is a "Print" link
>>> that invokes the Print dialog, no other popups ontop of popups.
>>>
>>> Some info:
>>>
> http://www.scottklarr.com/topic/15/css-create-a-style-sheet-for-print-only/
>>>
>>> <
>>>
> http://www.scottklarr.com/topi

RE: Print friendly panel

2010-02-28 Thread Josh Chappelle
Awesome! Thanks a lot guys. That will be easy to do.

Josh 

-Original Message-
From: Riyad Kalla [mailto:rka...@gmail.com] 
Sent: Saturday, February 27, 2010 6:06 PM
To: users@wicket.apache.org
Subject: Re: Print friendly panel

This is what I've done in the past as well, allows your user to just "print"
the page they are staring at and have the browser do the right thing in
using an alternative style sheet for rendering the page -- this includes
using a lot of display:none to trim down the parts of the page that you
don't want printing. This way all you need on your page is a "Print" link
that invokes the Print dialog, no other popups ontop of popups.

Some info:
http://www.scottklarr.com/topic/15/css-create-a-style-sheet-for-print-only/

<http://www.scottklarr.com/topic/15/css-create-a-style-sheet-for-print-only/
>
http://webdesign.about.com/cs/css/a/aa042103a.htm

On Sat, Feb 27, 2010 at 4:54 PM, Alex Rass  wrote:

> Josh,
>
> This doesn't answer your question directly (about a popup).
> But a MUCH simpler way is to make your page printer friendly by supplying
> an
> alternative CSS for printing format (google on that). Makes life much
> easier.
>
> When you tell your page which css to use, you can say "use this CSS for
> printing only". All transparent to the user.
>
> - Alex
>
>
> -Original Message-
> From: Josh Chappelle [mailto:jchappe...@4redi.com]
> Sent: Friday, February 26, 2010 4:09 PM
> To: users@wicket.apache.org
> Subject: Print friendly panel
>
> Hi,
>
>
>
> Does anyone know of a suggested method to render a printer friendly panel
> to
> a separate browser window so that user's can print? The only thing I have
> found is the following article and it looks a little clunky.
>
>
>
> http://cwiki.apache.org/WICKET/rendering-panel-to-a-string.html
>
>
>
> Basically I just need to be able to place a link that when clicked will
pop
> up a new browser window with only the contents to the target panel. That
> way
> users can print that panel from there.
>
>
>
> Thanks,
>
>
>
> Josh
>
>
>
>
>
>
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>


-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



RE: Print friendly panel (pdf)

2010-02-28 Thread Alex Rass
That's what google is doing to print (through a conversion on the back end).
So if you contribute it, I am sure SOMEONE would want it :)

- Alex


-Original Message-
From: Martin Makundi [mailto:martin.maku...@koodaripalvelut.com] 
Sent: Sunday, February 28, 2010 12:22 PM
To: users@wicket.apache.org
Subject: Re: Print friendly panel

Hi!

Anybody interested in pdf print script via wicket?

**
Martin

2010/2/28 nino martinez wael :
> Yeah I agree this is the way it should be done. Works like a charm! And
then
> just have a simple js like this:
>
> 
>  <!--
>  function printpage() {
>  window.print();
>  }
>  //-->
> 
>
> on or link button or whatever..
>
>
>
> 2010/2/28 Riyad Kalla 
>
>> This is what I've done in the past as well, allows your user to just
>> "print"
>> the page they are staring at and have the browser do the right thing in
>> using an alternative style sheet for rendering the page -- this includes
>> using a lot of display:none to trim down the parts of the page that you
>> don't want printing. This way all you need on your page is a "Print" link
>> that invokes the Print dialog, no other popups ontop of popups.
>>
>> Some info:
>>
http://www.scottklarr.com/topic/15/css-create-a-style-sheet-for-print-only/
>>
>> <
>>
http://www.scottklarr.com/topic/15/css-create-a-style-sheet-for-print-only/
>> >
>> http://webdesign.about.com/cs/css/a/aa042103a.htm
>>
>> On Sat, Feb 27, 2010 at 4:54 PM, Alex Rass  wrote:
>>
>> > Josh,
>> >
>> > This doesn't answer your question directly (about a popup).
>> > But a MUCH simpler way is to make your page printer friendly by
supplying
>> > an
>> > alternative CSS for printing format (google on that). Makes life much
>> > easier.
>> >
>> > When you tell your page which css to use, you can say "use this CSS for
>> > printing only". All transparent to the user.
>> >
>> > - Alex
>> >
>> >
>> > -Original Message-
>> > From: Josh Chappelle [mailto:jchappe...@4redi.com]
>> > Sent: Friday, February 26, 2010 4:09 PM
>> > To: users@wicket.apache.org
>> > Subject: Print friendly panel
>> >
>> > Hi,
>> >
>> >
>> >
>> > Does anyone know of a suggested method to render a printer friendly
panel
>> > to
>> > a separate browser window so that user's can print? The only thing I
have
>> > found is the following article and it looks a little clunky.
>> >
>> >
>> >
>> > http://cwiki.apache.org/WICKET/rendering-panel-to-a-string.html
>> >
>> >
>> >
>> > Basically I just need to be able to place a link that when clicked will
>> pop
>> > up a new browser window with only the contents to the target panel.
That
>> > way
>> > users can print that panel from there.
>> >
>> >
>> >
>> > Thanks,
>> >
>> >
>> >
>> > Josh
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> > -
>> > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
>> > For additional commands, e-mail: users-h...@wicket.apache.org
>> >
>> >
>>
>

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Print friendly panel

2010-02-28 Thread Martin Makundi
Hi!

Anybody interested in pdf print script via wicket?

**
Martin

2010/2/28 nino martinez wael :
> Yeah I agree this is the way it should be done. Works like a charm! And then
> just have a simple js like this:
>
> 
>  <!--
>  function printpage() {
>  window.print();
>  }
>  //-->
> 
>
> on or link button or whatever..
>
>
>
> 2010/2/28 Riyad Kalla 
>
>> This is what I've done in the past as well, allows your user to just
>> "print"
>> the page they are staring at and have the browser do the right thing in
>> using an alternative style sheet for rendering the page -- this includes
>> using a lot of display:none to trim down the parts of the page that you
>> don't want printing. This way all you need on your page is a "Print" link
>> that invokes the Print dialog, no other popups ontop of popups.
>>
>> Some info:
>> http://www.scottklarr.com/topic/15/css-create-a-style-sheet-for-print-only/
>>
>> <
>> http://www.scottklarr.com/topic/15/css-create-a-style-sheet-for-print-only/
>> >
>> http://webdesign.about.com/cs/css/a/aa042103a.htm
>>
>> On Sat, Feb 27, 2010 at 4:54 PM, Alex Rass  wrote:
>>
>> > Josh,
>> >
>> > This doesn't answer your question directly (about a popup).
>> > But a MUCH simpler way is to make your page printer friendly by supplying
>> > an
>> > alternative CSS for printing format (google on that). Makes life much
>> > easier.
>> >
>> > When you tell your page which css to use, you can say "use this CSS for
>> > printing only". All transparent to the user.
>> >
>> > - Alex
>> >
>> >
>> > -Original Message-
>> > From: Josh Chappelle [mailto:jchappe...@4redi.com]
>> > Sent: Friday, February 26, 2010 4:09 PM
>> > To: users@wicket.apache.org
>> > Subject: Print friendly panel
>> >
>> > Hi,
>> >
>> >
>> >
>> > Does anyone know of a suggested method to render a printer friendly panel
>> > to
>> > a separate browser window so that user's can print? The only thing I have
>> > found is the following article and it looks a little clunky.
>> >
>> >
>> >
>> > http://cwiki.apache.org/WICKET/rendering-panel-to-a-string.html
>> >
>> >
>> >
>> > Basically I just need to be able to place a link that when clicked will
>> pop
>> > up a new browser window with only the contents to the target panel. That
>> > way
>> > users can print that panel from there.
>> >
>> >
>> >
>> > Thanks,
>> >
>> >
>> >
>> > Josh
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> > -
>> > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
>> > For additional commands, e-mail: users-h...@wicket.apache.org
>> >
>> >
>>
>

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Print friendly panel

2010-02-28 Thread nino martinez wael
Yeah I agree this is the way it should be done. Works like a charm! And then
just have a simple js like this:


  <!--
  function printpage() {
  window.print();
  }
  //-->


on or link button or whatever..



2010/2/28 Riyad Kalla 

> This is what I've done in the past as well, allows your user to just
> "print"
> the page they are staring at and have the browser do the right thing in
> using an alternative style sheet for rendering the page -- this includes
> using a lot of display:none to trim down the parts of the page that you
> don't want printing. This way all you need on your page is a "Print" link
> that invokes the Print dialog, no other popups ontop of popups.
>
> Some info:
> http://www.scottklarr.com/topic/15/css-create-a-style-sheet-for-print-only/
>
> <
> http://www.scottklarr.com/topic/15/css-create-a-style-sheet-for-print-only/
> >
> http://webdesign.about.com/cs/css/a/aa042103a.htm
>
> On Sat, Feb 27, 2010 at 4:54 PM, Alex Rass  wrote:
>
> > Josh,
> >
> > This doesn't answer your question directly (about a popup).
> > But a MUCH simpler way is to make your page printer friendly by supplying
> > an
> > alternative CSS for printing format (google on that). Makes life much
> > easier.
> >
> > When you tell your page which css to use, you can say "use this CSS for
> > printing only". All transparent to the user.
> >
> > - Alex
> >
> >
> > -Original Message-
> > From: Josh Chappelle [mailto:jchappe...@4redi.com]
> > Sent: Friday, February 26, 2010 4:09 PM
> > To: users@wicket.apache.org
> > Subject: Print friendly panel
> >
> > Hi,
> >
> >
> >
> > Does anyone know of a suggested method to render a printer friendly panel
> > to
> > a separate browser window so that user's can print? The only thing I have
> > found is the following article and it looks a little clunky.
> >
> >
> >
> > http://cwiki.apache.org/WICKET/rendering-panel-to-a-string.html
> >
> >
> >
> > Basically I just need to be able to place a link that when clicked will
> pop
> > up a new browser window with only the contents to the target panel. That
> > way
> > users can print that panel from there.
> >
> >
> >
> > Thanks,
> >
> >
> >
> > Josh
> >
> >
> >
> >
> >
> >
> >
> > -
> > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> > For additional commands, e-mail: users-h...@wicket.apache.org
> >
> >
>


Re: Print friendly panel

2010-02-27 Thread Riyad Kalla
This is what I've done in the past as well, allows your user to just "print"
the page they are staring at and have the browser do the right thing in
using an alternative style sheet for rendering the page -- this includes
using a lot of display:none to trim down the parts of the page that you
don't want printing. This way all you need on your page is a "Print" link
that invokes the Print dialog, no other popups ontop of popups.

Some info:
http://www.scottklarr.com/topic/15/css-create-a-style-sheet-for-print-only/

<http://www.scottklarr.com/topic/15/css-create-a-style-sheet-for-print-only/>
http://webdesign.about.com/cs/css/a/aa042103a.htm

On Sat, Feb 27, 2010 at 4:54 PM, Alex Rass  wrote:

> Josh,
>
> This doesn't answer your question directly (about a popup).
> But a MUCH simpler way is to make your page printer friendly by supplying
> an
> alternative CSS for printing format (google on that). Makes life much
> easier.
>
> When you tell your page which css to use, you can say "use this CSS for
> printing only". All transparent to the user.
>
> - Alex
>
>
> -Original Message-
> From: Josh Chappelle [mailto:jchappe...@4redi.com]
> Sent: Friday, February 26, 2010 4:09 PM
> To: users@wicket.apache.org
> Subject: Print friendly panel
>
> Hi,
>
>
>
> Does anyone know of a suggested method to render a printer friendly panel
> to
> a separate browser window so that user's can print? The only thing I have
> found is the following article and it looks a little clunky.
>
>
>
> http://cwiki.apache.org/WICKET/rendering-panel-to-a-string.html
>
>
>
> Basically I just need to be able to place a link that when clicked will pop
> up a new browser window with only the contents to the target panel. That
> way
> users can print that panel from there.
>
>
>
> Thanks,
>
>
>
> Josh
>
>
>
>
>
>
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>


RE: Print friendly panel

2010-02-27 Thread Alex Rass
Josh, 

This doesn't answer your question directly (about a popup).
But a MUCH simpler way is to make your page printer friendly by supplying an
alternative CSS for printing format (google on that). Makes life much
easier.

When you tell your page which css to use, you can say "use this CSS for
printing only". All transparent to the user.

- Alex


-Original Message-
From: Josh Chappelle [mailto:jchappe...@4redi.com] 
Sent: Friday, February 26, 2010 4:09 PM
To: users@wicket.apache.org
Subject: Print friendly panel

Hi,

 

Does anyone know of a suggested method to render a printer friendly panel to
a separate browser window so that user's can print? The only thing I have
found is the following article and it looks a little clunky.

 

http://cwiki.apache.org/WICKET/rendering-panel-to-a-string.html

 

Basically I just need to be able to place a link that when clicked will pop
up a new browser window with only the contents to the target panel. That way
users can print that panel from there.

 

Thanks,

 

Josh

 

 



-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



RE: Print friendly panel

2010-02-27 Thread Josh Chappelle
Thanks Michael,

I actually got the popup to work by just putting target="_blank" in the
anchor tag. I didn't think about doing it your way.

My main problem is rendering the component into a string as well as to the
browser.

Thanks for your help!

Josh

-Original Message-
From: Michael O'Cleirigh [mailto:michael.ocleir...@rivulet.ca] 
Sent: Friday, February 26, 2010 3:25 PM
To: users@wicket.apache.org
Subject: Re: Print friendly panel

Hi Josh,

I'd create a PrinterFriendlyPage and then use a customized Link from the 
NotPrinterFriendlyPage to have it open in a new window.

Link has this public method where you can setup the PopupSettings class 
that seems to provide the configuration hooks for how the popup should 
work when displayed.

public final Link setPopupSettings(final PopupSettings popupSettings)
 {
 this.popupSettings = popupSettings;
 return this;
 }

Regards,

Mike

> Hi,
>
>
>
> Does anyone know of a suggested method to render a printer friendly panel
to
> a separate browser window so that user's can print? The only thing I have
> found is the following article and it looks a little clunky.
>
>
>
> http://cwiki.apache.org/WICKET/rendering-panel-to-a-string.html
>
>
>
> Basically I just need to be able to place a link that when clicked will
pop
> up a new browser window with only the contents to the target panel. That
way
> users can print that panel from there.
>
>
>
> Thanks,
>
>
>
> Josh
>
>
>
>
>
>
>


-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org


-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Print friendly panel

2010-02-26 Thread Michael O'Cleirigh

Hi Josh,

I'd create a PrinterFriendlyPage and then use a customized Link from the 
NotPrinterFriendlyPage to have it open in a new window.


Link has this public method where you can setup the PopupSettings class 
that seems to provide the configuration hooks for how the popup should 
work when displayed.


public final Link setPopupSettings(final PopupSettings popupSettings)
{
this.popupSettings = popupSettings;
return this;
}

Regards,

Mike


Hi,



Does anyone know of a suggested method to render a printer friendly panel to
a separate browser window so that user's can print? The only thing I have
found is the following article and it looks a little clunky.



http://cwiki.apache.org/WICKET/rendering-panel-to-a-string.html



Basically I just need to be able to place a link that when clicked will pop
up a new browser window with only the contents to the target panel. That way
users can print that panel from there.



Thanks,



Josh






   



-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Print friendly panel

2010-02-26 Thread Josh Chappelle
Hi,

 

Does anyone know of a suggested method to render a printer friendly panel to
a separate browser window so that user's can print? The only thing I have
found is the following article and it looks a little clunky.

 

http://cwiki.apache.org/WICKET/rendering-panel-to-a-string.html

 

Basically I just need to be able to place a link that when clicked will pop
up a new browser window with only the contents to the target panel. That way
users can print that panel from there.

 

Thanks,

 

Josh