Forum How do I...?

Prince command line : StdIn to send CSS file

hugo.doucet
Hello,
I know it it possible to use "-" to send the input file via stdin to prince.
This is done with following python code :

p = Popen(["prince "-","out.pdf], stdin=PIPE)
p.stdin.write(code.encode('utf-8')) # code is a string with HTML data
..

But i would like to stream my CSS-data also via stdin.
I've comme up with following python code :

p = Popen(["prince","-s","-","-","out.pdf"], stdin=PIPE)
p.stdin.write(stylesheet) # stylesheet is a string with CSS data
p.stdin.write(code.encode('utf-8')) # code is a string with HTML data

When i run this i get following error :
prince: loading style sheet: -
prince: debug: error loading resource: can't open input file: No such file or directory
prince: -: warning: can't open input file: No such file or directory

Must i conclude that the '-' argument only counts for a prince input file.
And cannot be used with a -s option.

Or i am doing something wrong ?
mikeday
It's a bit tricky to send two inputs through the same pipe; how can the receiving program tell where one input ends and the next begins?

Latest builds of Prince have a new control interface which allows multiple resources to be sent over a single channel, but it is significantly more complex to use.

Perhaps you could just prepend the stylesheet at the beginning of the input document, wrapped in <style> tags? Then you could send everything in one stream.
hugo.doucet
Point taken.
My goal was to avoid using filesystems since all my HTML code is dynamically generated.
Initially my css info was a separate file and i linked to it from my html-code.
I have changed this.
I have now added a <style>-element in the main HTML-file that holds all the style data.
Tx for the tip