[Mapserver-users] Pdf output shows junk on the browser?

Antti.Roppola at brs.gov.au Antti.Roppola at brs.gov.au
Tue Jun 15 04:38:24 EDT 2004


Hi Mahalakshmi,

What you are seeing appears to be a PDF file. Some things to try:

 - Save it to a file and try opening the file with Acrobat
   (to confirm that it is a valid PDF)

   Yes, to answer your question, you can save the generated PDF as a
   file, I do it by calling Mapserver as a system call and capturing
   the output to a file.

 - Grab the saved file and echo it as a download:

<?php
	$file="/path/to/mypdf.pdf";
	$handle=fopen($filename, "r");
	$buf=fread($handle, filesize($filename));
	$len = strlen($buf);
	Header("Content-type:application/pdf");
	Header("Content-Length:$len");
	Header("Content-Disposition:inline; filename=my_map.pdf");
	echo $buf;
	fclose($buf);
?>

I just tested this using IE 6.0 and Mozilla 1.x, while Mozilla
recognises the stream as a PDF and asks me if I want to open it
in xpdf or to save the file, IE just echoes the contents of the
PDF (as shown in your email)

 - Save the created PDF to the web-server and send the user a
   URL to click on. I tried this, and IE handles that OK.

Aka, it seems to be something broken about how IE recognises PDFs
in general. A quick look arounf IE doesn't reveal anything like
the "helper applications" in Mozilla that lets you see how incoming
mime-types are handled.

Cheers,

Antti

-----Original Message-----
From: Mahalakshmi Narayanan [mailto:mhln25 at yahoo.com]
Sent: Tuesday, 15 June 2004 2:54 PM
To: Antti.Roppola at brs.gov.au; EZS at DeStraat.NL;
mapserver-users at lists.gis.umn.edu
Subject: RE: [Mapserver-users] Pdf output shows junk on the browser?


Thanks for the reply.. 

However, my problem is still unresolved..
The junk starts with ...
------------------
%PDF-1.3 %äãÏÒ 5 0 obj <> stream xoe3T0BC 650PHÎå2 èB(
ß)"ËH!¤^Ë5" ´!pendstream endobj 6 0 obj 40 endobj 7 0
obj <>] /Length 8 0 R >> stream
ÿØÿàJFIFÿþ;CREATOR: gd-jpeg v1.0 (using IJG JPEG
v62), quality = 95
ÿÛC    
ÿÛC 
ÿÀô"ÿÄ
ÿĵ}!1AQa"q2'¡#B±ÁRÑð$3br'
%&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyzf"...??^?S'""*--~(tm)s¢£¤¥¦§¨©ª²³´µ¶·¸¹ºÂÃÄÅÆÇÈÉÊÒÓÔÕÖ×ØÙÚáâãäåæçèéêñòóôõö÷øùúÿÄ
ÿĵw!1AQaq"2B'¡±Á #3RðbrÑ
$4á%ñ&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz'f"...??^?S'""*--~(tm)s¢

-------------

I visited all sites suggested by Emil Zegers, but not
still solved..
I have windows xp with acrobat reader 6 installed. My
ie settings seem to be ok 'cos I am able to open other
pdf documents.. I don't know how to save as pdf
document using map file itself (from command prompt)
then try to open it.. is it possible to do that?

Thanks again..

With kind regards,
Mahalakshmi Narayanan

