PDF to SVG conversion. Colors are changed visually. #3648
-
Hello! I have seen some strange results after converting PDF to SVG via Is there any way to fix this after conversion? Maybe I can get some information about these attributes from the Original PDF file: Converted from SVG (another lib): Converted from SVG (PyMuPDF): Thank you in advance for any help! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Sorry for the tardy reply!
The results of 3. and 4. look the same (as expected) - except that the PyMuPDF output is much smaller because of the top-compression options used in However, the result of step 3./4. indeed is not identical to the original PDF page. But the differences are not colors. Instead there are some incorrect reproductions like the following. |
Beta Was this translation helpful? Give feedback.
-
Ah, no: PyMuPDF is out of the loop anyway, because all is done by MuPDF - which PyMuPDF simply invokes. b=(0.13669031858444214, 0.12195010483264923, 0.1252918243408203)
[hex(int(round(b[i]*255))) for i in range(3)]
['0x23', '0x1f', '0x20'] If you convert that back to PDF, the result is [int(svgcolor[i], 16)/255 for i in range(3)]
[0.13725490196078433, 0.12156862745098039, 0.12549019607843137] Which is not the exact same value as you extracted it, but still significantly different from the original. So it looks like an inevitable deviation deviation. |
Beta Was this translation helpful? Give feedback.
Ah, no: PyMuPDF is out of the loop anyway, because all is done by MuPDF - which PyMuPDF simply invokes.
It appears that we have a conversion problem PDF <-> HTML colors. Your example
color=(0.13669031858444214, 0.12195010483264923, 0.1252918243408203)
for SVG is correctly converted into a HTML color:stroke="#231f20"
, see here:If you convert that back to PDF, the result is
Which is not the exact same value as you extracted it, but still significan…