• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: WOComponent for Displaying PDF Problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: WOComponent for Displaying PDF Problem


  • Subject: Re: WOComponent for Displaying PDF Problem
  • From: Carter Wojcik <email@hidden>
  • Date: Thu, 19 Oct 2006 14:53:25 -0700 (PDT)

Thanks Amedeo -

Sure enough checked my application.java and found the
following:

	public void appendToResponse(WOResponse response,
WOContext context) {
		super.appendToResponse(response,context);

		// amend all pages response to use a UTF-8 character
set

		if
(_NSUtilities.UTF8StringEncoding.equals(response.contentEncoding()))
{
			response.setHeader("text/html; charset=UTF-8",
"Content-Type");
			response.setContentEncoding("UTF-8");
		}
	}

We would like to maintain the utf8 for
internationalization.  After playing around I
discovered that by adding:

	aResponse.setContentEncoding("UTF-8");

in appendToResponse in my pdfviewer component displays
the pdf correctly.

Currently our html headers are empty due to current
conflicts with our CSS (menus do not work):
     <!DOCTYPE PUBLIC="" -//W3C//DTD HTML 3.2//EN=""
HTML="">

Our .woo files contain the info that you recommended.

Thanks for the help.

Carter
--- Amedeo Mantica <email@hidden> wrote:

> Hello
>
> May be a problem in yout application.java Class!!
>
> Make sure you don't have an appendToResponse
> override that set wrong
> header such as: setHeader("text/html;charset=utf-8",
> "Content-Type");
>
> If you need to use UTF-8 encoding... use in
> application.java
>
>      public void appendToResponse(WOResponse r,
> WOContext c) {
>          r.setContentEncoding("UTF-8");
>          super.appendToResponse(r,c);
>      }
>
> then in your html headers add: <meta
> http-equiv="content-type"
> content="text/html;charset=utf-8">
> and in your .woo: {"WebObjects Release" =
> "WebObjects 5.0"; encoding
> = NSUTF8StringEncoding; }
>
>
> regards
> Amedeo
>
> On 16/ott/06, at 17:47, Jacky Gagnon wrote:
>
> > Hi,
> >
> > On 06-10-16, at 09:06, Carter Wojcik wrote:
> >
> >> Hi Amedeo -
> >>
> >> Thanks for the code.  I compared your code to
> mine and
> >> they are the same.  Now when I go to the output
> page I
> >> get the following displayed:
> >>
> >> %PDF-1.3 %????????? 2 0 obj << /Length 4 0 R
> /Filter
> >> /FlateDecode >> stream
> >>
>
x??}[?\???;~E?l;<??2???$?=#???"?B?E?v????????8????Y-?U????H
> >>
>
3?D?????e???;?N?????uxwx??q??p??7;??6??&4{??K???#_l?
>
> >> \??2ke??[&?
> >>
>
]??!6Hb"<?,6??Si?B???S???q??G?y??w?K??X????j?a5?zgQ[??ML?D??x
>
> >> AK?+b????{.+p????[?:?
> >>
>
bC?|J??x????X???#*+i?&Mr(ld?Y<???????L?b????v??bF?iV?[Z???-5?
>
> >> V7?d????}
> >> ?\?? ..........
> >>
> >
> > This is your PDF data.
> >
> >> This is just the first couple of lines.  When
> viewing
> >> the source of the page it is the same as what is
> >> displayed on the page.  There is no html header
> >> information in the source. Is this ok?
> >
> >
> > There is no html header in a PDF document.
> >
> > If you set correctly the content type
> ("application/pdf"), safari
> > is supposed to open the document with the PDF
> plug-in.
> > Try to save the file on your desktop and open it
> with Preview or
> > Acrobat Reader to see if they recognize the
> document.
> >
> > Did you check your run log for error/warning when
> you call pdfData()?
> >
> > Good Luck!
> >
> >
> >>
> >>
> >> Here is my code for the output page:
> >>
> >> _pdfData and _fileName are being set on the
> previous
> >> page
> >>
> >> public class PDFViewer extends WOComponent {
> >>
> >>     private NSData _pdfData;
> >>     private String _fileName;
> >>
> >>     public PDFViewer(WOContext context) {
> >>         super(context);
> >>     }
> >>
> >>     public void setPdfData(NSData newPDFData) {
> >>         _pdfData = newPDFData;
> >>     }
> >>
> >>     public NSData pdfData() {
> >>         return _pdfData;
> >>     }
> >>
> >>     public void setFileName(String aFileName) {
> >>         _fileName = aFileName;
> >>     }
> >>
> >>     public String fileName() {
> >>         return _fileName;
> >>     }
> >>
> >> 	public void appendToResponse(WOResponse
> aResponse,
> >> WOContext arg1) {
> >> 		super.appendToResponse(aResponse, arg1);
> >>
> >> 		if (pdfData() != null) {
> >> 			aResponse.disableClientCaching();
> >>
> aResponse.removeHeadersForKey("Cache-Control");
> >> 			aResponse.removeHeadersForKey("pragma");
> >> 			aResponse.setHeader("application/pdf",
> >> "content-type");
> >> 			aResponse.setHeader("inline; attachment;
> >> filename=\""+fileName()+"\"",
> "content-disposition");
> >>
> >>
>
aResponse.setHeader(Integer.toString(pdfData().length()),
> >> "content-length");
> >> 			aResponse.setContent(pdfData());
> >> 		}
> >> 	}
> >> }
> >>
> >> Thanks for the help.
> >>
> >> Carter
> >>
> >> --- Amedeo Mantica <email@hidden>
> wrote:
> >>
> >>> Hi carter
> >>>
> >>> look at this code in pdf output page
> >>>
> >>> data is an NSData condaining the PDF data!!
> >>>
> >>>
> >>> 	public void appendToResponse(WOResponse
> response,
> >>> WOContext context)
> >>> 	{
> >>> 		super.appendToResponse(response, context);
> >>> 		if(data!=null) {
> >>> 			response.disableClientCaching();
> >>>
> response.removeHeadersForKey("Cahce-Control");
> >>> 			response.removeHeadersForKey("pragma");
> >>>
> >>>
> >>
>
response.setHeader("application/pdf","content-type");
> >>> 			response.setHeader("inline; attachment;
> >>> filename=\"generated.pdf
> >>> \"","content-disposition");
> >>>
> >>>
> >>
>
response.setHeader(Integer.toString(data.length()),"content-lenght");
> >>> 			response.setContent(data);
> >>> 		}
> >>> 	}
> >>>
> >>>
> >>>
> >>>
> >>> On 13/ott/06, at 15:30, Carter Wojcik wrote:
> >>>
> >>>> Hi All -
> >>>>
> >>>> I have followed Chuck Hill's example for
> >>> generating a
> >>>> PDF in Practical WebObjects Chapter 11 XML and
> >>>> WebObjects to create a WOComponent to retrieve
> a
> >>> pdf
> >>>> from my database and display it in Safari. The
> >>> problem
> >>>> I am having is that when the component is
>
=== message truncated ===


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Re: WOComponent for Displaying PDF Problem (From: Amedeo Mantica <email@hidden>)

  • Prev by Date: Obscure Primary Key Gotcha
  • Next by Date: Re: stack overflow error
  • Previous by thread: Re: WOComponent for Displaying PDF Problem
  • Next by thread: Tomcat SSDD Development/Deployment
  • Index(es):
    • Date
    • Thread