I have tried the approach in this example and the duplicate
我已经尝试了这个例子中的方法和副本。
I still continue to receive a blank image when I render it. I need to generate a png file from this base64 string. The label_string is the base64 encoded pdf that I receive from a shipping label creater.
当我渲染它的时候,我仍然会得到一个空白的图像。我需要从这个base64字符串生成一个png文件。label_string是我从一个shipping label creater收到的base64编码的pdf。
file = Tempfile.new(['order', '.png'])
File.open(file.path.to_s, 'wb') do |f|
f.write(Base64.decode64(label_string))
end
pdf = Services::Invoices::Pdf.new(invoice).process(file.path)
file.unlink
pdf
here is my label_string
这是我label_string
"JVBERi0xLjQKJeLjz9MKMiAwIG9iago8PC9MZW5ndGggNjEvRmlsdGVyL0ZsYXRlRGVjb2RlPj5zdHJlYW0KeJwr5HIK4TI2UzC2NFMISeFyDeEK5CpUMFQwAEJDBV1jIz1LIGlsqGekkJyroB+RZqjgkq8QyAUARuULswplbmRzdHJlYW0KZW5kb2JqCjQgMCBvYmoKPDwvVHlwZS9QYWdlL01lZGlhQm94WzAgMCAyODggNDMyXS9SZXNvdXJjZXM8PC9Qcm9jU2V0IFsvUERGIC9UZXh0IC9JbWFnZUIgL0ltYWdlQyAvSW1hZ2VJXS9YT2JqZWN0PDwvWGYxIDEgMCBSPj4+Pi9Db250ZW50cyAyIDAgUi9QYXJlbnQgMyAwIFI+PgplbmRvYmoKMSAwIG9iago8PC9MZW5ndGggMjQ4Mi9GaWx0ZXJbL0FTQ0lJODVEZWNvZGUvRmxhdGVEZWNvZGVdL1Jlc291cmNlczw8L1Byb2NTZXQgNSAwIFIvRm9udDw8L0YxIDYgMCBSL0YyIDcgMCBSL0YzIDggMCBSL0Y0IDkgMCBSL0Y1IDEwIDAgUi9GNiAxMSAwIFIvRjcgMTIgMCBSL0Y4IDEzIDAgUi9GOSAxNCAwIFIvRjEwIDE1IDAgUi9GMTEgMTYgMCBSL0YxMiAxNyAwIFI+Pi9YT2JqZWN0PDwvRmVkRXhHcm91bmQgMTggMCBSL0dyb3VuZEcgMTkgMCBSL2JhcmNvZGUwID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MDA2NjE3IDAwMDAwIG4gCjAwMDAwMDAxNDIgMDAwMDAgbiAKMDAwMDAwMzE2MiAwMDAwMCBuIAowMDAwMDAzMjEwIDAwMDAwIG4gCjAwMDAwMDMyOTkgMDAwMDAgbiAKMDAwMDAwMzM5MyAwMDAwMCBuIAowMDAwMDAzNDkwIDAwMDAwIG4gCjAwMDAwMDM1OTEgMDAwMDAgbiAKMDAwMDAwMzY3OSAwMDAwMCBuIAowMDAwMDAzNzcyIDAwMDAwIG4gCjAwMDAwMDM4NjggMDAwMDAgbiAKMDAwMDAwMzk2OCAwMDAwMCBuIAowMDAwMDA0MDYwIDAwMDAwIG4gCjAwMDAwMDQxNTEgMDAwMDAgbiAKMDAwMDAwNDI0NCAwMDAwMCBuIAowMDAwMDA0MzQxIDAwMDAwIG4gCjAwMDAwMDQ5NjMgMDAwMDAgbiAKMDAwMDAwNTMzMCAwMDAwMCBuIAowMDAwMDA2NjgwIDAwMDAwIG4gCjAwMDAwMDY3MjYgMDAwMDAgbiAKdHJhaWxlcgo8PC9TaXplIDIzL1Jvb3QgMjEgMCBSL0luZm8gMjIgMCBSL0lEIFs8YzIwNmM1YTk5MmMwYzk5NzIxNmE5NDQ2ZTM2MDVmOGM+PDI2MTU5NWIxZjhiMjA5MzcyZDBiMzM0M2YyMWNiZDQwPl0+PgpzdGFydHhyZWYKNjg2MgolJUVPRgo="
UPDATE: I found a similar problem at this question
更新:我在这个问题上发现了一个类似的问题。
2 个解决方案
#1
1
In Imagemagick, you can do that with the INLINE: input structure. See http://www.imagemagick.org/Usage/files/#inline. For example:
在Imagemagick中,可以使用内联:输入结构。看到http://www.imagemagick.org/Usage/files/内联。例如:
convert 'inline:data:image/png;base64,
R0lGODlhIAAgAPIEAAAAAB6Q/76+vvXes////wAAAAAAAAAAACH5BAEAAAUALAAA
AAAgACAAAAOBWLrc/jDKCYG1NBcwegeaxHkeGD4j+Z1OWl4Yu6mAYAu1ebpwL/OE
YCDA0YWAQuJqRwsSeEyaRTUwTlxUqjUymmZpmeI3u62Mv+XWmUzBrpeit7YtB1/r
pTAefv942UcXVX9+MjNVfheGCl18i4ddjwwpPjEslFKDUWeRGj2fnw0JADs=
' b64_noseguy.png
#2
0
file1 = Tempfile.new(['order', '.pdf'])
File.open(file1.path.to_s, 'wb') do |f|
f.write(Base64.decode64(label_string))
end
file = Tempfile.new(['order', '.png'])
im = Magick::Image.from_blob(open(file1.path.to_s).read).first
im.write(file.path.to_s)
pdf = Services::Invoices::Pdf.new(invoice).process(file.path)
file.unlink
pdf
This works, however; it does not seem like it would be the best solution.
然而,这作品;这似乎不是最好的解决方案。
#1
1
In Imagemagick, you can do that with the INLINE: input structure. See http://www.imagemagick.org/Usage/files/#inline. For example:
在Imagemagick中,可以使用内联:输入结构。看到http://www.imagemagick.org/Usage/files/内联。例如:
convert 'inline:data:image/png;base64,
R0lGODlhIAAgAPIEAAAAAB6Q/76+vvXes////wAAAAAAAAAAACH5BAEAAAUALAAA
AAAgACAAAAOBWLrc/jDKCYG1NBcwegeaxHkeGD4j+Z1OWl4Yu6mAYAu1ebpwL/OE
YCDA0YWAQuJqRwsSeEyaRTUwTlxUqjUymmZpmeI3u62Mv+XWmUzBrpeit7YtB1/r
pTAefv942UcXVX9+MjNVfheGCl18i4ddjwwpPjEslFKDUWeRGj2fnw0JADs=
' b64_noseguy.png
#2
0
file1 = Tempfile.new(['order', '.pdf'])
File.open(file1.path.to_s, 'wb') do |f|
f.write(Base64.decode64(label_string))
end
file = Tempfile.new(['order', '.png'])
im = Magick::Image.from_blob(open(file1.path.to_s).read).first
im.write(file.path.to_s)
pdf = Services::Invoices::Pdf.new(invoice).process(file.path)
file.unlink
pdf
This works, however; it does not seem like it would be the best solution.
然而,这作品;这似乎不是最好的解决方案。