Save webpages as pdf file

Moderator: Forum moderators

Post Reply
User avatar
rockedge
Site Admin
Posts: 7017
Joined: Mon Dec 02, 2019 1:38 am
Location: Connecticut,U.S.A.
Has thanked: 3146 times
Been thanked: 2932 times
Contact:

Save webpages as pdf file

Post by rockedge »

There are times that information on a web page will be needed while the system is off-line and a copy in a PDF format would be an easy and practical way of storing and accessing that web page.

To do this in Puppy Linux open the PPM (or from the command line with Pkg ) and search for and install wkhtmltopdf

In a terminal use it like this : wkhtmltopdf <webpage_url> <output_file>

Code: Select all

wkhtmltopdf http://puppylinux.com /root/Downloads/puppylinux.com.pdf
for help :

Code: Select all

wkhtmltopdf -h
screen coordinates can be given to only capture a region of an html page.

maybe a script can be assembled to grab pages with a drag and drop of the URL of the target pages.
keniv
Posts: 694
Joined: Mon Jul 13, 2020 2:18 pm
Location: Scotland
Has thanked: 124 times
Been thanked: 72 times

Re: Save webpages as pdf file

Post by keniv »

rockedge wrote: Sun Aug 23, 2020 8:13 pm

There are times that information on a web page will be needed while the system is off-line and a copy in a PDF format would be an easy and practical way of storing and accessing that web page.

To do this in Puppy Linux open the PPM (or from the command line with Pkg ) and search for and install wkhtmltopdf

In a terminal use it like this : wkhtmltopdf <webpage_url> <output_file>

Code: Select all

wkhtmltopdf http://puppylinux.com /root/Downloads/puppylinux.com.pdf

for help :

Code: Select all

wkhtmltopdf -h

screen coordinates can be given to only capture a region of an html page.

maybe a script can be assembled to grab pages with a drag and drop of the URL of the target pages.

I tried this on Bookworm 10.0.10. Installed wkhtmltopdf via synaptic. I tried to download 2 pages from this forum but this failed. There is no output in /root/Downloads. Below is the output from the terminal.

Code: Select all

# wkhtmltopdf https://forum.puppylinux.com/viewtopic.php?t=13790 /root/Downloads/https://forum.puppylinux.com/viewtopic.php?t=13790.pdf
Loading page (1/2)
Printing pages (2/2)                                               
QPainter::begin(): Returned false Done #

I'm not really sure what I'm doing wrong here or the relevance of QPainter::begin(): Returned false. I do think this would be useful if I could get it to work. I would appreciate any help with this.

Ken.

User avatar
bigpup
Moderator
Posts: 7512
Joined: Tue Jul 14, 2020 11:19 pm
Location: Earth, South Eastern U.S.
Has thanked: 1021 times
Been thanked: 1682 times

Re: Save webpages as pdf file

Post by bigpup »

The web site for wkhtmltopdf
https://wkhtmltopdf.org/

Github web page for wkhtmltopdf
https://github.com/wkhtmltopdf/wkhtmltopdf

I downloaded it and installed using synaptic in BookwormPup64 10.0.10

It has this in the information for using it:

Reduced Functionality:
This version of wkhtmltopdf has been compiled against a version of QT without
the wkhtmltopdf patches. Therefore some features are missing, if you need
these features please use the static version.

Currently the list of features only supported with patch QT includes:

* Printing more than one HTML document into a PDF file.
* Running without an X11 server.
* Adding a document outline to the PDF file.
* Adding headers and footers to the PDF file.
* Generating a table of contents.
* Adding links in the generated PDF file.
* Printing using the screen media-type.
* Disabling the smart shrink feature of WebKit.

The things you do not tell us, are usually the clue to fixing the problem.
When I was a kid, I wanted to be older.
This is not what I expected :o

williwaw
Posts: 2151
Joined: Tue Jul 14, 2020 11:24 pm
Has thanked: 196 times
Been thanked: 414 times

Re: Save webpages as pdf file

Post by williwaw »

