Bug 159005

Summary: Print document with annotations
Product: [Applications] okular Reporter: albert <alberthilbert>
Component: generalAssignee: Okular developers <okular-devel>
Status: RESOLVED FIXED    
Severity: wishlist CC: amg1127, bradh, digitalpioneer, doc.evans, fabiodurso, ivo, kdebug, mhlavink, mstu, nate, ndesmoul, neteler, niels_ole, povvy, timoundiep, vo.jeroen, xjakub
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Ubuntu   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description albert 2008-03-09 12:12:10 UTC
Version:            (using KDE 4.0.1)
Installed from:    Ubuntu Packages

Add an option to print a document with annotations included
Comment 1 Ivo Anjo 2008-04-04 11:05:39 UTC
I agree, I just tried to print an annotated document just to discover that the annotations are ignored when printing.

At least a warning would be useful.
Comment 2 schmirrwurst 2008-04-11 18:28:38 UTC
the same for me, annotations can't be print nor saved !
Comment 3 fabio 2008-09-29 15:17:21 UTC
I wish u could do that, it might be very useful in reviewing or studying a document
Comment 4 Tristan Miller 2008-10-14 12:17:37 UTC
*** This bug has been confirmed by popular vote. ***
Comment 5 Pino Toscano 2009-11-05 09:53:18 UTC
*** Bug 213209 has been marked as a duplicate of this bug. ***
Comment 6 Vsevolod Krishchenko 2009-11-29 10:02:29 UTC
I hate to be rude, but reviews tools are useless crap now. It's impossible to use them to reviews papers, diplomas and other documents because there's no way to transfer them to another machine.

Printing them to pdf file (via Print menu) could fix this.
Comment 7 Albert Astals Cid 2009-11-29 15:18:01 UTC
There is a way to move them to other systems. File -> Export As -> Document Archive.

I hate to be rude but the next time you are going to comment please read the manual before doing useless crap complaining.
Comment 8 Nicolas Desmoulins 2009-11-30 10:16:35 UTC
Nonetheless, having the possibility to generate a new pdf, with the pdf printer, which includes the annotations would be nice. For example to share this annotations with the poor souls who still use Acrobat Reader under Windows...

Because, unless I'm mistaken, the export command generate a file that other readers can't read.
Comment 9 Brad Hards 2009-11-30 20:55:28 UTC
Nicolas: please don't mix bugs. Read (all of) http://bugs.kde.org/show_bug.cgi?id=151614.
Comment 10 Nicolas Desmoulins 2009-12-01 11:44:45 UTC
Well Brad, to me the two bugs are of course not the same but are strongly related.

Because the possibility to print a pdf with its annotation could provide (if you choose a pdf printer) at least a part of the solution to the bug you mentionned. It's just another reason why to be able to print a document with its annotations would be nice.

And if you can (one day hopefully) print a document with its annotation, I don't see the difficulty to use a pdf printer instead of a real printer.
Comment 11 Pino Toscano 2010-02-09 20:40:07 UTC
*** Bug 226059 has been marked as a duplicate of this bug. ***
Comment 12 Pino Toscano 2011-10-09 20:43:33 UTC
*** Bug 283666 has been marked as a duplicate of this bug. ***
Comment 13 Troy Rollo 2011-10-22 23:55:38 UTC
For a quick and (very) dirty fix, try changing Document::print in Okular as shown below, and add  "CMakeFiles/okularpart.dir/ui/pagepainter.o CMakeFiles/okularpart.dir/ui/guiutils.o" and  "-lqimageblitz" to the Link command for libokularcore.so.1. From the command line, see LD_LIBRARY_PATH to include the directory with the new libokularcore.so.1 before /lib and /usr/lib, and run okular.

This is a very quick and dirty fix - I have deliberately not performed some checks that should be performed, but it is enough to generate (via print to PDF) PDFs that show the annotations. It will sometimes SEGV after the printing is done, and there are no guarantees that it will not do so before that.

bool Document::print( QPrinter &printer )
{
    int	pages = d->m_pagesVector.count();
    int page;

    QPainter painter(&printer);

    for (page = 0; page < pages; ++page)
    {
	QRect geom(printer.pageRect());
	Page* pageptr = d->m_pagesVector.value( page, 0 );
	QMap< int, PagePrivate::PixmapObject >::ConstIterator itEnd = pageptr->d->m_pixmaps.constEnd();
        PixmapRequest *request = new PixmapRequest( itEnd.key(), page, geom.width(), geom.height(), 1, false );

	request->d->mPage = pageptr;
	d->m_generator->generatePixmap(request);
	PagePainter::paintPageOnPainter(&painter, d->m_pagesVector[page], PRESENTATION_ID, PagePainter::Annotations, geom.width(), geom.height(), geom);
	if (page < pages)
		printer.newPage();
    }
    return true;
//    return d->m_generator ? d->m_generator->print( printer ) : false;
}
Comment 14 Fabio D'Urso 2012-06-11 23:44:06 UTC
Starting from KDE 4.9, it's possible to print annotations in a PDF document (except for Stamp annotations, because printing support for this annotation type is not implemented yet).

Since this bug is not only about PDFs, I'm leaving it open.
Comment 15 kdebug 2016-04-25 22:14:23 UTC
Is there a reason why printing stamp annotations isn't implemented yet ?
This would make okular much more useful.

Kind regards
Comment 16 Nate Graham 2017-08-17 23:15:36 UTC
As of https://bugs.kde.org/show_bug.cgi?id=151614, PDFs with annotations will now print as expected, for the most part. However there is a bug that affects the implementation, such that stamp annotations don't appear when the document is printed. That is tracked with https://bugs.kde.org/show_bug.cgi?id=383651