Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
914 views
in Technique[技术] by (71.8m points)

serialization - Serialize emf file using readAsDataUrl in javascript

I am working on a project where I need to import windows files (ppt, word, visio, etc) and need to convert the emf to pngs. I have the backend support via inkscape / php to handle the conversion, however, I have to POST to the BE using base64 encoded strings. So my usecase:

  1. POST serialized emf file to endpoint
  2. base64_decode the string, save a temp emf file and png
  3. Use inkscape to convert the emf to png.
  4. Return base64 string of png.

The biggest issue is that I believe the original encoding of the emf file isn't correctly serializing. Any thoughts? And, I can't post the actual emf image as a blob to the BE.

question from:https://stackoverflow.com/questions/65835004/serialize-emf-file-using-readasdataurl-in-javascript

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I figured out the issue that I was having and to fix it, I used JSZip to convert this to data:application/zip;base64. This encoded it properly and on the php endpoint, I decoded this into a tmp file, used inkscape to convert and returned the base64 encoded string of the newly created png. The issue was not using file_get_contents so the string that was being encoded didn't exist. I hope this helps someone else out there with a similar situation.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...