wont most new browsers print to file and offer to print to pdf?

older browsers often had export to pdf as an option

User avatar
bigpup
Moderator
Posts: 7512
Joined: Tue Jul 14, 2020 11:19 pm
Location: Earth, South Eastern U.S.
Has thanked: 1021 times
Been thanked: 1682 times

Re: Save webpages as pdf file

Post by bigpup »

Sure, but this is a topic about a specific software program, to do it with.

The things you do not tell us, are usually the clue to fixing the problem.
When I was a kid, I wanted to be older.
This is not what I expected :o

User avatar
bigpup
Moderator
Posts: 7512
Joined: Tue Jul 14, 2020 11:19 pm
Location: Earth, South Eastern U.S.
Has thanked: 1021 times
Been thanked: 1682 times

Re: Save webpages as pdf file

Post by bigpup »

It works if you use the correct html address

This worked for me to make a pdf of the puppylinux.com

Code: Select all

wkhtmltopdf https://puppylinux-woof-ce.github.io /root/Downloads/puppylinux.com.pdf

The file it made is named:

puppylinux.com.pdf

I know that html address does not look like what it should be, but it is the correct one for puppylinux.com

At the top of the forum is Links.
use it to go to puppylinux.com
You will see it is actually going to:
https://puppylinux-woof-ce.github.io
.
.

The things you do not tell us, are usually the clue to fixing the problem.
When I was a kid, I wanted to be older.
This is not what I expected :o

User avatar
bigpup
Moderator
Posts: 7512
Joined: Tue Jul 14, 2020 11:19 pm
Location: Earth, South Eastern U.S.
Has thanked: 1021 times
Been thanked: 1682 times

Re: Save webpages as pdf file

Post by bigpup »

@keniv

I too tried to do a forum topic page and it just gave a bunch of errors.

But did work for https://forum.puppylinux.com

The things you do not tell us, are usually the clue to fixing the problem.
When I was a kid, I wanted to be older.
This is not what I expected :o

williwaw
Posts: 2151
Joined: Tue Jul 14, 2020 11:24 pm
Has thanked: 196 times
Been thanked: 414 times

Re: Save webpages as pdf file

Post by williwaw »

bigpup wrote: Fri Feb 28, 2025 12:52 am

@keniv
I too tried to do a forum topic page and it just gave a bunch of errors

did your file name include a "/" ?
if your filename included a "/" like the one keniv tried, https://forum.puppylinux.com/viewtopic.php?t=13790
that may be the issue.

keniv
Posts: 694
Joined: Mon Jul 13, 2020 2:18 pm
Location: Scotland
Has thanked: 124 times
Been thanked: 72 times

Re: Save webpages as pdf file

Post by keniv »

@bigpup and @williwaw
Thanks for your replies. I'll try to respond to them in order.

* Printing more than one HTML document into a PDF file.

Does this mean that using this method is limited to one page at a time?

wont most new browsers print to file and offer to print to pdf

I tried this in Firefox File>Print. This looked as if it would work giving quite a lot of options including printing one page, all and odds or evens. It wants to save to cups-pdf. When I tried this it gave me further options including saving to /root/Downloads which was what I chose but this exited with an error.

I too tried to do a forum topic page and it just gave a bunch of errors.

But did work for https://forum.puppylinux.com

I tried the example given by @rockedge in the first post. Below is the output from the terminal.

Code: Select all

# wkhtmltopdf http://puppylinux.com /root/Downloads/puppylinux.com.pdf
Loading page (1/2)
Warning: A finished ResourceObject received a loading finished signal. This might be an indication of an iframe taking too long to load.
Warning: A finished ResourceObject received a loading progress signal. This might be an indication of an iframe taking too long to load.
Printing pages (2/2)
Done                                                           
# 

This did produce a pdf file but it was blank. I'm wondering if the "taking too long to load" message is to do with the forum again being quite slow this morning. Maybe I should try again later when it's back to normal.

did your file name include a "/" ?
if your filename included a "/" like the one keniv tried, viewtopic.php?t=13790
that may be the issue.
Top

