Overlay two postscript files (command line approach)?

前端 未结 3 2075
闹比i
闹比i 2020-12-31 21:05

I\'m aware that similar questions have been answered here before:

  • postscript - overlay one pdf or ps file on top of another - Stack Overflow
  • overlay -
3条回答
  •  情歌与酒
    2020-12-31 21:55

    Ok, here is what works for me, thanks to @luserdroog's answer, with unchanged files, and "directly" in evince.

    First of all, get tmp-Front.ps, logo.ps and @luserdroog combo.ps (modded below) in a directory. The first problem is that if evince encounters %%EOF, it will stop parsing whatever comes next. So, we first want to get rid of those directives in tmp-Front.ps and logo.ps:

    sed -i 's/%%EOF/% %EOF/' logo.ps
    sed -i 's/%%EOF/% %EOF/' tmp-Front.ps
    

    Second, if evince doesn't encounter %%Orientation and similar directives at the very beginning, then it will not show the document in landscape (as the original tmp-Front.ps is). Thus, we should extract these directives from tmp-Front.ps, and add them at the beginning of combo.ps - and save all that as new file, combopg.ps:

    cat <(echo '%!') <(grep '%%Pages\|%%PageOrder\|%%BoundingBox\|%%DocumentMedia\|%%Orientation' tmp-Front.ps) <(echo) combo.ps > combopg.ps
    

    Here I use the following modification of combo.ps:

    /Oldshowpage /showpage load def
    /showpage {} def
    gsave
        (tmp-Front.ps) run
    grestore
        %additional scaling and translation to place the graphic?
        1 1 scale
        300 300 translate
        0 0 moveto
    
        (logo.ps) run
    Oldshowpage
    

    Finally, since evince doesn't recognize the run directive, I use this modification of psinc, psinc.pl to "include" the contents of the files:

    cat combopg.ps | perl ./psinc.pl > combopgout.ps
    

     

    Now, you can finally open combopgout.ps in evince - and simultaneously in a text editor, where you can look for the line 300 300 translate; editing these arguments in the text editor and saving the file will cause evince to reload the .ps file and show the latest position - it would look like this for the default:

    combopgout.ps.png

    (Note the logo is rotated as per landscape orientation)

     

    Well, I guess this solves it - thanks for the answers!!

提交回复
热议问题