So, in short: what we do is just re-distilling the PDF by using poppler 
to read the PDF and render it to a cairo surface with the PDF backend. I 
see no clear reason why bitmaps from the PDF shouldn't re-distill 
properly without loss of resolution. (There could be a slight loss of 
crispness as the images could be converted from whatever format they 
were in, eg JPEG2000, to the format in which the cairo PDF backend 
prints bitmaps -- likely PNG if I had to guess, so that should be 
lossless at the expense of an increase in file size).

In xournal, the code is in xo-print.c, print_to_pdf_cairo() is the main 
function that exports the open document to a PDF; print_page_to_cairo() 
is where individual pages get exported to a cairo surface (either for 
new-style export-to-PDF or for File -> Print to actual or virtual 
printers alike); print_background() is where the background gets printed 
to a cairo surface and as you'll see in the BG_PDF case it just scales 
the page and asks poppler to draw the PDF page.

Denis

On 06/17/2015 04:29 PM, Denis Auroux wrote:
> The new export-to-PDF renders things on a PDF cairo surface, which I
> imagine is more or less the same as using File -> Print -> Print to File
> -> PDF with the main difference that we create the cairo context
> ourselves and set the page sizes to match ours, rather than letting
> gtkprint set up the cairo context and use the page sizes set in the
> virtual printer.
>
> So, basically, we create a cairo PDF surface, and then ask poppler to
> render the appropriate page of the existing PDF file to that cairo
> surface (and then add the annotations on top).
>
> I am not aware of any resolution parameters that we could set in there.
> Well, actually, there is one:
> cairo_surface_set_fallback_resolution ()
> (see the documentation of cairo_surface_t)
> but I don't see why it would matter since it's only for falling back to
> rendering to a bitmap and putting that bitmap in the PDF when cairo is
> asked to do something it can't directly do into a PDF, and presumably
> whatever poppler tries to do to show the scanned image is just read the
> PDF-embedded image and draw another embedded image into the other PDF,
> which shouldn't require any fallback.
> Besides, the fallback resolution is apparently 300 dpi by default
> according to the cairo docs, so that should be plenty.
>
> Does export also drop the resolution of other bitmaps -- either those
> inserted by the user into xournal (if so it means the cairo surface
> we're writing to silently compresses bitmaps without asking us --
> xournal wouldn't change the resolution), or bitmaps contained in the PDF
> file that we're annotating?
>
> Anyway: I've seen this happen as well, on PDFs where I thought the
> background was actual vector stuff and not bitmap, but I didn't
> double-check. It's definitely annoying and worth investigating. In
> principle poppler is used both to render the PDF on-screen for xournal
> and to export it to the new PDF, so if it can do one well it should also
> be able to do the other well.
>
> Denis
>
> On 06/17/2015 04:09 PM, D M German wrote:
>>
>> Hi Denis,
>>
>> One question about the new exporter.
>>
>> I have PDFs that each page is a scan (images). When I use export to PDF
>> it drops the resolution significantly. If use the old exporter, things
>> look ok.
>>
>> Is this based on some variable that controls the resolution of the
>> background PDF?
>>
>>
>> thanks!
>>
>>
>> --
>> Daniel M. German                  "My friends would think I was a nut,
>>                                     turning water into wine,
>>     Solsbury Hill, Peter Gabriel -> opening doors that seem to be shut."
>> http://turingmachine.org/
>> http://silvernegative.com/
>> dmg (at) uvic (dot) ca
>> replace (at) with @ and (dot) with .
>>
>>
>>
>> ------------------------------------------------------------------------------
>>
>> _______________________________________________
>> Xournal-devel mailing list
>> Xournal-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/xournal-devel
>>
>

-- 
Denis Auroux
UC Berkeley, Department of Mathematics
817 Evans Hall, Berkeley CA 94720-3840, USA
aur...@math.berkeley.edu

------------------------------------------------------------------------------
_______________________________________________
Xournal-devel mailing list
Xournal-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/xournal-devel

Reply via email to