--- Antti.Roppola at brs.gov.au wrote:
> What sort of junk?
> 
> If it looks like this, you are getting a PDF file,
> but it is not
> being recognised by the end-user as one:
> 
>    %PDF-1.3
>    %äãÏÒ
>    5 0 obj
>    <</Length 6 0 R
>    /Filter/FlateDecode
>    >>
>    stream
>   
>
x~\~D½I²$I®$¸~OS¼^K´~SÌö~Iê^Fu^BëEmÂ6ÿþ~K^F3CÌó©À²èS~÷~@«ªÉ~H~Q^Aä~_
> 
> 
> I have noticed that the PDF output file includes a
> MIME header
> in the first couple of lines. Depending on how you
> are generating
> and sending the file, this might be a problem. If
> so, try open the
> PDF file and delete everything before "%PDF-" before
> sending it to
> the browser. Also try opening the file from your PDF
> reader. Aka,
> the first thing to do is confirm that a valid PDF
> file is being created.
> 
> Cheers,
> 
> Antti
> 
> -----Original Message-----
> From: Emil Zegers [mailto:EZS at DeStraat.NL]
> Sent: Friday, 11 June 2004 5:38 PM
> To: mapserver-users at lists.gis.umn.edu;
> mhln25 at yahoo.com
> Subject: Re: [Mapserver-users] Pdf output shows junk
> on the browser?
> 
> 
> Hello 
> 
> If your PDF configuration in the map file is correct
> and you do have installed Adobe Acrobat and/or
> Reader, the problem might be caused by some browser
> related issues.
> 
> Especially recent IE versions have trouble
> displaying server side (created) PDF's properly.
> 
> Take a look at the following links for more info:
> 
> http://www.adobe.com/support/techdocs/29776.htm
> 
>
http://forum.planetpdf.com/wb/default.asp?action=9&fid=6&read=41191
> 
> http://www.bnl.gov/itd/webapps/pdf_help.asp
> 
> 
> Groeten,
> 
> Emil Zegers
> 
> De Straat Milieu-adviseurs
> Divisie Informatisering
> 026 7513902
> 06 22965585
> http://www.destraat.nl
> 
> >>> Mahalakshmi Narayanan <mhln25 at yahoo.com>
> 06/11/04 08:09 AM >>>
> Hi!
> 
> I tried to output my map as a pdf but I get junk
> thrown to me when I include the following
> outputformat
> tag..
> -------------------
> OUTPUTFORMAT
>   NAME pdf
>   MIMETYPE "application/x-pdf"
>   DRIVER pdf
>  # FORMATOPTION "OUTPUT_TYPE=RASTER"
>   EXTENSION "pdf" 
> END
> -------------------
> I am running windows xp with 
> --------------
> MapServer version 4.0.2 OUTPUT=GIF OUTPUT=PNG
> OUTPUT=JPEG OUTPUT=WBMP OUTPUT=PDF
>  OUTPUT=SWF SUPPORTS=PROJ SUPPORTS=FREETYPE
> SUPPORTS=WMS_SERVER SUPPORTS=WMS_CLI
> ENT SUPPORTS=WFS_SERVER SUPPORTS=WFS_CLIENT
> INPUT=EPPL7 INPUT=POSTGIS INPUT=OGR
> INPUT=GDAL INPUT=SHAPEFILE
> ------------------
> 
> do i need anything else to be installed on my box to
> get pdf output?
> 
> can somebody help me, pls.
> 
> With regards,
> Mahalakshmi Narayanan
> 
> 
> 
> 	
> 		
> __________________________________
> Do you Yahoo!?
> Friends.  Fun.  Try the all-new Yahoo! Messenger.
> http://messenger.yahoo.com/ 
> _______________________________________________
> Mapserver-users mailing list
> Mapserver-users at lists.gis.umn.edu
>
http://lists.gis.umn.edu/mailman/listinfo/mapserver-users
> 
> __________
> VChecked
> 
> 
>
______________________________________________________
> 
>  This message has been checked for all known viruses
>
______________________________________________________
> 
> _______________________________________________
> Mapserver-users mailing list
> Mapserver-users at lists.gis.umn.edu
>
http://lists.gis.umn.edu/mailman/listinfo/mapserver-users
> 



	
		
__________________________________
Do you Yahoo!?
Friends.  Fun.  Try the all-new Yahoo! Messenger.
http://messenger.yahoo.com/ 




More information about the mapserver-users mailing list