亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

蠟染 將 SVG 轉換為 JPEG

蠟染 將 SVG 轉換為 JPEG

米脂 2022-08-17 17:25:42
JPEGTranscoder transcoder = new JPEGTranscoder();String urlPath = "D:/CRD_Material/Scheme/scheme-2.svg";String s1 = "<svg width='350' height='450' xmlns='http://www.w3.org/2000/svg'  xmlns:xlink='http://www.w3.org/1999/xlink'>"            + "<!-- Created with SVG-edit - http://svg-edit.googlecode.com/ -->  "            + "<g><title>Layer 1</title> "            + " <rect fill='none' stroke='#000000' stroke-width='2' stroke-linejoin='none' stroke-linecap='none' x='18' y='23' width='213' height='352' id='svg_6'/>"            + "   <line fill='none' stroke='#000000' stroke-width='2' stroke-linejoin='none' stroke-linecap='none' x1='17' y1='336' x2='230' y2='336' id='svg_7'/>"            + "   <line fill='none' stroke='#000000' stroke-width='2' stroke-linejoin='none' stroke-linecap='none' x1='20' y1='58' x2='231' y2='58' id='svg_8' stroke-dasharray='2,2'/>"            + "   <rect id='svg_3' height='65' width='181' y='74' x='31' stroke-width='2' stroke='#000000' fill='#0'/>  </g> </svg>";FileWriter writer = new FileWriter("D:/PDFBox/test.svg");writer.write(s1);writer.close();transcoder.addTranscodingHint(JPEGTranscoder.KEY_QUALITY, new Float(1.0));TranscoderInput input = new TranscoderInput(new FileInputStream("D:/PDFBox/test.svg"));OutputStream ostream = new FileOutputStream("D:/PDFBox/out.jpg");TranscoderOutput output = new TranscoderOutput(ostream);transcoder.transcode(input, output);ostream.close();System.exit(0);這是我的代碼,我想將SVG字符串轉換為JPEG圖像。運行此代碼時,我收到以下錯誤:org.w3c.dom.DOMException: <unknown>:The attribute "stroke-linecap" represents an invalid CSS value ("none").Original message:The "none" identifier is not a valid value for the "stroke-linecap" property有人請幫幫我..提前致謝
查看完整描述

1 回答

?
慕后森

TA貢獻1802條經驗 獲得超5個贊

的唯一有效值為 、 和 ,例如,請參閱此處。缺省值為 。因此,要么更改為其中之一,要么刪除所有位置的段。stroke-linecapbuttroundsquarebuttnonestroke-linecap='none'

您的 svg 代碼也存在類似的問題,請參閱此處的有效值。stroke-linejoin

最后也是不正確的。如果需要黑色,請使用 或 .fill='#0'fill='#000000'fill='black'

因此,新字符串可以是

String s1 = "<svg width='350' height='450' xmlns='http://www.w3.org/2000/svg'  xmlns:xlink='http://www.w3.org/1999/xlink'>"
        + "<!-- Created with SVG-edit - http://svg-edit.googlecode.com/ -->  "
        + "<g><title>Layer 1</title> "
        + " <rect fill='none' stroke='#000000' stroke-width='2' x='18' y='23' width='213' height='352' id='svg_6'/>"
        + "   <line fill='none' stroke='#000000' stroke-width='2' x1='17' y1='336' x2='230' y2='336' id='svg_7'/>"
        + "   <line fill='none' stroke='#000000' stroke-width='2' x1='20' y1='58' x2='231' y2='58' id='svg_8' stroke-dasharray='2,2'/>"
        + "   <rect id='svg_3' height='65' width='181' y='74' x='31' stroke-width='2' stroke='#000000' fill='#000000'/>  </g> </svg>";



查看完整回答
反對 回復 2022-08-17
  • 1 回答
  • 0 關注
  • 121 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號