How include img in postscript

后端 未结 3 1878
盖世英雄少女心
盖世英雄少女心 2020-12-10 08:03

I want to add image to my postscript code

%!PS-Adobe-3.0

/Times-Roman findfont
12 scalefont setfont

50 700 moveto
(text) show
showpage

bu

3条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-10 08:43

    I would suggest a simple way - run an EPS file.
    First, convert the image to EPS, ex. myimage.eps, save it in myfolder and then modify your code to define placeEPS operator and display myimage.eps by using it.

    %!PS-Adobe-3.0
    
    % Place EPS image definition
    % Syntax:     placeEPS
    % =============================================================
    /placeEPS 
    {
        userdict begin
    
        /__be_state     save            def
        /__ds_count     countdictstack  def
        /__os_count     count 5 sub     def
        /showpage       {}              def
    
        initgraphics
        translate 
        dup scale 
        run
    
        count           __os_count sub  { pop } repeat
        countdictstack  __ds_count sub  { end } repeat
                        __be_state              restore
        end
    } bind def
    % =============================================================
    
    % Your old code starts here
    /Times-Roman findfont
    12 scalefont setfont
    50 700 moveto
    (text) show
    
    % Now mark myimage.eps scaled to 100% at position 100, 100
    (myfolder/myimage.eps) 1 100 100 placeEPS
    
    showpage
    

    Now convert to PDF by Acrobat Distiller or GhostScript.
    You can also use this approach to place a full-page canvas to a document.

提交回复
热议问题