문제

I'm trying to create pdf documents on the fly in an application, i.e. a user clicks a link and a pdf document is displayed to them with some text and some images.

I'm currently using FPDF v1.6 (http://www.fpdf.org/) which supports 24bit (true colour) png's but the problem I have is that this is a legacy application and there's 1000's of png's that are of 16bit colour depth which FPDF does not support and I can't simply convert due to other parts of the application using these images.

The only solutions I see are:

  1. convert the 16bit png image on the fly and embed that into the pdf.
  2. find a new class pdf class that will accept 16bit colour depth png's.

Anyone have any ideas?

도움이 되었습니까?

해결책

Maybe you could try using TCPDF (never used it with 16bit PNGs but it should be easy to test it).

다른 팁

Fixed with this in python:

def fix_16_bit_depth_not_supported(raw_image_path):
    """
    fix
    RuntimeError: FPDF error: 16-bit depth not supported: test.png
    """
    new_file, filename = tempfile.mkstemp(suffix='.png')
    os.close(new_file)
    i = cv2.imread(raw_image_path, cv2.IMREAD_UNCHANGED)
    img = np.array(i, dtype=np.float32)
    convert = img / 255.
    cv2.imwrite(filename, convert)
    return filename
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top