Posted 25 January 2024, 9:45 am EST
Hi,
I use SVG pictures as background of my cells
testsvg.zip
but when I export them in PDF format, the pictures are no longer in SVG
testsvgpdf.zip
Is there a way to keep my SVG format in the pdf file?
thanks
Forums Home / Spread / SpreadJS
Posted by: Fabrice.Mainguene on 25 January 2024, 9:45 am EST
Posted 25 January 2024, 9:45 am EST
Hi,
I use SVG pictures as background of my cells
testsvg.zip
but when I export them in PDF format, the pictures are no longer in SVG
testsvgpdf.zip
Is there a way to keep my SVG format in the pdf file?
thanks
Posted 29 January 2024, 12:34 pm EST
No idea?
Posted 30 January 2024, 12:12 am EST
Hi,
We are currently investigating the method to verify image formats within a PDF. Could you please share the details of how you are checking image formats in a PDF, or if you are utilizing any specific libraries for this purpose?
Best regards,
Ankit
Posted 30 January 2024, 6:01 am EST
if zooming in on images doesn’t convince you, you can use the python script:
import PyPDF2
from PIL import Image
from io import BytesIO
def extract_image_extensions(pdf_file):
image_extensions = set()
try:
with open(pdf_file, 'rb') as file:
reader = PyPDF2.PdfReader(file)
num_pages = len(reader.pages)
for page_num in range(num_pages):
page = reader.pages[page_num]
images=page.images
for obj in images:
print(obj.name)
except Exception as e:
print(f"Une erreur s'est produite : {e}")
return image_extensions
pdf_file_path = "c:\\python\\exemple.pdf"
extensions = extract_image_extensions(pdf_file_path)
print("Extensions des images dans le fichier PDF:", extensions)
The result for my pdf are:
I1.png
I2.png
I3.png
Posted 31 January 2024, 12:34 am EST
Hi,
I was able to observe the same behavior with the PDF file exported from the SpreadJS. I have escalated it to the concerned dev team for further investigation.
The internal tracking id for the same is: SJS-22607 and I will let you know when there is more info on this from the dev team.
Regards,
Ankit
Posted 4 February 2024, 5:31 pm EST
Hi,
The devs have mentioned that this is the limitation of the current implementation. The SpreadJS uses Canvas to render everything in sheets, and when generating PDF, all the images will use Canvas API to generate directly, and therefore, the images will be pixilated and not SVG.
Regards,
Ankit