If this is the problem is there a way around it?
Hope this helps.

Ken.

User avatar
pp4mnklinux
Posts: 1314
Joined: Wed Aug 19, 2020 5:43 pm
Has thanked: 684 times
Been thanked: 330 times

Re: Save webpages as pdf file

Post by pp4mnklinux »

Hi Ken (@keniv):

It is possible (4 sure) that you know this option, and it doesn't answer your question, but I had this problems and I solved them with an extension which gives me that an more.

The extension is called "Take Webpage Screenshots Entirely - FireShot" and It gives me all the options that I need.

https://chromewebstore.google.com/detai ... fceg?pli=1

Overview
Take FULL webpage screenshots. Capture, edit and save them to PDF/JPEG/GIF/PNG, upload, print, send to OneNote, clipboard or email.

🏆 Awarded as "The Best Free Google Chrome Extension" by PCMAG.COM

🔒 Instant screenshots are stored locally, and never leave your computer, so it's 100% safe for storing a sensitive information. FireShot can work offline.

🛑 No spyware and unnecessary permissions - you're just in a couple of clicks away from an ideal screenshot.

Top 7️⃣ reasons to install FireShot:

1️⃣ Save screenshot to disk as PDF (with links), PNG, and JPEG
2️⃣ Capture entire page, visible part of the web page or just a selection
3️⃣ Automatically capture all tabs to PDF or image 🔥
4️⃣ Provide a list of URLs for an automatic batch capturing process 🔥
5️⃣ Send screenshots to Gmail
6️⃣ Copy captured images to clipboard
7️⃣ Print

### An upgrade is available. Activate it directly from the menu and:

✓ PDF with direct links and text, can be split to pages
✓ Capture specific elements, such as scrolling areas on web pages
✓ Capture all tabs in one click and save to single PDF
✓ Edit: crop, resize, add text and arrow annotations, blur areas and apply other effects
✓ Send to OneNote (Pro version)
✓ Save captures to disk as PNG, GIF, JPEG, BMP
✓ Upload to Twitter, ImageShack, Flickr, EasyCaptures, custom FTP or HTTP servers
✓ Copy to clipboard
✓ Print
✓ E-Mail
✓ Export captures to external editor
✓ Add page information to screenshots (URL, title, time, domain, etc)

You can configure it the way you want, and I hope I satisfy your demands.

It is 45Mb size, It's an extension, It's.... THE FASTEST WAY TO TAKE CAPTURES, ;)) :thumbup2:
Have a nice day.

Attachments
1.jpg
1.jpg (61.38 KiB) Viewed 570 times
2.jpg
2.jpg (110.96 KiB) Viewed 570 times
3.jpg
3.jpg (120.3 KiB) Viewed 570 times
williwaw
Posts: 2151
Joined: Tue Jul 14, 2020 11:24 pm
Has thanked: 196 times
Been thanked: 414 times

Re: Save webpages as pdf file

Post by williwaw »

keniv wrote: Fri Feb 28, 2025 10:30 am

If this is the problem is there a way around it?
Hope this helps.

Ken.

ken, are you using an old firefox? Firefox File>Print. does not seem like what I have to do a recent firefox. I click on the icon on the right of the tool bar and choose print from the dropdown to get a new view in the same tab. choosing destination cups-pdf or destination save to pdf both work here albiet the different choices bring up a different file picker dialog befor the save is made.
what is the error? coulf you be running the browser as spot but trying to save to root?

try testing the firefox feature with a simple page like https://bkhome.org/news/tag_easy.html

also maybe test wkhtmltopdf with the bkhome as well. my test with firefox worked but testing with a forum page took a long time maybe on account of the problems with the forum recently.

as for testing wkhtmltopdf
try
wkhtmltopdf https://bkhome.org /root/Downloads/barry.pdf
to also avoid the forum issues at present
you should be able to name your pdf anything you like, so not having / in the file name is entirely possible.

