postscript

PDF crop even-odd pages with PHP + GhostScript

不羁岁月 提交于 2019-12-02 03:46:07
I am working in a routine for crop PDF's and import them into a PDF template. I am using GhostScript, invoked with exec() from a PHP script, and FPDI. All running server-side. So far, I am able to crop pdf documents with GhostScript using the procedure explained in this post (setting CropBox ). The next step is to crop differently the even and odd pages of a document. So I tried the method explained in this other post in SuperUser site, passing custom PostScript code into -c parameter to GhostScript: -c "<< /CurrPageNum 1 def /Install { /CurrPageNum CurrPageNum 1 add def CurrPageNum 2 mod 1 eq

Understanding recursive Koch Snowflake function in Postscript

最后都变了- 提交于 2019-12-02 01:39:31
I have followiong program in PostScript which I am having difficutly in understanding. /kochR { 2 copy ge {dup 0 rlineto} { 3 div 2 copy kochR 60 rotate 2 copy kochR -120 rotate 2 copy kochR 60 rotate 2 copy kochR } ifelse pop pop } def 0 0 moveto 27 81 kochR 0 27 moveto 9 81 kochR 0 54 moveto 3 81 kochR 0 81 moveto 1 81 kochR stroke My questions on above program are: What does 2 copy ge { dup 0 rlineto } mean here? How does ifelse work here and what is the condition? What does 3 div do here? What does the 2 copy KochR statement perform here? What does 2 copy ge { dup 0 rlineto } mean here? As

Tracking Code Into a PDF or PostScript File

落爺英雄遲暮 提交于 2019-12-01 18:12:01
Is there a way to track when a PDF is opened? Perhaps by embedding some script into the pdf itself? I saw the question below, and I suppose the answer is "no" for javascript, but I am wondering if this is possible at all. Google analytics tracking code insert in pdf file The PDF standard includes support for JavaScript but as @Wes Hardaker pointed out, not every PDF reader supports it. However, sometimes some is better than none. Here's Adobe's official Acrobat JavaScript Scripting Guide . What's probably most interesting to you is the doc object which has a method called getURL() . To use it

Tracking Code Into a PDF or PostScript File

亡梦爱人 提交于 2019-12-01 18:08:41
问题 Is there a way to track when a PDF is opened? Perhaps by embedding some script into the pdf itself? I saw the question below, and I suppose the answer is "no" for javascript, but I am wondering if this is possible at all. Google analytics tracking code insert in pdf file 回答1: The PDF standard includes support for JavaScript but as @Wes Hardaker pointed out, not every PDF reader supports it. However, sometimes some is better than none. Here's Adobe's official Acrobat JavaScript Scripting Guide

Conversion of TIFF to PDF with Ghostscript

人走茶凉 提交于 2019-12-01 17:28:29
Could you tell me how can I convert TIFF to PDF with using Ghostscript or Postscript? I tried to use this command: gswin32c.exe -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=o.pdf test.tif But it doesn't work. It produces an error: GPL Ghostscript 9.06 (2012-08-08) Copyright (C) 2012 Artifex Software, Inc. All rights reserved. This software comes with NO WARRANTY: see the file PUBLIC for details. Error: /undefined in II* Operand stack: Execution stack: %interp_exit .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- --nostringval-- --nostringval-- false

Conversion of TIFF to PDF with Ghostscript

给你一囗甜甜゛ 提交于 2019-12-01 16:14:05
问题 Could you tell me how can I convert TIFF to PDF with using Ghostscript or Postscript? I tried to use this command: gswin32c.exe -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=o.pdf test.tif But it doesn't work. It produces an error: GPL Ghostscript 9.06 (2012-08-08) Copyright (C) 2012 Artifex Software, Inc. All rights reserved. This software comes with NO WARRANTY: see the file PUBLIC for details. Error: /undefined in II* Operand stack: Execution stack: %interp_exit .runexec2 --nostringval-

How can I extract color values from an EPS file?

大城市里の小女人 提交于 2019-12-01 13:40:17
I'm trying to find all fill and stroke values used in an EPS file. I can parse the file, I just can't figure out how color values are defined in the EPS postscript section. I have converted the file to SVG (using ghostscript) and I can get the hex values, but an EPS to SVG conversion with a gradient produces files 20x the size. Is there a standard format for color values in postscript that I can extract from an EPS file? KenS PostScript is a programming language, not a simple file format, so there is no simple way to determine what is going on in the program. A gradient may well be defined as

Resize A4 PDF to SRA4 and center content

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-01 11:06:51
I'd like to be able to resize an A4 PDF to the slightly bigger SRA4 format, used by printing professionals. The content shouldn't be resized, but only centered. In other words, I'd like to add margins to my A4 document. I managed more or less to do that with this Ghostscript (9.05) call: gs -dPDFSETTINGS=/default -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=out.pdf -dDEVICEWIDTHPOINTS=637 -dDEVICEHEIGHTPOINTS=907 -dFIXEDMEDIA in.pdf The problem is that the A4 content is not centered in the SRA4 page, but is placed at the bottom left corner. Any idea how to center the content? plang I

How to “decode” eexec of font file?

人走茶凉 提交于 2019-12-01 06:14:10
I have a .pfa font file and I would like to read the "algorithm" for rendering the font. However, most of the information is hidden in binary in the line: currentfile eexec 743F8413F3636CA85A9FFEFB50B4BB27302A5F6C876586CCC1670A7EF5521E6ADE15AAB4 DD2DDDB83735311FC63DB80D2C96AECFA05BB67F865EA35934B4B79A203A8DD489B09C79 FF6EB9DBCFD889C3E73F8C94BC342AF671D6F688870A62EE1A0DF216E150FFEC64A8C2B7 509AD05C011599C1AD84E6C4B668E07EA219BD72663D8AF4CA8EC8E23AA90DE90BE940C6 6DB849CEDB3B64961365A7CCE47F4FC9E30FDEE4B14B90C2E0D8C344EBC974EABF417B3D

How can you get the height metric of a string in PostScript?

折月煮酒 提交于 2019-11-30 23:13:28
问题 You can obtain the width of a string in the current font with stringwidth and although this actually pushes offset coordinates on the stack, the y-value always seems to be useless. Is there a way to determine the exact height of a string, that may or may not include descenders? 回答1: stringwidth , as it says, doesn't return string's height. (In all cases I looked at, the second integer on the stack after executing stringwidth was 0 -- for strings that run in horizontal direction.) stringwidth