I have a pdf file that I want to save in my Postgres DB
When I tried to save the file it brings A string literal cannot contain NUL (0x00) characters.
so I followed the solution from here which replaces the null with a character
unicode(ppbData[0], errors='ignore').replace("\\x00", "\�")
The problem is that I can't convert it back to PDF now. I tried encode()
and other methods
file = open('new.pdf', 'wb')
file.write(text.encode())
file.close()
but it returns blank pdf
Is there any way to replaces the character with a null or any other way to convert it back to normal pdf? Maybe the first solution with replacing also wasn't right and there is another way?
I have a pdf file that I want to save in my Postgres DB
When I tried to save the file it brings A string literal cannot contain NUL (0x00) characters.
so I followed the solution from here which replaces the null with a character
unicode(ppbData[0], errors='ignore').replace("\\x00", "\�")
The problem is that I can't convert it back to PDF now. I tried encode()
and other methods
file = open('new.pdf', 'wb')
file.write(text.encode())
file.close()
but it returns blank pdf
Is there any way to replaces the character with a null or any other way to convert it back to normal pdf? Maybe the first solution with replacing also wasn't right and there is another way?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.