PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, August 16, 2022

[FIXED] How do I save a pdf with a custom file name

 August 16, 2022     filenames, input, output, pdf     No comments   

Issue

Im new to python and can't figure out how to save my pdf file with a custom name.

What I want to do is something like:

Name = input('What is your name: ')

pdf.output('Name.pdf')

And as I expected the name of the pdf file created is now: Name

I tried searching for it but I think im using the wrong words for it since I can't find a solution for my problem. I might be explaning it badly. But if anyone got an answer for it it would be much appreciated :)


Solution

Sir, in your question:

pdf.output('Name.pdf')

Here you are passing Name.pdf as a string to the output function if you want to pass the Name variable you should not use ' quotes around the value you are passing you final code should look something like this:

name = input("Enter your name: ") 
name = name + ".pdf" //adds .pdf extension to the name entered
pdf.output(name)  //see how there are no quotes around name variable



Answered By - Anurag Parmar
Answer Checked By - David Goodson (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing