### accidentallygivenfuck's blog

By accidentallygivenfuck, 4 years ago, ,

Hi Codeforces,

Does anyone know a way to download problems in a PDF file for later offline use?

I know a somewhat not-so-good way:

• Open codeforces.com/contest/<contestid>/problems
• Press ctrl+p
• Set the correct preferences, so that the result will be readable
• Print to file

But I remember that I downloaded 482B - Interesting Array in a PDF file at the beginning of the contest, when I tried to open the problem page. I don't know how, but maybe it was because the servers were too busy. That is why, I thought there might be a way to download problems in PDF format.

I still have the file. This file is more convenient than printing the problems page.

•
• +6
•

 » 4 years ago, # | ← Rev. 2 →   +3 Hello, I think you can use wkhtmltopdf, It justs requires an url as input, and it gives you the required pdf.
 » 4 years ago, # | ← Rev. 3 →   +5 I just wrote a code for this C++0x:Using this you can remove surplus elements from problem and have a clean page instead. You can also change  and style the document. It saves the document into saved.html. After saving it, Use your own method to PDFify your new HTML. // // main.cpp // CF to PDF // // Created by Hossein Yousefi on 1/11/15. // Copyright (c) 2015 IranGeek. All rights reserved. // #include using namespace std; int main(int argc, const char * argv[]) { cout << "Enter URL of problem: "; string url; cin >> url; string download_cmd = "curl " + url + " > _cfprob.html"; system(download_cmd.c_str()); ifstream fin("_cfprob.html"); string tmp, parsed_html; while (fin >> tmp) { parsed_html = parsed_html + " " + tmp; } system("rm _cfprob.html"); unsigned long begin, length; begin = parsed_html.find(""); length = parsed_html.find("") - begin + 7; string head = parsed_html.substr(begin, length); begin = parsed_html.find(""); length = parsed_html.find("") - begin; string problem = parsed_html.substr(begin, length); string html_to_be_saved = " " + head + " " + problem + " "; ofstream fout("saved.html"); fout << html_to_be_saved; system("open saved.html"); } TESTED in OS X.This that problem, converted to PDF using this C++ code: https://drive.google.com/file/d/0B6dkBXoLJA10Q1ZpUTNCejA2T0k/view?usp=sharing
•  » » 4 years ago, # ^ | ← Rev. 2 →   0 You know that this only works in mac, right ? Linux and Windows don't have open or curl, or windows doesn't have rm.
•  » » » 4 years ago, # ^ |   +13 You can convert commands into your OS.rm is del in windows.open is xdg-open in linux. open is start in windows.curl is available here to download it for windows: http://curl.haxx.se/dlwiz/?type=bin&os=Win64curl should work on linux too as far as I know.
•  » » » » 4 years ago, # ^ |   0 You should install it (curl on linux) :)
•  » » » » 4 years ago, # ^ |   0 I converted it to Windows but when it s finished it says that the path I am using is being used by another process...
 » 4 years ago, # |   0 thanks
•  » » 4 years ago, # ^ | ← Rev. 2 →   0 You are welcome. And thanks to you too :P But I didn't mean to be informative. I rather asked a question.So can someone please tell if it is possible to download problems in exactly the same format as in this file?