Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't convert svg to pdf #425

Open
OnlyFart opened this issue Jun 3, 2024 · 3 comments
Open

Can't convert svg to pdf #425

OnlyFart opened this issue Jun 3, 2024 · 3 comments

Comments

@OnlyFart
Copy link

OnlyFart commented Jun 3, 2024

This file can't covert to pdf.
test.svg.zip

If remove image, then convert work success

Command:
cairosvg test.svg -o test.pdf

Result:
OSError: [Errno cairo returned CAIRO_STATUS_READ_ERROR: b'error while reading from input stream'] 10

OS: macos
Version: 2.7.1

@OnlyFart
Copy link
Author

OnlyFart commented Jun 3, 2024

After a series of experiments, I found out that if execution goes along the first branch, then an error occurs. If according to the "else" branch, then everything works correctly

Снимок экрана 2024-06-03 в 16 44 06

@liZe
Copy link
Member

liZe commented Jun 3, 2024

Hi!

With image.png corresponding to the PNG in your SVG file, I’ve tested this small C code:

#include <cairo.h>
#include <stdio.h>

int main()
{
    cairo_surface_t *surface = cairo_image_surface_create_from_png ("/tmp/image.png");
    if (cairo_surface_status(surface) == CAIRO_STATUS_READ_ERROR)
        {
            printf("read error\n");
        }
    return 0;
}

It prints read error, so the problem comes from Cairo, not CairoSVG.

Maybe this PNG is broken? Otherwise, you should report a bug to Cairo, there’s not much we can do for you here.

@OnlyFart
Copy link
Author

OnlyFart commented Jun 4, 2024

Hi!

With image.png corresponding to the PNG in your SVG file, I’ve tested this small C code:

#include <cairo.h>
#include <stdio.h>

int main()
{
    cairo_surface_t *surface = cairo_image_surface_create_from_png ("/tmp/image.png");
    if (cairo_surface_status(surface) == CAIRO_STATUS_READ_ERROR)
        {
            printf("read error\n");
        }
    return 0;
}

It prints read error, so the problem comes from Cairo, not CairoSVG.

Maybe this PNG is broken? Otherwise, you should report a bug to Cairo, there’s not much we can do for you here.

Yes, this png is broken...

IEND header not correct
image

At the same time, cairosvg is capable of dealing with this broken file if it goes along another branch)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants