Open Bug 162659 Opened 17 years ago Updated 4 months ago

Maybe "Save Page As" could save as PDF (using Skia PDF)

Categories

(Core :: Graphics, enhancement)

enhancement
Not set

Tracking

()

People

(Reporter: jhmelman, Unassigned)

References

(Blocks 1 open bug)

Details

Attachments

(1 file, 2 obsolete files)

I think it would be useful if such an option existed. As soon as sometimes I
save pages as "Webpage, complete" and then convert them to pdf, it would be nice
if Mozilla could do it for me. Nevertheless, I think other users would like it
too, and, as far as I know, Mozilla would be the only browser with this feature,
which is a good thing.

I don't know if it's disencouraged by Adobe, but my suggestion is here anyway. :)
Whiteboard: DUPEME
To save a page as PDF, you can print to a PDF printer driver (distiller, etc).
I know this is possible, it costs U$ 249,00. I know that free alternatives exist
(I even presented one in my report). I just think it would be nice and easier
for people if Mozilla had this feature.
Seems like a bloat factor to me. On Mac OS X you can always print directly to
PDF, as Display Postscript is the native graphics format. Adobe wouldn't mind
others implementing native PDF in their operating systems, as it just
establishes their de facto standard further. Adobe's role is to supply feature
laden tools for better PDF documents.
That would be a cool idea!  That way, I won't have the staff keep coming on over
to me to ask how to save the pdf stuffs.
..you can save as PostScript.. and when you got a PS, it isn't a problem to
create a PDF.

.. and it's also possible to create a virtual printer via CUPS for example wich
writes a PDF File..

I think this would be as useful as when we add a image editor (gimpzilla) to
Mozilla (-composer)..
related:
  bug 100571
  bug 40873
can't find a dupe of this...
QA Contact: sairuh → petersen
"..you can save as PostScript.. and when you got a PS, it isn't a problem to
create a PDF"

yes, but having a "save as pdf" in the file menu is much faster and user 
friendly!

It's also feature bloat that should be in an extension, imo. The amount of code
needed to do this would be fairly large, and the memory footprint of all that
code being loaded all the time would be quite noticeable.

wontfix (but an extension to do this would be quite nice).
Status: UNCONFIRMED → RESOLVED
Closed: 17 years ago
Resolution: --- → WONTFIX
*** Bug 198868 has been marked as a duplicate of this bug. ***
*** Bug 231198 has been marked as a duplicate of this bug. ***
*** Bug 261554 has been marked as a duplicate of this bug. ***
Blocks: 286847
Whiteboard: DUPEME
No longer blocks: 286847
*** Bug 286847 has been marked as a duplicate of this bug. ***
*** Bug 286847 has been marked as a duplicate of this bug. ***
I think this should not be in an extension. 

1. PDF is a defacto standard for presentation of mixed text/graphical documents.
2. I think the argument that generating PS and making PDF is easy does not fit.
I know how to do it, but most users will not.
3. I think printing as PS file is strange for many users 


It rather should be "Save as" or like in OpenOffice.org "Export" PS/PDF. I
consider saving as PDF as a core functionality which would be of very high use
for many users. I think it is more important than saving as HTML, what less
people might want, because handling directories and images and files is not easy
- and many pages are dynamic, so the HTML is not usable offline.

So I voted for this bug and think it should be reopened. Please do not view it
just like  "The amount of code needed to do this would be fairly large". I agree
that a small footprint is something that should be a major goal, but if we could
save pages as PDF would be something that IE and Opera can not and would make
Firefox attractive for those people who are used to PDF. From my view saving as
PDF makes much more sense for an average user as saving HTML (in a directory
with many files).


