{
    "mode": "man",
    "parameter": "pdftosrc",
    "section": "1",
    "url": "https://www.chedong.com/phpMan.php/man/pdftosrc/1/json",
    "generated": "2026-06-03T00:21:23Z",
    "synopsis": "pdftosrc PDF-file [stream-object-number]",
    "sections": {
        "NAME": {
            "content": "pdftosrc - extract source file or stream from PDF file\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "pdftosrc PDF-file [stream-object-number]\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "If  only  PDF-file  is given as argument, pdftosrc extracts the embedded source file from the\nfirst found stream object with /Type /SourceFile within the PDF-file and writes it to a  file\nwith  the  name /SourceName as defined in that PDF stream object (see application example be‐\nlow).\n\nIf both PDF-file and stream-object-number are given as arguments, and stream-object-number is\npositive,  pdftosrc  extracts  and  uncompresses  the  PDF  stream of the object given by its\nstream-object-number from the PDF-file and writes it to a file named  PDF-file.stream-object-\nnumber with the ending .pdf or .PDF stripped from the original PDF-file name.\n\nA  special  case  is  related  to  XRef object streams that are part of the PDF standard from\nPDF-1.5 onward: If stream-object-number equals -1, then pdftosrc decompresses the XRef stream\nfrom  the PDF file and writes it in human-readable PDF cross-reference table format to a file\nnamed PDF-file.xref (these XRef streams can not be extracted just by giving their object num‐\nber).\n\nIn any case an existing file with the output file name will be overwritten.\n",
            "subsections": []
        },
        "OPTIONS": {
            "content": "None.\n",
            "subsections": []
        },
        "FILES": {
            "content": "Just the executable pdftosrc.\n",
            "subsections": []
        },
        "ENVIRONMENT": {
            "content": "None.\n",
            "subsections": []
        },
        "DIAGNOSTICS": {
            "content": "At success the exit code of pdftosrc is 0, else 1.\n\nAll messages go to stderr.  At program invocation, pdftosrc issues the current version number\nof the program xpdf, on which pdftosrc is based:\n\npdftosrc version 3.01\n\nWhen pdftosrc was successful with the output file writing, one of the following messages will\nbe issued:\n\nSource file extracted to source-file-name\n\nor\n\nStream object extracted to PDF-file.stream-object-number\n\nor\n\nCross-reference table extracted to PDF-file.xref\n\n\nWhen  the object given by the stream-object-number does not contain a stream, pdftosrc issues\nthe following error message:\n\nNot a Stream object\n\nWhen the PDF-file can't be opened, the error message is:\n\nError: Couldn't open file 'PDF-file'.\n\nWhen pdftosrc encounters an invalid PDF file, the error message (several lines) is:\n\nError: May not be a PDF file (continuing anyway)\n(more lines)\nInvalid PDF file\n\nThere are also more error messages from pdftosrc for various kinds of broken PDF files.\n",
            "subsections": []
        },
        "NOTES": {
            "content": "An embedded source file will be written out unchanged, i. e. it will not be  uncompressed  in\nthis process.\n\nOnly the stream of the object will be written, i. e. not the dictionary of that object.\n\nKnowing  which stream-object-number to query requires information about the PDF file that has\nto be gained elsewhere, e. g. by looking into the PDF file with an editor.\n\nThe stream extraction capabilities of pdftosrc (e. g. regarding understood PDF  versions  and\nfilter types) follow the capabilities of the underlying xpdf program version.\n\nCurrently  the  generation number of the stream object is not supported.  The default value 0\n(zero) is taken.\n\nThe wording stream-object-number has nothing to do with the `object  streams'  introduced  by\nthe Adobe PDF Reference, 5th edition, version 1.6.\n",
            "subsections": []
        },
        "EXAMPLES": {
            "content": "When  using  pdftex,  a source file can be embedded into some PDF-file by using pdftex primi‐\ntives, as illustrated by the following example:\n\n\\immediate\\pdfobj\nstream attr {/Type /SourceFile /SourceName (myfile.zip)}\nfile{myfile.zip}\n\\pdfcatalog{/SourceObject \\the\\pdflastobj\\space 0 R}\n\nThen this zip file can be extracted from the PDF-file by calling pdftosrc PDF-file.\n",
            "subsections": []
        },
        "BUGS": {
            "content": "Not all embedded source files will be extracted, only the first found one.\n\nEmail bug reports to pdftex@tug.org.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "xpdf(1), pdfimages(1), pdftotext(1), pdftex(1),\n",
            "subsections": []
        },
        "AUTHORS": {
            "content": "pdftosrc written by Han The Thanh, using xpdf functionality from Derek Noonburg.\n\nMan page written by Hartmut Henkel.\n",
            "subsections": []
        },
        "COPYRIGHT": {
            "content": "Copyright (c) 1996-2006 Han The Thanh, <thanh@pdftex.org>\n\nThis file is part of pdfTeX.\n\npdfTeX is free software; you can redistribute it and/or modify it under the terms of the  GNU\nGeneral  Public License as published by the Free Software Foundation; either version 2 of the\nLicense, or (at your option) any later version.\n\npdfTeX is distributed in the hope that it will be useful, but WITHOUT ANY  WARRANTY;  without\neven  the  implied  warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License along with pdfTeX; if  not,\nwrite  to  the  Free  Software  Foundation,  Inc.,  59  Temple  Place,  Suite 330, Boston, MA\n02111-1307  USA\n\n\n\nWeb2C 2022/dev                              16 June 2015                                 pdftosrc(1)",
            "subsections": []
        }
    },
    "summary": "pdftosrc - extract source file or stream from PDF file",
    "flags": [],
    "examples": [
        "When  using  pdftex,  a source file can be embedded into some PDF-file by using pdftex primi‐",
        "tives, as illustrated by the following example:",
        "\\immediate\\pdfobj",
        "stream attr {/Type /SourceFile /SourceName (myfile.zip)}",
        "file{myfile.zip}",
        "\\pdfcatalog{/SourceObject \\the\\pdflastobj\\space 0 R}",
        "Then this zip file can be extracted from the PDF-file by calling pdftosrc PDF-file."
    ],
    "see_also": [
        {
            "name": "xpdf",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/xpdf/1/json"
        },
        {
            "name": "pdfimages",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/pdfimages/1/json"
        },
        {
            "name": "pdftotext",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/pdftotext/1/json"
        },
        {
            "name": "pdftex",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/pdftex/1/json"
        }
    ]
}