• 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: Returning a PDF file
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Returning a PDF file


  • Subject: Re: Returning a PDF file
  • From: "Daniele Corti" <email@hidden>
  • Date: Wed, 28 Mar 2007 18:00:45 +0200



2007/3/28, Johann Werner <email@hidden>:
I found the cause of the problems to correctly display an inline pdf.
Apparently the header information "application/pdf" is overwritten by
Apache to "text/html". I suppose that it does so because the URL
doesn't end with ".pdf" but ends with the context ID.

I don't think so... but, to be sure, try to return the response as a WOComponent throught a Direct Action:

e.g.

yourLink: WOHyperlink
{
   directActionName = "donwload";
}

public WOActionResult downloadAction()
{
      ///obtain your NSData aktPDF
     ComponentEmpty c = (ComponentEmpty) pageWithName("ComponentEmpty");
     c.setAktPDF(aktPDF);
    return c;
}

public class ComponentEmpty extends WOComponent
{
    private NSData _aktPDF;
    public ComponentEmpty(WOContext aContext)
    {
       super(aContext);
    }

    public NDData aktPDF()
    {
       return _aktPDF;
     }

    public void setAktPDF(NSData newaktPDF)
     {
        _aktPDF = newaktPDF;
     }

     public void appendToResponse(WOResponse aResponse, WOContext context)
     {
          aResponse.disableClientCaching();
        aResponse.removeHeadersForKey("cache-control");
        aResponse.removeHeadersForKey("pragma");
        aResponse.setHeader ("application/pdf", "content-type");
       aResponse.setHeader("Report PDF", "content-description");
        aResponse.setHeader("inline; filename=\"" + --> your PDF
file name <-- + ".pdf\"", "content-disposition");
       aResponse.setHeader( --> your PDF file length <--, "content-length");
        aResponse.setContent( --> your PDF <-- );
        /////DO NOT CALL SUPER.APPENDTORESPONSE()
     }
}

This should work...

How can I prevent Apache from ignoring the headers from WO or is it
possible to return a WOComponent (the PDF file) but with a
"corrected" URL?

Johann
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription: email@hidden



--
Daniele Corti
AIM: S0CR4TE5
Messenger: email@hidden
 _______________________________________________
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

  • Follow-Ups:
    • Re: Returning a PDF file
      • From: Johann Werner <email@hidden>
References: 
 >Re: Returning a PDF file (From: Johann Werner <email@hidden>)

  • Prev by Date: Re: Returning a PDF file
  • Next by Date: Re: Returning a PDF file
  • Previous by thread: Re: Returning a PDF file
  • Next by thread: Re: Returning a PDF file
  • Index(es):
    • Date
    • Thread