User avatar
rockedge
Site Admin
Posts: 7017
Joined: Mon Dec 02, 2019 1:38 am
Location: Connecticut,U.S.A.
Has thanked: 3146 times
Been thanked: 2932 times
Contact:

Re: Save webpages as pdf file

Post by rockedge »

would using the forum's Printview feature and then using the browser print to a PDF?

Screenshot_2025-02-28_19-33-10-800px.jpg
Screenshot_2025-02-28_19-33-10-800px.jpg (51.36 KiB) Viewed 492 times
Screenshot_2025-02-28_19-32-42-600px.jpg
Screenshot_2025-02-28_19-32-42-600px.jpg (46.3 KiB) Viewed 491 times
keniv
Posts: 694
Joined: Mon Jul 13, 2020 2:18 pm
Location: Scotland
Has thanked: 124 times
Been thanked: 72 times

Re: Save webpages as pdf file

Post by keniv »

@williwaw

ken, are you using an old firefox?

I'm using the the portable version of Firefox that comes with Bookworm10.0.10. It's v128.7.0 esr and is up to date but if your running a different version I guess it might explain any differences.

coulf you be running the browser as spot but trying to save to root?

Yes I am running as spot and I did try to save to /root/Downloads which might explain the error of which I can't remember the details. I'd have to repeat this to get details. Have just tried your suggestion with wkhtmltopdf https://bkhome.org /root/Downloads/barry.pdf and it worked perfectly.

I click on the icon on the right of the tool bar and choose print from the dropdown to get a new view in the same tab. choosing destination cups-pdf

Tried this with the first page of this thread and got the same error as mentioned above (please see the "error" image below). I repeated this but this time chose to save in Home/temp which was one of the options offered and got this (please see "pdf" image below). This did provide a good pdf of the first page so at least something is working.
@rockedge

would using the forum's Printview feature and then using the browser print to a PDF?

I'm a bit pressed for time at the moment but I will also try the above suggestion later this evening and report back.
@ pp4mnklinux

The extension is called "Take Webpage Screenshots Entirely - FireShot" and It gives me all the options that I need.

https://chromewebstore.google.com/detai ... fceg?pli=1

I don't tend to use chrome browsers so this is probably not a solution for me but thank you for your suggestion.

Ken.

Attachments
error.png
error.png (10.81 KiB) Viewed 397 times
pdf.png
pdf.png (21.59 KiB) Viewed 397 times
keniv
Posts: 694
Joined: Mon Jul 13, 2020 2:18 pm
Location: Scotland
Has thanked: 124 times
Been thanked: 72 times

Re: Save webpages as pdf file

Post by keniv »

rockedge wrote: Sat Mar 01, 2025 12:44 am

would using the forum's Printview feature and then using the browser print to a PDF?

Just had time to try this with the first page of this thread and it does work though it makes a pdf that's eight pages long. I now have two similar methods to do this and it looks as if wkhtmltopdf isn't necessary though when I did get it to work it was very quick.

Ken.

User avatar
rockedge
Site Admin
Posts: 7017
Joined: Mon Dec 02, 2019 1:38 am
Location: Connecticut,U.S.A.
Has thanked: 3146 times
Been thanked: 2932 times
Contact:

Re: Save webpages as pdf file

Post by rockedge »

Remember in the print options you can select the pages to print or not to print to only printout a single page, two or more, or or all of them

keniv
Posts: 694
Joined: Mon Jul 13, 2020 2:18 pm
Location: Scotland
Has thanked: 124 times
Been thanked: 72 times

Re: Save webpages as pdf file

Post by keniv »

rockedge wrote: Sat Mar 01, 2025 7:27 pm

Remember in the print options you can select the pages to print or not to print to only printout a single page, two or more, or or all of them

Yeah, I selected the "current" page, I think, assuming that as the thread only occupies a single page on the forum it would only produce a single page pdf. I guess if it did occupy one page of a pdf the text size etc would be much smaller so perhaps over eight pages is better. Anyway it's a useful thing to be able to do so thanks for the help with this.

Regards,

Ken.

Post Reply

Return to “Utilities”