[Catalyst] Extra characters inserted into PDF output

Dr. Jennifer Nussbaum bg271828 at yahoo.com
Tue Dec 2 16:02:18 GMT 2008


Ive been working for a while to try to diagnose a problem with PDF display; i sent some messages to the list with the title "PDF upload problems (probably OT)", and Tom Doran has helped me a lot offlist.

After a lot of work and help from other people, ive sort of figured out what seems to be happening but still have no idea why, and if anyone has an idea im very eager to hear it!

My PDF files are being uploaded and saved in the database apparently correctly. Then what seems to be happening is that somewhere in the binary stream of PDF, there is a (random) sequence of "<!", and somewhere later there is a ">". And something is inserting a "--" before the ">".

In other words something is apparently interpreting this as XML or HTML and trying to be 'helpful' by fixing malformed comments.

But i cant tell where this is happening. Ive now looked at it with four different browsers on three different operating systems and two different PDF renderers, and in all cases the output has those extra bytes, these dashes inserted as if to close HTML comments. 

My debugging statements show that Catalyst is outputting the correct size of the file, which suggests that the insertion is happening elsewhere. My view method looks like this:

sub view_document : Local {
  my ( $self, $c, $id ) = @_;
  my $source = $c->model->find($id);
  my $document = $source->document; # overloaded to $document->document
  $c->log->debug("Document contents were " . length($document) . " bytes");
  $c->res->output($document);
  $c->res->headers->content_type($document->type); # this is 'application/pdf' but setting this manually has no effect
  $c->res->headers->header('Content-Disposition' => "attachment; filename=".$document->filename); # dropping this also has no effect
}

Any ideas?

Thanks!

Jen


      



More information about the Catalyst mailing list