我正在从我的服务器将一个Base64编码的pdf作为字符串加载到我的Javascript中.我的客户端应用程序使用的是AngularJS,HTML5.
我的HTML看起来像这样:
<div id="printablePdfContainer">
<iframe id="printablePdf" width="100%" height="100%"></iframe>
</div>
Run Code Online (Sandbox Code Playgroud)
我的Javascript看起来像这样:
var pdfName = 'data:application/pdf;base64,' + data[0].PrintImage;
var embeddedPdf = document.getElementById('printablePdf');
embeddedPdf.setAttribute('src', pdfName);
$scope.printDocument(embeddedPdf);
Run Code Online (Sandbox Code Playgroud)
我的printDocument功能如下所示:
$scope.printDocument = function() {
var test = document.getElementById('printablePdf');
if (typeof document.getElementById('printablePdf').print === 'undefined') {
setTimeout(function(){$scope.printDocument();}, 1000);
} else {
var x = document.getElementById('printablePdf');
x.print();
}
};
Run Code Online (Sandbox Code Playgroud)
printDocument函数取自堆栈溢出中的预先存在的问题(静默打印嵌入式PDF),这是打印嵌入式pdf的答案.但是,这似乎不再起作用了.我总是得到'未定义'
typeof document.getElementById('printablePdf').print === 'undefined'
Run Code Online (Sandbox Code Playgroud)
校验.似乎.print不存在或什么的.
所以,我的问题是:如何使用Javascript在HTML5中打印嵌入式PDF,而无需打开弹出窗口?
问候,菲尔
我有这个界面:
public interface FakeTemplate {
@CustomAnnotation
void foo() {
}
}
Run Code Online (Sandbox Code Playgroud)
以及该接口的实现:
@Component
public FakeImpl implements FakeTemplate {
@Override
public void foo() {
//Do Stuff
}
}
Run Code Online (Sandbox Code Playgroud)
还有这方面:
@Aspect
@Component
public class CustomAspect {
@Before(value = "@annotation(com.fake.CustomAnnotation)")
public void doStuffBefore(JoinPoint joinPoint} {
}
}
Run Code Online (Sandbox Code Playgroud)
我正在使用启用了 AspectJ 的 spring,使用:@EnableAspectJAutoProxy(proxyTargetClass = true)
我的问题是doStuffBefore
在执行 FakeImpl 的方法之前没有调用方面方法foo()
。@CustomAnnotation
当我把onFakeImpl
而不是 时,它确实可以工作FakeTemplate
,但我更喜欢把注释放在 on 上FakeTemplate
,因为它位于单独的 API 包中,并且我将它委托为放置所有注释的地方。
我还想确保CustomAnnotation
在每个实现的类上调用 ,FakeTemplate
而无需记住在所有实现类本身上添加注释。
如果注释仅在接口类上,有什么方法可以获取要调用的建议吗?
我正在 Cassandra 中设计一个键空间,它将保存有关用户组的信息。有关它的一些信息:
我正在考虑两种设计。
select * from table where GroupID = {GroupID}
并返回与组中的用户一样多的行。select * from table where GroupID = {GroupID}
并返回一行,其中包含其 UserID 列集中包含的用户 ID 集。我找不到很多关于这种情况下更好的设计的文档。对这两种情况有什么想法或利弊吗?
angularjs ×1
annotations ×1
cassandra ×1
collections ×1
cql ×1
html ×1
html5 ×1
interface ×1
java ×1
javascript ×1
pdf ×1
schema ×1
spring ×1
spring-aop ×1