Amen, I think PDF needs to be in Firefox, especially since Microsoft is
developing their "PDF Killer" which will probably be in IE.  I know you can
still make a PDF other ways, but it is not as intuitive.  Such has always been
the case for office suite documents, but notice how much better it is in OOo.  I
could create PDFs before I used OOo, but I do it a lot more now because it is
simply a better implementation. If it was done as an extension, I would vote to
have it ship with FF.
I originally was in full support of this idea (I think I posted a similar bug
ages ago) because saving as a webpage means that extra folders etc. are created.
However, I have come to agree that it is better for an extension for two reasons:
1) Bloat factor - it is the essential philosophy of Mozilla to keep Firefox as
light as possible and put everything else in extensions. Even Adblock is an
extension but a big selling point of the browser.
2) Patent issues - PDF is not an open format. While it is currently free to use
(AFAIK) the patent, it still is patented and this could potentially be enforced
by Adobe at a latter stage. It may also cause Linux distributions such as Ubuntu
and Debian to have to remove the feature before shipping Firefox. A lot of
Governments etc. are embracing open source and ditching proprietary formats like
.doc and .pdf files.
What about adding an option during install (perhaps at the end?) that would have
a short (emphasis on short) list of common extensions it could download and
install automatically?  Perhaps Adblock, ForecastFox, ImageZoom (so useful!),
Save as PDF, Google Toolbar, or Gmail?  That way it is actually more part of the
installer than the core product of Firefox.  Although the PDF extension would
still need to be developed.  Also, I thought that PDF was pretty much
unemcumbered.  I understand Debian (or any derivitive) would maybe have to drop
it.  That's why it would be great as an extension; not required for normal FF
operation.  I think incorporation of this install option would be very powerful
for FF, especially since many "converts" probably don't realize there are great
extensions like AdBlock.
I think I would not have anything against extension, if they would be
distributed with Firefox itself. At least a core of the extensions. I think the
philosophy to keep Firefox small in contrast to the philosophy that Mozilla had
(to be as bloated as can possible) is overexaregated nowadays.

If there is functionality that is needed, it should  be included in Firefox.
Keeping the core small is a nice idea. But now many features are not implemented
and we often had incompatibilities with important extensions. I am not sure that
this really is what users are looking for. I think a user EXPECTS to have
running features. I do not think viewing everything from developers perspective
and sticking to that will ever lead to a firefox that solves users problems.

I also do noit think that there are any patent issues. Otherwise Fedora Core
would never ship any PDF producing software. If you think there are you should
point to where this argument is laid out.

