can I create a PDF which will always open at zoom 100% ?

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
Abhijit_Muke
Posts: 1
Joined: 2015-01-28T02:43:54-07:00
Authentication code: 6789

can I create a PDF which will always open at zoom 100% ?

Post by Abhijit_Muke »

Hello ImageMagick, I am running with an issue in png to pdf conversion.Actually I have big png file not in size but in contents.In pdf conversion it create a big pdf file. I don't have any issue with its quality, but whenever I try to open this pdf in PDF viewer, it make it Fit to Page. So, I can't see created PDF in my first view, I need to zoom it upto 100%.

So my question is, can I create a PDF which will always open at zoom 100% ?

Thanks.

snibgo
Posts: 12910
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: can I create a PDF which will always open at zoom 100% ?

Post by snibgo »

[Mod note: moved to Users forum.]
snibgo's IM pages: im.snibgo.com

pipitas
Posts: 168
Joined: 2012-07-15T14:06:46-07:00
Authentication code: 15

Re: can I create a PDF which will always open at zoom 100% ?

Post by pipitas »

From my rusty memory, the following additional parameter to a Ghostscript command (when running a recent v9.xx version of Ghostscript!) should set the initial view parameters for the viewer:

Code: Select all

-c "[ /PageMode /UseNone /Page 1 /View [ /XYZ null null 1 ] /PageLayout /SinglePage /DOCVIEW pdfmark"
Please take note about various basic things concerning this:
  • This '-c ...' is a PostScript snippet using the special 'pdfmark' operator. It leads Ghostscript to insert the PDF code required for the view settings into the PDF root object (= '/Type /Catalog').
  • 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...)
  • 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: 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; '<top>' 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:

Code: Select all

gs \
  -o out.pdf \
  -sDEVICE=pdfwrite \
  -c "[ /PageMode /UseNone /Page 1 /View [ /XYZ null null 1 ] /PageLayout /SinglePage /DOCVIEW pdfmark" \
  -f in.pdf
To see if the command worked, open the PDF in a text editor 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.

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: 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:

Post Reply