Inserted images don't show up in Adobe Illustrator #784
-
I've written a script that generates qr codes and inserts them onto a pdf template using the insertImage module. While testing, I noticed that the inserted images do not show up in Illustrator, even though the pdf looks fine in Acrobat, Chrome, Firefox, etc. Although, I've noticed that the images sometimes only load a few seconds after the empty template. Any ideas what is causing this? I've attached the pdf. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
I am not using illustrator, so cannot really reproduce the problem. >>> doc.pdf_catalog()
1
>>> print(doc.xref_object(1))
<<
/Metadata 2 0 R
/OCProperties <<
/D <<
/ON [ 5 0 R 244 0 R ]
/Order 245 0 R
/RBGroups [ ]
>>
/OCGs [ 5 0 R 244 0 R ]
>>
/Pages 3 0 R
/Type /Catalog
>>
>>> print(doc.xref_object(245))
[ 244 0 R ]
>>> The
|
Beta Was this translation helpful? Give feedback.
-
Of course - just an idea. Thought the template might be transparent. Bad luck then. >>> import fitz
>>> help(fitz.Document.set_layer)
Help on function set_layer in module fitz.fitz:
set_layer(self, config, basestate=None, on=None, off=None, rbgroups=None)
Set the ON, OFF, RBGroups PDF keys of an OC layer.
>>> What is your version? Anyway, to remove the optional content instructions, use the following snippet: # after finishing your image inserts
page.cleanContents() # clean the syntax, join multiple contetns objects
xref = page.getContents()[0] # get xref of resulting single object
cont_lines = doc.xrefStream(xref).splitlines() # read it, break up into lines
for i in range(len(cont_lines)):
if cont_lines[i].startswith((b"/OC", b"EMC")):
cont_lines[i] = b""
cont = b"\n".join(cont_lines)
doc.updateStream(xref, cont)
# now save the document
# using "garbage=4, deflate=True" should result in a file of about 60% of original size This makes everything unconditionally visible. Hopefully Illustrator is at least smart enough to digest the result ... |
Beta Was this translation helpful? Give feedback.
Of course - just an idea. Thought the template might be transparent. Bad luck then.
What is your version?
Anyway, to remove the optional content instructions, use the following snippet: