简体   繁体   English

使用 PI java 映射中的 Base64 有效负载从 url 获取 pdf 文件

[英]Get pdf file from url with Base64 payload in PI java mapping

I am able to get a PDF file from an URL, encoding the stream into base 64 and send the string to a third party within a field of a XML file, but I have the next issue when I try to open the PDF file decode.我能够从 URL 获取 PDF 文件,将流编码为 base 64 并将字符串发送到 XML 文件字段内的第三方,但是当我尝试打开 PDF 文件解码时遇到了下一个问题。

Cannot extract the embedded font 'ArialMT,Bold". Some characters may not display or print correctly.无法提取嵌入字体“ArialMT,Bold”。某些字符可能无法正确显示或打印。

Here is the code from Java Mapping in SAP PI 7.1:这是 SAP PI 7.1 中 Java 映射的代码:

    urlStr = "Insert here your url";
    StringBuffer data = new StringBuffer();
    URL url = new URL(urlStr);
    URLConnection conn = url.openConnection ();

    // Get the response
    BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
    StringBuffer sb = new StringBuffer();
    String line;
    String carriagereturn = System.getProperty("line.separator");

    while ((line = rd.readLine()) != null)
    {
        trace.addWarning(line);
        sb.append(line);
        sb.append(carriagereturn);
    }

    rd.close();
    result = sb.toString();
} catch (Exception e){
    trace.addWarning(e.toString());
}

return org.apache.commons.codec.binary.Base64.encodeBase64String(result.getBytes());

I have read that it is not possible to retrieve the font when you execute an InputStreamReader because of the copyrights of the letter.我已经读到,由于信件的版权,在执行InputStreamReader时无法检索字体。 Is it true?这是真的吗?

Is there other any possibility to embed the font afterwards using iText library or similar?之后是否还有其他可能使用 iText 库或类似库嵌入字体?

This may happens if the font was not embeded in the PDF during creation, and you do not have the same exact font on the system where you open the pdf.如果在创建过程中字体未嵌入 PDF 中,并且您在打开 pdf 的系统上没有完全相同的字体,则可能会发生这种情况。

Is the pdf generated using itext ? pdf 是使用 itext 生成的吗? in this case, this answer could help you.在这种情况下,这个答案可以帮助你。 otherwise, try putting the font in your system font directory.否则,尝试将字体放在系统字体目录中。

Edit : as for the second question, there is a small demo program to embed a font in an existing pdf file where the font is not embeded here编辑:至于第二个问题,有一个小的演示程序可以在现有的pdf文件中嵌入字体,这里没有嵌入字体

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM