Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Mon Jun 10, 2024 1:39 am

Hello.
I used Spire.PDF to play Flatten with Python, but it's becoming Flatten with the image gone.
I want to play Flatten without the image disappearing, what should I do?

mhkim8282
 
Posts: 3
Joined: Wed Jun 05, 2024 6:36 am

Tue Jun 11, 2024 1:42 am

Hello,

Thanks for your inquiry.
To help us further investigate your issue, please provide us with your test file and your test code, you can attach here or send them to this email: support@e-iceblue.com. Thank you in advance.

Sincerely
William
E-iceblue support team
User avatar

William.Zhang
 
Posts: 454
Joined: Mon Dec 27, 2021 2:23 am

Tue Jun 11, 2024 6:01 am

Hello

Below is the source code that downloaded the PDF file and flattened the PDF file again.

If there is an existing image, the image does not come out.

Thank you.

Code: Select all
    def download_file(url, file_path, flatten_file_path=None, type=None):
        try:
            response = requests.get(url, stream=True)
            if response.status_code == 200:
                with open(file_path, 'wb') as f:
                    for chunk in response.iter_content(chunk_size=1024):
                        if chunk:
                            f.write(chunk)

                if type == "form":
                    doc = PdfDocument()
                    # Load a PDF file
                    doc.LoadFromFile(file_path)
                    doc.Form.IsFlatten = True
                    doc.SaveToFile(flatten_file_path)

                    doc.Close()
           
                return True
            else:
                return False

        except Exception as e:
            raise e

mhkim8282
 
Posts: 3
Joined: Wed Jun 05, 2024 6:36 am

Tue Jun 11, 2024 8:37 am

Hello,

Thanks for your feedback.
I simulated a pdf file with image and form fields. After flattening, the image is not lost. I uploaded this file for your reference. The problem should be related to the file, so please provide us with your result document so that we can investigate more accurately. Thanks in advance.

Sincerely
William
E-iceblue support team
User avatar

William.Zhang
 
Posts: 454
Joined: Mon Dec 27, 2021 2:23 am

Wed Jun 12, 2024 12:10 am

Hello

Thank you for your answer.

Attached is the original PDF and the PDF file processed by Flatten.
The original PDF has an image, but the image disappears when the platten processing is performed.

Is there a way to deal with it?

Thank you.

Have a nice day.

mhkim8282
 
Posts: 3
Joined: Wed Jun 05, 2024 6:36 am

Wed Jun 12, 2024 1:32 am

Hello,

Thanks for your reply.
I have reproduced the issue you mentioned using your file and have logged this issue to our tracking system with ticket SPIREPDF-6829. Our dev team will investigate further and fix it. I will notify you once it is fixed. Sorry for the inconvenience.

Sincerely
William
E-iceblue support team
User avatar

William.Zhang
 
Posts: 454
Joined: Mon Dec 27, 2021 2:23 am

Return to Spire.PDF