试图使用Wicked PDF.
我在控制器中有这个代码
def pdf
pdf = WickedPdf.new.pdf_from_string(
render_to_string(
pdf: 'filename.pdf',
template: '/pages/poa.html.slim',
layout: '/layouts/pdf'),
header: {
content: render_to_string({
template: '/pdfs/poa_header.html.slim',
layout: '/layouts/pdf'
})
})
save_path = [Rails.root, '/public/pdf/', 'filename.pdf'].join
File.open(save_path, 'wb') do |file | file << pdf
end
end
Run Code Online (Sandbox Code Playgroud)
我在尝试执行上面的操作时收到此错误消息
RuntimeError (Failed to execute:
Error: "\xFE" from ASCII-8BIT to UTF-8):
Run Code Online (Sandbox Code Playgroud)
我已经尝试清空我正在渲染的模板和布局的内容但仍然出错.
最近我正在为android构建一个应用程序.我正在使用phonegap来做同样的事情.一切都运行良好,除了一个问题,即我无法在Android中使用jquery打开pdf文件.我已经尝试了很多相同但我无法做到这一点.
我想要的是,点击图像后,它将从网址打开一个pdf.
编辑:
我试过这个:
<img src="img/b_img1.png" onclick="openPdf('http://www.w3.org/2011/web-apps-ws/papers/Nitobi.pdf')"/>
Run Code Online (Sandbox Code Playgroud)
openPdf函数是这样的:
function openFile(pdfUrl) {
window.plugins.fileOpener.open(pdfUrl);
}
Run Code Online (Sandbox Code Playgroud)
fileOpener插件是这样的:
cordova.define("cordova/plugin/fileopener",
function(require, exports, module) {
var exec = require("cordova/exec");
var FileOpener = function() {};
FileOpener.prototype.open = function(url) {
exec(null, null, "FileOpener", "openFile", [url]);
};
var fileOpener = new FileOpener();
module.exports = fileOpener;
});
/**
* Load Plugin
*/
if (!window.plugins) {
window.plugins = {};
}
if (!window.plugins.fileOpener) {
window.plugins.fileOpener = cordova.require("cordova/plugin/fileopener");
}
Run Code Online (Sandbox Code Playgroud)
我在config.xml页面中添加了插件,如下所示:
<plugin name="FileOpener" value="com.phonegap.plugins.file.FileOpener"/>
Run Code Online (Sandbox Code Playgroud)
我已经在com.phonegap.plugins.file包中添加了FileOpener.java,如下所示:
package com.phonegap.plugins.file;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import …Run Code Online (Sandbox Code Playgroud) 您好,如果我尝试使用 ssh 连接 bitbucket.org
ssh -vT git@bitbucket.org
Run Code Online (Sandbox Code Playgroud)
一切正常
debug1: Authentication succeeded (publickey).
Run Code Online (Sandbox Code Playgroud)
但如果我尝试使用该git clone命令,我会收到以下消息:
Permission denied (publickey).
fatal: The remote end hung up unexpectedly
Run Code Online (Sandbox Code Playgroud)
一些额外信息:
~/.ssh/ssh-add -l返回正确的密钥。(RSA)