autosave batch documents printed to PDF24 with different filenames

Home › Forums › General › autosave batch documents printed to PDF24 with different filenames

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #5678
    therapist
    Participant

    I have created 6 documents in Visual Basic 4 which I programmatically print to Pdf24 from within a loop.

    I need to autosave each individual pdf with a DIFFERENT FILENAME to the same folder.

    I need to define each filename from within VB using a variable.

    This is what I have done so far:-

    In THE pdf24 Assistant settings I have :-

    • Set PDF Printer Tool to "Automatically save documents after printed"   (Under PDF Printer Tool)
    • Set the Output Directory to C:\PDFs   (Under Auto Save)
    • Set the Filename entry to use the placeholders  %Y, %m, %d, %H, M%, S% $filename   (Under PDF Printer Tool)

    ALL 4 documents are saved OK as PDF's but with the $fileName placeholder part of the filename being saved as "Microsoft Visual Basic" for all 4 PDF's  ie. :-

    • 1st. file saved as "2018-11-16 12-04-09 Microsoft Visual Basic.pdf"
    • 2nd. file saved as "2018-11-16 12-04-10 Microsoft Visual Basic.pdf"
    • 3rd. file saved as "2018-11-16 12-04-11 Microsoft Visual Basic.pdf"
    • 4th. file saved as "2018-11-16 12-04-11 Microsoft Visual Basic.pdf"

    What I need to do is to autosave all 4 files using my own filenames and without Date, Month etc. etc.   I can't fathom how to do it using just the $fileName placeholder - unfortunately, using just this, each PDF is saved with the filename "Microsoft Visual Basic", which means that each previous file saved is overwritten by the next file saved.

    Is it possible from within Visual Basic to use a variable to define a DIFFERENT filename for EACH INDIVIDUAL PDF as it is autosaved?

    I would be extremely grateful for any help whatsoever.

    PS.  Does the $fileName placeholder take the filename from the application name which generates the PDF's hence the filename "Microsoft Visual Basic" ?

    #441
    naughton
    Member

    I have a Visual Basic Program that prints to a specific printer as I want. I can get it to 'print' to PDF 24 but not to save without manual intervention.

    Is there a way to automate the name it is to saved as and where to save it to?

    #875
    tenortrev
    Participant

    Apologies but I've already posted this to the wrong area of the forum I think (online Converter) so am now posting here - it's a PDF24 printer question.

    I've created a Visual Basic 6 program which loads all documents in a folder and then prints to PDF using PDF24.

    In the PDF24 Assistant under Settings.......PDF Printer........Auto Save
    I notice that there are fields for Output Directory AND Filename.

    Also, under Settings.......PDF Printer........PDF Printer Tool there is an option to "Automatically save documents after printed".

    Finally, to get to my question, does anyone know if the Output Directory and Filename can be assigned / changed from within Visual Basic so that each document can then be automatically saved as PDF's into different directories with different filenames of my choosing ?

    Many thanks for any help offered.

    #1800
    pdf24
    Member

    Hi,

    there is an easier solution with PDF24. Just use the PDF24 DocTool. You can use the DocTool to create PDF files from documents and you can advise this tool to save the file under a specified file name.

    Just call the docTool without parameters to get the command line description.

    #1801
    surp
    Participant

    @TenorTrev

    Kind of late but maybe this will help you.

    In the Settings of Assistent, if you set:
    > Output directory to C:\PDF\%UserName% and
    > Filename as $fileName

    Your report of VBA will be stored in a seperate folder by user and with the VBA reportname as filename.

    #64455
    therapist
    Participant

    I have just realised that the top line should have read "I have created 6 documents in Visual Basic 6 which I programmatically print to Pdf24 from within a loop."

    I had put Visual Basic 4 when I meant Visual Basic 6.

    I'm hoping that's the reason I haven't had any suggestions so far. Hope someone can help. Many thanks.

    #5687
    Stefan Ziegler
    Keymaster

    I think there is a simpler solution for your problem. Just use the PDF24-docTool.exe to convert your files to PDF. Use the following command line:

    pdf24-DocTool.exe -convertToPDF [-profile profileId] -outputFile OUT FILE1 [FILE2]

    This lets you specify the input file and the output file.

    When you call the docTool without arguments on the command line, then the tool outputs all command line arguments.

    #64456
    therapist
    Participant

    Thank you for your reply Stefan.

    I'm assuming that I would need to type this line for each of my PDF'd? If so then it's quite possible that I will need to do this in the future for many more PDF's and typing in this line for each PDF would be rather tedious.

    Using Visual Basic then I could use a Loop to process all PDF's automatically. Within the Loop I could define the filename to save to for each PDF but it's finding a way to automate this assigning of filenames to each PDF and then saving them with their individual filename once they have been printed to PDF24 (using Autosave) that I am having difficulty with.

    Examples of filename I would want to save to are:-
    DKL007-Cavalier.pdf
    CKs101-Russian-Blue.pdf
    GW051-Paris.pdf
    etc
    etc
    etc

    The information for the output filenames I would take from the filenames of documents which I merge from within Visual Basic before printing to PDF.

    Hope this is easy to understand. Don't know if you can help me further but I do thank you for taking the time to address my problem.
    regards

    #5702
    dech
    Participant

    Hi everyone,

    I would like to know if there is a way setting the file name according CLIPBOARD (you know, I copied by CTRL+C some text "ABCD" and I want to use it as the name of the file.)

    Of course I can do it manualy - when saving the file I will pres CTRL+V ...but I wanted to have it done automatically...perhaps by %variables?

    thank you.

    #66072
    PDF24 Support
    Moderator

    Hello,

    there is no placeholder for the clipboard content in the file name of the automatic saving. The file name can contain $fileName (the name of the print job, which the printing program sets), $fileDir, $printerName, $owner, $id, date and time such as %Y-%m-%d %H-%M-%S and environment variables such as %USERNAME%. Thank you for the suggestion, we will add it to our list.

    What works today:

    • To type or paste the name yourself: in the PDF24 settings under PDF Printer > Auto Save, enable Use a file name chooser before saving the file. PDF24 then shows a save dialog with the suggested name, and you can paste your text with Ctrl+V.
    • To let the document or your own program decide the name (as in the Visual Basic programs in this topic): since version 11.31.0 a printed document can set its own file name and folder with control codes. Enable Recognize control codes in the printed document for the PDF printer (together with Automatically save documents after printed) and print a text like this into the document:
    @@fn:DKL007-Cavalier@@
    @@df:C:\PDFs\@@

    PDF24 reads the codes after printing, removes them from the PDF and saves it as C:\PDFs\DKL007-Cavalier.pdf. If you put the codes on an extra last page and enable Control codes are on a separate last page (remove it after reading), this page is removed completely. Your program then only has to print a different name into each document. The codes only work if the program sends them to the printer as real text, so please test it with one document first. All codes are described here:
    https://creator.pdf24.org/manual/11/#62-control-codes-in-printed-documents

    • For files that already exist on disk, the PDF24 DocTool converts a file to PDF under a name you choose (pdf24-DocTool.exe -convertToPDF -outputFile <output file> <input file>). A program can call it once per file in its loop:

    https://creator.pdf24.org/manual/11/#11110-convert-to-pdf

    #66815
    PDF24 Support
    Moderator

    Hello,

    a short advance note on the question about the clipboard: the next version of PDF24 Creator adds the placeholder $clipboard for the file name of the automatic saving. It is replaced by the first line of text on the clipboard, so after copying ABCD with Ctrl+C, the file name $clipboard gives ABCD.pdf. Characters that are not allowed in file names are replaced by a hyphen.

    We will post here once it is released.

    #66945
    PDF24 Support
    Moderator

    Hello,

    the change announced above is now released in PDF24 Creator 11.34.0, available since 11 November 2026: https://tools.pdf24.org/en/creator

    For the clipboard question above: the file name of the automatic saving now knows the placeholder $clipboard. It is replaced by the first line of text on the clipboard, so after copying ABCD with Ctrl+C, the file name $clipboard gives ABCD.pdf.

    Detailed guide: Create PDF for free: print to PDF, convert files or online

Viewing 12 posts - 1 through 12 (of 12 total)
  • You must be logged in to reply to this topic.