Thilo
*** Bug 309410 has been marked as a duplicate of this bug. ***
*** Bug 316878 has been marked as a duplicate of this bug. ***
*** Bug 319569 has been marked as a duplicate of this bug. ***
I think this should be implemented since pdf is such a usefull standard.
OpenOffice supports it and it's appreciate so much microsoft is going to implement it in their next office version. I think firefox should implement this features before they think to do it for internet explorer.
Can't this be done fairly easily using Cairo once it's being used to render everything? (Gecko 1.9).
Yeah with Cairo this should be possible afaik, but Gecko 1.9 will be seen in FF 3 at earliest so still some time to go.
*** Bug 323748 has been marked as a duplicate of this bug. ***
bz: Seeing as, in Gecko 1.9, this ought to be relatively easy to do (as opposed to currently where it would require a large amount of external code), don't you think this could be reopened for future?
I really don't care.  I certainly have no plans to work on this.
Boris: If you "don't care" (but don't oppose), could you then please reopen this bug (since you WONTFIXed it), and reassign it to the default owner? Thanks.
Would be useful. But should "Safe Page As PDF" use the print or screen stylesheet?
(In reply to comment #29)
Nit: s/Safe/Save

Instead of adding (yet) another menu-item under the File menu, it might be sufficient to add "PDF" in the Save As dialog under the "Save as type" dropdown list:

Save as type: [                     ]
              | Web Page, complete  |
              | Web Page, HTML only |
              | Text Files          |   <-- Why is this plural
              | PDF File            | <-- This bug
              | All Files           |   <-- what is THAT doing here?
              +---------------------+
(In reply to comment #30)
> Instead of adding (yet) another menu-item under the File menu, it might be
> sufficient to add "PDF" in the Save As dialog under the "Save as type" dropdown
> list:

Yes, that's also what I would recommend. Sorry for my misleading wording.
Status: RESOLVED → REOPENED
Resolution: WONTFIX → ---
reopening
Assignee: law → file-handling
Status: REOPENED → NEW
QA Contact: chrispetersen → ian
Summary: Maybe "Save Page As" could save as PDF → Maybe "Save Page As" could save as PDF (using Cairo)
Subsequent to my Comment #16 I have converted to thinking this should be in mainline Firefox and not an extension. My first reason (bloat) shouldn't apply if the Cairo backend is being used to render anyway. 

You were correct that my second reason was never correct - pdf is patented but I have since read the licenses which they grant and they are permissive enough not to cause issues if the standard is followed. I feared that there may be a blanket restriction on patented code in the free distributions, but that does not seem so. I apologise if I alarmed anybody.
Assignee: file-handling → nobody
Component: File Handling → GFX: Thebes
QA Contact: ian → thebes
Depends on: 369930
Bug 369930 implemented the back-end (thebes and widget) to print to a PDF file on windows, and bug 367907 made an additional fix for gtk2. As I understand it, it just needs to be hooked up in the front-end.
Maybe that can be used for Save Page As as well?
Given that "Save web pages as PDF documents" is listed as P2 in the Firefox 3 PRD (http://wiki.mozilla.org/Firefox3/Product_Requirements_Document#P2_4), should Priority be changed to P2 on this bug?
that was supposed to come off the PRD and priorities in the PRD have nothing to do with priorities on bugs
Oh, so this isn't going to make Firefox 3? :/
pretty sure the frontend bits got cut.  I implemented the backend bits and have a little extension I should post somewhere that lets you print to PDF.
(In reply to comment #38)
> I implemented the backend bits and have
> a little extension I should post somewhere that lets you print to PDF.

Oh yes, please do post it.
Attached file Extension Stuart was talking about (obsolete) —
This is the extension Stuart was talking about.
I haven't actually tried it, but I used the code inside it, which works nicely.
Note that the picture inside it, might be copyrighted.
So the only problem with that is that it uses the print stylesheet.
I just printed this bug page with the extension and got a 510 KB PDF. PDF Creator makes a 154 KB file.

Then tried to print this PCMag article: http://www.pcmag.com/article2/0,2704,2200774,00.asp

PDFCreator: 204 KB, printpdf: 714 KB and for some reason images are not printed with the extension but they are with PDF Creator.

Is there some kind of optimization pending?
I agree with Dão; the generated PDF should look as close as possible to the screen representation (including background images), since that's what (I believe) the Save Page option is supposed to do. If the user wants a printer-friendly version, that's the purpose of PostScript print and PDFCreator.

If generating printer-oriented PDFs is desired, maybe two options could be added to the Save As menu (since adding a custom printer to the standard print dialog on most environments is not supported).
How much code is this using? this was already very simple on ubuntu/mac os x as they ship with pdf as a printer,this seams quite pointless.
Id suggest moving the whole thing to an extension to reduce firefoxs memory footprint, perhaps the start page should recomend it, but on ubuntu/mac this feature would just be bloat and most users never save pages.(ive saved maybe 2 pages in about 3/4 years, and then i don't think i ended up using them)

if the feature is included could it be disabled in about:config or is it too late by then to save the memory?
(In reply to comment #44)
> How much code is this using? this was already very simple on ubuntu/mac os x as
> they ship with pdf as a printer,this seams quite pointless.
> Id suggest moving the whole thing to an extension to reduce firefoxs memory
> footprint, perhaps the start page should recomend it, but on ubuntu/mac this
> feature would just be bloat and most users never save pages.(ive saved maybe 2
> pages in about 3/4 years, and then i don't think i ended up using them)
> if the feature is included could it be disabled in about:config or is it too
> late by then to save the memory?

Just because you don't use a feature often doesn't mean that it wouldn't be useful to most other Firefox users ;)

Also, as I understand it, because Cairo includes a PDF output option built-in, not a lot of code needed to be added to enable the extension to work (see the patch in bug 369930).
This doesn't seem to print SVG correctly. Is that a known bug?
What do you mean? When printing pdf only, or does it also happen with regular printing? And what problem are you seeing?
Sorry. I probably shouldn't have commented in here about it. Printing SVG using the extension only gives me the first inch or two of the page. The rest is white. I can attach an example using one of examples at http://www.croczilla.com/svg/samples/ tomorrow if that will help.

I know the extension isn't something meant for production yet. I just wasn't sure if it was being written as a prototype to test the possible FF/Gecko implemntation someday, or written just as an extension for people asking for this functionality. If its just an extension then sorry for the bugspam.
I guess the extension is meant for both.

I can reproduce the problem you're seeing. It isn't really related to the pdf extension, I can see it while directly printing an svg file.
So I filed bug 411382 for it. You can CC yourself to that bug to watch progress on that.
Is the intention to publish the extension to AMO (in the Sandbox for the moment, of course) in time for the release of Fx 3? I think many users would find it useful.
Attached patch patchSplinter Review
This is mostly copied from the extension into the code that handles the "File->Save Page As..".

There are several things wrong with it:
- On the Mac this can't work, so it has to be disabled there.
- printSettings.printSilent = true doesn't work, I still get the print progress dialog, which is annoying.
- Probably a check that there is a printer installed would be good. If there is no printer installed, then this save option should be disabled, because it can't work when no printer is installed.

I also encountered bug 120313 when trying to fix it, which causes you to get a .htm extension when saving the pdf file, which is stupid.
Comment on attachment 285350 [details]
Extension Stuart was talking about

my extension can be found at https://addons.mozilla.org/en-US/firefox/addon/5971

the intension of the extension is to test functionality that mostly works but probably won't be exposed in firefox 3 due to lack of time to polish it and fix all the issues with it.
Attachment #285350 - Attachment is obsolete: true
(In reply to comment #51)
> There are several things wrong with it:

I assume it's also still using the print stylesheet, which seems undesirable for a "Save As" option (as per comment #41 and comment #43).
Ah yes, that makes the patch useless.
I guess the code could be added somewhere in the print dialog, instead. But that should be a different bug, then.
(In reply to comment #14)
> - and many pages are dynamic, so the HTML is not usable offline.

JavaScript and such work in HTML files; do they work in PDF?

I suggest MAFF (bug 381413), which is basically "Save as, complete" + metadata in a neat zip file than can be unzipped and/or modified if needed.
MHT (MAFF-like) support should be a high higher priority than MAFF support - see bug 18764 and bug 40873, and this RFC for the standard http://www.rfc-editor.org/rfc/rfc2557.txt

However, that's a different issue - the use-cases for PDF support (e.g. documents which display the same on all machines, easily printable in the same format you see it) is different from that of MHT/MAFF (save a functional web page).

Both RFE's are different, and both are valid.
Attached patch firefoxpdf (obsolete) — Splinter Review
This would actually be really good and make a lot more sense than saving as html.
Attachment #382716 - Attachment is obsolete: true
(In reply to Malcolm Rowe from comment #1)
> To save a page as PDF, you can print to a PDF printer driver (distiller,
> etc).

But that way, you'd lose the hyperlinks.
Boris, do you happen to know what the story on this bug is?
This bug should be much easier now that we can use some of the code from Fennec that saves pages as PDF. According to a discussion in #mobile, the code for Fennec to Save as PDF uses the Cairo PDF backend.
It would be tremendously useful for this feature to be added to Firefox. Printing as PDF is not the same (i.e. loses links). I'm quite surprised that it's not more requested.
I should add that all of the current FF addons to Save As PDF/Convert to PDF either save an image or use a web-based third party to do the actual conversion. Clearly the former is of limited usefulness and the latter won't work for local or intranet files.
Hi,

I often write SVG schemas (with Vim) and need to export them to PDF. I did this with Inkscape but its support of CSS is quite bad (e.g. the dominant-baseline property is not supported — https://bugs.launchpad.net/inkscape/+bug/811862), whereas Firefox has a great support of SVG + CSS. The fact is that I need to print my page, export it to PDF and trim the generated A4 format to fit to my schema. Crazy. No automation and a bit boring…

If Firefox could also export SVG to a specific dimension, it could be awesome and a _real_ need. I have a software that is waiting on this feature, but I think I am not alone (SVG editors need that too I think).
Duplicate of this bug: 770951
As Firefox includes now a native PDF viewer and PDF is a single file compared to the current 'Save Page As' option I suggest making PDF the default output - like in Firefox for Android (if the PDF feature gets implemented in the Desktop version too). For average users a PDF is much more protable than the current implementation of 'Save Page As'.
I have not read all the above discussions, so my apologies if this point is discussed and resolved above.

The native PDF viewer of firefox opens the pdf file but when we save it (say, a part of it, splitting 40 pages opened pdf to only page 1-2) it gives only option to save as XPS file for microsoft viewer.

It is surprising that the developer didn't think of saving in the existing opened format that is pdf itself.

If there is any method of doing that with built in things of ff, please guide me to it, otherwise, add an option to save as pdf file itself.

or, If there is any other thing (like nitropdf etc. some printer plugin) tell me about that. I am still surprised that when ff knows how to open a pdf file, why should it need any external softer to save in pdf format.

Thanks.
-- 
Rawat
To add, chrome's built in pdf reader "does" save as pdf file, so I have to use chrome to split pdf files, as I am not able to do the same in ff. and I don't have any other pdf conversion/ printing thing installed on my pc to let chrome save as pdf when ff can't do that.

-- 
Rawat
Save as PDF on the desktop, implemented using the technology in Android FF would be great. Using the print media CSS would be preferred, but I can see uses for using the screen media CSS also, so I approve of comment 43.

After trying out over a dozen "print to PDF" schemes, and Chrome's "save as PDF", and concluding that (1) Adobe Acrobat "print to PDF" is best quality, but all are limited by what the browser tells the print driver, and apparently not all fonts are rendered as fonts (2) I would probably have to generate my own PDF from the SVG data I'm already generating, but separately ... I then happened to obtain an Android, found the FF Save as PDF feature, and discovered that it is better than _any_ other technique I've found for converting mixed HTML/SVG pages to PDF. All the fonts are recognized by Acrobat in the output which hasn't been seen using any other technique I've found.

This feature has been getting great reviews for years on Android (I've just discovered), just for the convenience, but I'm here to say that it is also technically produces the best quality output. I'm really sorry to see that mine is the first comment in over a year, regarding this issue.

Is it possible to trigger the "Save as PDF" feature on Android from Javascript?
Continuing the quest, here is a review for a plugin that works really hard to generate PDF, but... includes webkit in the addon, it seems. Isn't that ridiculous, for something that could be done better with the technology already built-in?

http://www.scientificcomputing.com/blogs/2013/09/driverless-printing-generating-pdf-files-web-page
Please add this, I think that on the desktop version it's almost as useful as on the Android one
Bug 1063217 made this slightly easier to add.
Would it be possible to "un-bitrot" the patch?
Flags: needinfo?(martijn.martijn)
(In reply to Worcester12345 from comment #73)
> Would it be possible to "un-bitrot" the patch?

Sure, but see comment 51 and comment 53. Those issues have to be addressed.
Flags: needinfo?(martijn.martijn)
In case your are not aware, my "Print Edit" add-on supports saving of web pages to PDFs using either print media CSS (default) or screen media CSS (Web Style enabled).

Hope this helps.
(In reply to dw-dev from comment #75)
> In case your are not aware, my "Print Edit" add-on supports saving of web
> pages to PDFs using either print media CSS (default) or screen media CSS
> (Web Style enabled).
> 
> Hope this helps.

Perhaps you can help with the fixes mentioned in Comment 74, and use your knowledge of this subject to fix this bug WITHIN THE PROGRAM ITSELF. That would be AWESOME if you could help contribute to this.
(In reply to dw-dev from comment #75)
> In case your are not aware, my "Print Edit" add-on supports saving of web
> pages to PDFs using either print media CSS (default) or screen media CSS
> (Web Style enabled).

While I see the PDF checkbox on Windows (at work), I do not see this at Ubuntu 14.04 (at home). 

It's nice that it's possible to "Save as PDF" at least on Windows using your add-on (which I am a very happy user of due to many other very nice features), but I also very much agree with Comment 76 that it would be great if the problem here could be tackled and this feature made available natively in Firefox.
I was not aware that the PDF checkbox does not appear on newer versions of Ubuntu.  It certainly did on earlier versions.

If "Save as PDF" is to become a standard feature of Firefox, then I would suggest that the current version of the Cairo library built into Firefox is not an ideal solution, since it supports an early version of the PDF standard.
Duplicate of this bug: 1405130
Summary: Maybe "Save Page As" could save as PDF (using Cairo) → Maybe "Save Page As" could save as PDF (using Skia PDF)
There is a angularjs code for it. Here: https://github.com/hearsid/ng-html-to-pdf-save
You need to log in before you can comment on or make changes to this bug.