Inkscape.org
Beginners' Questions Save mixed vector/raster document to PDF without changing images format
  1. #1
    nopria nopria @nopria

    I often use Inkscape (version 1.2.2) to make small changes to PDF vectorial content and save the modified document back to PDF format. However, if a PDF contains images, they are converted to PNG before saving the destination PDF, resulting sometimes in much bigger file size and lossy process (lossy because if afterwards I want, in order to reduce size of destination PDF, to convert back to JPG images originally in JPG, such JPG->PNG->JPG process is lossy in respect of image quality).

    Is there a way to save a mixed vector/raster document (such as a PDF containing images) leaving images intact?

    I would like images extracted from source and destination PDF to be exactly the same, not only in content but also in format and resolution.

    Thanks in advance for your attention.

     
     

     

     

  2. #2
    inklinea inklinea @inklinea⛰️

    You can try the poppler/cairo import option instead ? 

  3. #3
    nopria nopria @nopria

    I did, but this seems to be more an export matter.

  4. #4
    inklinea inklinea @inklinea⛰️

    I did a test. my pdf file size only changes slightly ( 2-3kb) when importing pdf then exporting as pdf.

    Size inflation usually happens if any alternation is made to the jpeg image before export, this could be anything no matter how tiny - as inkscape will resample to png for lossless editing.

    It can also happen if filters are applied at export - maybe try Filters>Remove Filters ? 

  5. #5
    nopria nopria @nopria

    I tested again my PDF, trying Filters->Remove Filters, but the issue is still there. The PDF has several JPG images embedded (I can extract them with command line Poppler), but when I save it from Inkscape, after deleting some vectorial lines, without touching the raster images at all, its file size increases from 19MB to 151MB, mainly because all images are converted to PNG (again I can extract them with command line Poppler). Please find below the links to the original and the modified PDF, if you want to make your own tests:

    https://e1.pcloud.link/publink/show?code=XZTznbZecDikDTg6xRirJuJkIN3Myg8YFoV

    https://e1.pcloud.link/publink/show?code=XZxznbZXuV5alPy3WLzH39GaQjIph4eUK2k

  6. #6
    inklinea inklinea @inklinea⛰️

    Which lines are you trying to edit, I have just moved around / deleted items from the central floor plan. Size has not changed. 

    I used poppler import

     

  7. #7
    inklinea inklinea @inklinea⛰️

    Which lines are you trying to edit, I have just moved around / deleted items from the central floor plan. Size has not changed. 

    I used poppler import

     

  8. #8
    nopria nopria @nopria

    I have to delete the borders and the upper left frame from the original 19MB PDF, you can see the exact result in the 151MB PDF. I used Poppler import too.

  9. #9
    inklinea inklinea @inklinea⛰️

    I've tried on Ubuntu and Windows 10. Both using Inkscape 1.2.2

    I have removed most of the green borders around the images, the diagram from the top left, the black dots below the images. Also remove a few black dot labels from the floor plan.

    Also the grey header and footer. 

    I used poppler import, then the select tool / delete and File>Save a copy and unchecked rasterise filter effects - nothing else. 

    The file gets smaller - about 18.1mb now.

    Other than that no sure.

  10. #10
    nopria nopria @nopria

    It seems to be the kind of import. In the previous post I said I used Poppler import but I must have been wrong. I tried again both and, regardless of changes to vectorial elements (even without changing anything, just saving as PDF after import), with Poppler import the PDF keeps approximately the same size, while with internal import it gets much bigger because images are converted to PNG. The evidence that the conversion happens while importing is that the internal import needs much more time than Poppler import (if the PDF contains many images).

    I made many tests in the past, I wonder how I did not notice such difference between internal and Poppler import; it would have saved me a lot of time also.

    Thanks for your help and perseverance.

     

     

Inkscape Inkscape.org Inkscape Forum Beginners' Questions Save mixed vector/raster document to PDF without changing images format