Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7732695
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T06:47:41+00:00 2026-06-01T06:47:41+00:00

How would one go about specifying an offset for auto-naming the individual output files?

  • 0

How would one go about specifying an offset for auto-naming the individual output files? This would probably apply to other programs as well, but I need it to work for Ghostscript right now and can provide my example command for reference.

The following command outputs each individual page of a.pdf as an individual .png file (0.png, 1.png, 2.png, etc…) What I would like to do is start with lets say 23.png, 24.png, 25.png, etc… Is there a way I can pass this via command line? Obviously (%d,23).png doesn’t work, but perhaps there’s another way to do this?

gswin32c -q -dNOPAUSE -sDEVICE=tiffg4 -sOutputFile=%d.png a.pdf -c quit

Thanks!

EDIT:
Looks like -dFirstPage does something similar for offsetting the start page of a multi-page input, but I can’t seem to find anything like this for the output.

FINAL EDIT:
I’ll leave this question open for anyone who may want to pitch in with a better idea, however this is what I ended up doing in Python. (This method could probably be applied to any language that has access to the command line)

Output starts at 23.png and loops until a.pdf EOF

import os
from pyPdf import PdfFileReader

offset = 22
totalpages = PdfFileReader.getNumPages()

start = 1

while start <= totalpages:
    os.command('gswin32c -q \
                         -dNOPAUSE \
                         -dFirstPage=start \
                         -dLastPage=start \
                         -sDEVICE=tiffg4 \
                         -sOutputFile='+str(start+offset)+'.png \ 
                          a.pdf \
                         -c \
                          quit')
    start = start+1
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T06:47:42+00:00Added an answer on June 1, 2026 at 6:47 am

    (BTW, you cannot use -o %03d.png to start the output file with 000.png — it will start with 001.png as the first page…. Also, your -sDEVICE=tiffg4 will output TIFF G4 files, not PNG files, regardless of what suffix you use for the output file….)

    I can only think about an ugly workaround to achieve what you want. Since Ghostscript can process various input files and commandline sources in the same commandline, but still write the output in one go, you could pre-process a 22-page file file before the one you are interested in:

     gs \
       -o %03.tiff \
       -sDEVICE=tiffg4 \
        22page.pdf \
        the-real-pdf.pdf
    

    Now simply delete the first 22 TIFF files, and the first page of your real PDF will be in 023.tiff.

    An alternative method would be to do it like this:

     gs \
       -o %03.tiff \
       -sDEVICE=tiffg4 \
       -c "showpage showpage showpage showpage" \
       -c "showpage showpage showpage showpage" \
       -c "showpage showpage showpage showpage" \
       -c "showpage showpage showpage showpage" \
       -c "showpage showpage" \
       -f the-real-pdf.pdf
    

    See the 22 showpage commands? It causes Ghostscript to process 22 empty pages of PostScript input, before the -f the-real-pdf.pdf file gets its turn. Or even better:

     gs \
       -o %03.tiff \
       -sDEVICE=tiffg4 \
       -c "$(for i in $(seq 1 22); do echo showpage; done)" \
       -f the-real-pdf
    

    In order to create PNG files for the TIFFs, just use -sDEVICE=pngalpha (or pngmono, png256 or pnggray)…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How would one go about defining something like this in an xsd? <start> <request
Where would I go about placing partial files shared by more than one model?
How would one go about merging these two .htaccess files? I keep triggering 500
How would one go about either using the 3D components of WPF or using
How would one go about proving to management that a batch reformat of all
How would one go about writing a query that selects items 2000-2010 out of
How exactly would one go about getting an OpenGL app to run fullscreen straight
Conceptually speaking how would one go about writing an achievement system for a website
I was wondering how one would go about developing a website from scratch with
I would like to know how one goes about adding functionality from one open

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.