Initial View Property for PDFA - ghostscript

I am using ghostscript to convert my postscript file to PDF/A.
My requirement is to have the Initial View- Magnification property set to Fit Page.
However, the value is set to default always. I have tried different View properties in PDFMarks but none of them seems to be working.
Below is my PDFMarks:
[ /Title (Document title) /DOCINFO pdfmark
[ /PageMode /UseOutlines /View [/Fit] /Page 1 /DOCVIEW pdfmark
I have also tried /FitV,/FitB but none of them seem to be working.

Ghostscript's pdfwrite device converts this pdfmark into an OpenAction in the Catalog. Using your pdfmark code, and an empty page, this appears to work well for me.
So the questions:
Which version of Ghostscript are you using
What is the exact command line you are sending
What makes you think this isn't working ? (How precisely are you
verifying the action ?)

Related

How to add TrimBox and BleedBox without fonts being rasterized

I want Ghostscript to prepare PDFs for print production. The input PDF (Version 1.3) is in RGB, uses transparency and has crop marks.
Convert colors to CMYK by applying an ICC profile
Add a TrimBox and a BleedBox
I managed to achieve the steps above using the following command:
gs -o output.pdf -sDEVICE=pdfwrite -dPDFX -r100 -dOverrideICC=true -sOutputICCProfile=ISOcoated_v2_300_eci.icc -sColorConversionStrategy=CMYK -dProcessColorModel=/DeviceCMYK -dRenderIntent=3 input.pdf -c "[ /PAGES pdfmark << /PDFXSetBleedBoxToMediaBox false /PDFXTrimBoxToMediaBoxOffset [29 29 29 29] /PDFXBleedBoxToTrimBoxOffset [8 8 8 8] >> setdistillerparams" -f
But unfortunately the fonts are getting rasterized.
I found out that -dPDFX causes that.
But it seems like -dPDFX is needed to add the TrimBox and BleedBox. Without -dPDFX the fonts remain unchanged but the boxes won't be added.
I'm on OSX, the PDF contains two Type 3 fonts.
Any help is very appreciated.
OK, a few points:
Ghostscript (and more particularly the pdfwrite device) doesn't add anything to PDF files. It makes brand new PDF files from the supplied input, which may or may not be a PDF file.
The process is described here and I'd suggest you read it. Essentially you cannot assume that the content of the produced PDF file bears any relationship at all to the content of the input, if it's a PDF file.
Your usage of ICC profiles is not causing the conversion to CMYK, that's done by setting ColorConversionStrategy. Your setting of OverrideICC and OutputICCProfile aren't doing anything and you should remove those switches. In addition you should not set ProcessColorModel if you are setting ColorConversionStrategy. Similarly setting RenderIntent does nothing at all with the pdfwrite device, drop that too.
Don't set the resolution. All that does is set the resolution of any content which must be rendered (eg creating a PDF file < version 1.4 from an input file containing transparency). So drop the -r100.
-dPDFX doesn't cause fonts to be rasterised.
If that's happening then it's almost certainly nothing to do with selecting PDFX, without seeing your input file I can't comment further.
-dPDFX is not necessary to create a PDF file with TrimBox or BleedBox.
Of course, what your PostScript actually does is create PDFX Bleed and Trim Offsets, and yes, if you want those then you need to set PDFX, clearly. On the other hand, if you actually want to set normal regular Bleed or Trim boxes then that is also documented in the pdfmark reference (see page 37 of the 1.7 pdfmark reference):
The syntax for specifying a non-default page cropping for a particular
page in a document is as follows:
[ /CropBox [xll yll xur yur]
/PAGE pdfmark The syntax for specifying the default page cropping for a document is as follows:
[ /CropBox [xll yll xur yur]
/PAGES pdfmark
Obviously you would Substitute Bleed or Trim for CropBox.
Update
This command line:
gs -sDEVICE=pdfwrite -sOutputFile=new.pdf /temp/input.pdf -c "[/CropBox [100 100 7568 3784] /PAGES pdfmark" -f
for me produces a PDF file (new.pdf) which has a CropBox in the Pages tree root node. Entries in the Pages tree are inherited by all pages below the node where they are defined and when I open the file with Acrobatm I can see that the crop marks are no longer visible.
So for me, it all works fine, and without using PDFX. Adding -sColorConversionStrategy=CMYK should be enough to get a CMYK file out. And since it isn't using PDF/X, it will maintain the transparency instead of rendering it. Note that since your file is all in DeviceGray, the colour is retained unchanged anyway.
I forgot to say that using /TrimBox instead of /CropBox works perfectly well for me as well, in exactly the same manner.

PostScript, can't see visual output with ghostscript

%!
/Times-Roman 12 selectfont
100 100 moveto
(Hello) show
How can I take the output as PDF and EPS
formatted file.
Your question really needs some editing, its not clear (to me anyway) what your problem is.
You say 'PostScript, can't see visual output with Ghostscript' as the title, and then want to know about 'taking the output'. So which is it ? A problem viewing a PostScript file when using Ghostscript ? Or a problem with the output ?
You can use the eps2write device to get EPS output and the pdfwrite device to get PDF output, as per the documentation. Neither has 'visual output'.

Generating index in pdf using table of content available in pdf

I have a pdf file basically RTC datasheet,
It is not allowing to jump to page using table of content and it doesn't have index or bookmark on the left side panel.
http://www.horustech.com.tw/WebMaster/FileData/Epson/RX8900SA(SA;CE).pdf
Now my question is it possible to update index/bookmark in this pdf using ghostscript or pdftk command ?
You could make a *new** PDF file, and you could add to that a new /Outlines tree (which I believe is called Bookmarks by Acrobat), but you would have to do it by creating a sequence of PostScript pdfmark operations. You would have to build those yourself, there's no way to do it automatically.
You could also (more difficult) /Link annotations to the table of contents so that it could jump to the relevant page/area. Again with Ghostscript you would have to do this by manually creating pdfmark operations.
Again, none of this can be done automatically, creating the pdfmarks would have to be done manually, especially the hyperlinks in the table of contents, those are almost certainly better handled using an interactive program, if you wanted to do that.
I'm reasonably sure you could do this with pdftk too, but again I think you would have to add the Outlines or Links manually.

Using Ghostscript Add watermark to PDF for Print Only

I am creating a program using ghostscript which add watermark(stamp) on pdf file. But I want to know, is it possible to add watermark to pdf which display only on print copy of that pdf not on computer screen?
I believe you can do this by creating an Optional Content Group which has a usage dictionary where the /Print dictionary has a PrintState key with the value ON. You will also want a /View dictionary with a ViewState key which has the value OFF.
You then create an annotation for the watermark and have that annotation be a part of the Optional Content Group created above. That annotation will then print, but will not view.
Note however that it is up to the consuming application to decide whether it is a Viewer or a Printer. Ghostscript, for example, always assumes that it is a Viewer and so uses the ViewState to determine the visibility of optional content groups.
You should be able to construct Optional Content Groups and Annotations by using pdfmark operations. See the Adobe pdfmark reference for more information.

Can I create a PDF which will always opens at zoom level 100%?

I am running into an issue with PNG to PDF conversion.
Actually I have big PNG files not in size but in contents.
In PDF conversion it creates a big PDF files. I don't have any issue with its quality, but whenever I try to open this PDF in PDF viewer, it opens in "Fit to Page" mode.
So, I can't see the created PDF in the initial view, but I need to zoom it up to 100%.
My question is: can I create a PDF which will always open at zoom 100% ?
You can possibly achieve what you want with the help of Ghostscript.
Ghostscript supports to insert PostScript snippets into its command line parameters via -c "...[PostScript code here]...".
PostScript has a special operator called pdfmark. This operator is not understood by most PostScript interpreters, but is understood by Acrobat Distiller and (for most of its parameters) also by Ghostscript when generating PDFs.
So you could try to insert
-c "[ /PageMode /UseNone /Page 1 /View [/XYZ null null 1] \
/PageLayout /SinglePage /DOCVIEW pdfmark"
into a PDF->PDF conversion Ghostscript command line.
Please take note about various basic things concerning this snippet:
The contents of the command line snippet appears to be 'unbalanced' regarding the [ and ] operators/keywords. But it is not! The initial [ is balanced by the final pdfmark keyword. (Don't ask -- I did not define this syntax...)
The 'inner' [ ... ] brackets delimit an array representing the page /View settings you desire.
Not all PDF viewers do respect the view settings embedded in the PDF file (Acrobat software does!).
Most PDF viewers allow users to override the view settings embedded in PDF files (Acrobat software also does this). That is, you can tell your viewer to never respect any settings from the PDF files it opens, but f.e. to always open it with "fit to width".
Some specific things about this snippet:
The page mode /UseNone means: the document displays without bookmarks or thumbnails. It could be replaced by
/UseOutlines (to display bookmarks also, not just the pages)
/UseThumbs (to display thumbnail images of the pages, not just the pages
/FullScreen (to open document in full screen mode)
The array for the view mode constructed as [/XYZ <left> <top> <zoom>] means: The zoom factor is 1 (=100%), the left distance from the page origin is the special 'null' value, which means to keep the previously user-set value; the top distance from the page origin is also 'null'. This array could be replaced by
/Fit (to adapt the page to the current window size)
/FitB (to adapt the visible page content to the current window size)
/FitH <top>' (to adapt the page width to the current window width);` indicates the required distance from page origin to upper edge of window.
...plus several others I cannot remember right now.
So to change the settings of an existing PDF file, you could do the following:
gs \
-o out.pdf \
-sDEVICE=pdfwrite \
-c "[ /PageMode /UseNone /Page 1 /View [ /XYZ null null 1 ] " \
-c " /PageLayout /SinglePage /DOCVIEW pdfmark" \
-f in.pdf
To check if the Ghostscript command worked, open the PDF in a text editor which is capable of handling binary files. Search for the /View or the /PageMode keywords and check if they are there, inserted as values into the PDF root object.
If it worked, check if your PDF viewer honors the settings. If it doesn't honor them, see if there is an overriding setting within the viewers preference settings.
I did a quick test run on a sample PDF of mine. Here is how the PDF root object's dictionary looks now, checked with the help of pdf-parser.py:
pdf-parser-beta.py -s Catalog a.pdf
obj 1 0
Type: /Catalog
Referencing: 3 0 R, 9 0 R
<<
/Type /Catalog
/Pages 3 0 R
/PageMode /UseNone
/Page 1
/View [/XYZ null null 1]
/PageLayout /SinglePage
/Metadata 9 0 R
>>
To learn more about the pdfmark operator, google for 'pdfmark reference filetype:pdf'. You should be able to find it on the Adobe website and elsewhere:
https://www.google.de/search?q=pdfmark%20reference%20filetype%3Apdf&oq=pdfmark%20reference%20filetype%3Apdf
In order to let ImageMagick create a PDF as you want it, you may be able to hack the file defining your delegate settings. For more help about this topic see for example here:
http://www.imagemagick.org/Usage/files/#delegates
PDF specification supports this functionality in this way: create a GoTo action that goes to first page and sets the zoom level to 100% and then set the action as the document open action.
How exactly you implement it in real life depends very much on the tool you use to create the PDF file. I do not know if ImageMagick can create such actions.

Resources