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

PIL.PdfParser.PdfFormatError: xref entry duplicated (and not identical) #7084

Closed
leo20160311 opened this issue Apr 12, 2023 · 5 comments · Fixed by #7102
Closed

PIL.PdfParser.PdfFormatError: xref entry duplicated (and not identical) #7084

leo20160311 opened this issue Apr 12, 2023 · 5 comments · Fixed by #7102

Comments

@leo20160311
Copy link

leo20160311 commented Apr 12, 2023

Hi boss
My program encountered a problem and I don't know how to solve it, please help, thanks
I have sent the relevant documents to email: [aclark@python-pillow.org]

this is my code:

my_bytes = open(tiffilepath, 'rb').read()
my_image = Image.open(BytesIO(my_bytes))
my_image.save(fp=dstfilepath, append=True)
my_image.close()

error:

    my_image.save(fp=outpdfpath, append=True)
  File "C:\Users\S0049\AppData\Local\Programs\Python\Python39\lib\site-packages\PIL\Image.py", line 2431, in save
    save_handler(self, fp, filename)
  File "C:\Users\S0049\AppData\Local\Programs\Python\Python39\lib\site-packages\PIL\PdfImagePlugin.py", line 52, in _save
    existing_pdf = PdfParser.PdfParser(f=fp, filename=filename, mode="r+b")
  File "C:\Users\S0049\AppData\Local\Programs\Python\Python39\lib\site-packages\PIL\PdfParser.py", line 379, in __init__
    self.read_pdf_info()
  File "C:\Users\S0049\AppData\Local\Programs\Python\Python39\lib\site-packages\PIL\PdfParser.py", line 545, in read_pdf_info
    self.read_trailer()
  File "C:\Users\S0049\AppData\Local\Programs\Python\Python39\lib\site-packages\PIL\PdfParser.py", line 639, in read_trailer
    self.read_prev_trailer(self.trailer_dict[b"Prev"])
  File "C:\Users\S0049\AppData\Local\Programs\Python\Python39\lib\site-packages\PIL\PdfParser.py", line 642, in read_prev_trailer
    trailer_offset = self.read_xref_table(xref_section_offset=xref_section_offset)
  File "C:\Users\S0049\AppData\Local\Programs\Python\Python39\lib\site-packages\PIL\PdfParser.py", line 965, in read_xref_table
    check_format_condition(
  File "C:\Users\S0049\AppData\Local\Programs\Python\Python39\lib\site-packages\PIL\PdfParser.py", line 78, in check_format_condition
    raise PdfFormatError(error_message)
PIL.PdfParser.PdfFormatError: xref entry duplicated (and not identical)
@radarhere
Copy link
Member

So to be clear, you're not able to attach the TIFF image here? I presume because you're not comfortable posting the image publicly?

@radarhere
Copy link
Member

Having seen another issue that you've created recently, it appears that you just don't think you can post TIFF images here.

I know that GitHub will say 'We don't support that file type' if you try and upload a TIFF image directly. However, you can either
a) create a zip of the image, and then upload that
or
b) just change the file extension to something else, from '.tiff' to say '.txt', and then upload that

@leo20160311
Copy link
Author

Thank you for your patient guidance. By dragging and dropping, I was able to upload files. Thank you very much:
TIFF.zip

@leo20160311
Copy link
Author

Yes, just because I don't know how to upload the problematic file, I'm very sorry

So to be clear, you're not able to attach the TIFF image here? I presume because you're not comfortable posting the image publicly?

no, just because I don't know how to upload the problematic file, I'm very sorry

@radarhere
Copy link
Member

How did you create this PDF?

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

Successfully merging a pull request may close this issue.

2 participants