Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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

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

1 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...