Hi Massimiliano,
it works thank you!

However there are 2 things i do not like:

1) My PDF File is renamed to the same as my Controller function Name plus a 
number and *without the Extension .pdf*. 
Example:* printlanguages+cd123452*

2) After the *"return response.stream()"* my *submit button* that started 
the Output remains pressed until i refresh the url-page manually.

Is there a way to Redirect to the URL after the pdf file was displayed?

Do you or does anybody else have a solution for this?


Am Dienstag, 3. November 2015 12:02:05 UTC+1 schrieb Massimiliano:

> Try this way to display your pdf:
>
> def yourcontroller()
>     # generate pdf 
>     . . . 
>     import cStringIO
>     data = open(filename,"rb").read()
>     response.headers['Content-Type']='application/pdf'     
>     return response.stream(cStringIO.StringIO(data))  
>
>
>
>
> On Mon, Nov 2, 2015 at 4:29 PM, Karl Florian <[email protected] 
> <javascript:>> wrote:
>
>> Hi,
>> i am a newby to web2py and need some help dislaying label in my 
>> application.
>>  
>> I’m using Latex and PSTricks to create my barcode label.pdf files. 
>> The problem is, everthing works ok on local Windows or Ubuntu but not 
>> from my Linux-VServer (WEbServer).
>> The label.pdf is created but not displayed.
>>
>> This my sourccode after the place where i creating my label.pdf file:
>> //********************************************************
>> This does not work on webserver (only in local Systems):
>>  ...............
>>         os.system('latex label.tex')
>>         time.sleep(0.1)
>>         if sys.platform == "win32":
>>              os.system('dvips -o label-pics.ps label.dvi')
>>                 os.system('ps2pdf awblabel-pics.ps label.pdf')
>>                os.startfile('label.pdf')
>>         else:
>>                 # os.system('dvipdf label.dvi')
>>                 os.system('dvips -o awblabel-pics.ps label.dvi')
>>                 os.system('ps2pdf awblabel-pics.ps label.pdf')
>>                if sys.platform == "darwin": subprocess.call(['open', 
>> 'label.pdf'])
>>                 else: subprocess.call(['xdg-open', 'label.pdf'])
>>     return dict(redirect(URL('labelapp', args=req_id)))
>>
>> //********************************************************
>> This works, however my SUBMIT Button does not get released:
>>  ...................
>>  else:
>>     mypdffile=os.path.join(request.folder, 'pdffiles', 'label.pdf' )
>>     pdfdata = open(mypdffile,"rb").read()
>>     os.unlink(mypdffile)
>>     response.headers['Content-Type']='application/pdf'
>>     return pdfdata
>> return dict(redirect(URL('labelapp', args=req_id)))
>>
>> //********************************************************
>>
>> Do i have to use something like *PDFObject.js* or *PDF.js* or is there a 
>> better way to do it?
>> Where can i find examples that use *PDFObject.js* or *PDF.js*?
>> .........................
>>
>> I just can not find any good examples.
>>
>> As i said i am new to web programming and web2py.
>>
>>
>> I think web2py is a cool product.
>> Hope someone can help.
>>
>> -- 
>> Resources:
>> - http://web2py.com
>> - http://web2py.com/book (Documentation)
>> - http://github.com/web2py/web2py (Source code)
>> - https://code.google.com/p/web2py/issues/list (Report Issues)
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "web2py-users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> -- 
> Massimiliano
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to