小编phi*_*han的帖子

使用Javascript,HTML5,AngularJS从浏览器打印嵌入式PDF

我正在从我的服务器将一个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,而无需打开弹出窗口?

问候,菲尔

html javascript pdf html5 angularjs

7
推荐指数
1
解决办法
3万
查看次数

Spring方面调用接口方法上的自定义注释

我有这个界面:

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而无需记住在所有实现类本身上添加注释。

如果注释仅在接口类上,有什么方法可以获取要调用的建议吗?

java spring annotations interface spring-aop

5
推荐指数
1
解决办法
5592
查看次数

Cassandra 架构使用集合集合或多行

我正在 Cassandra 中设计一个键空间,它将保存有关用户组的信息。有关它的一些信息:

  • 只能通过请求某个组中包含哪些用户并更新组中包含的用户来访问此数据。
  • 读取将比写入频繁得多。
  • 每个组最多可包含 20,000 个用户 ID

我正在考虑两种设计。

  1. 每组多行:该表将有两列 TEXT 类型,并以主键(GroupID、UserID)为键,读取组中的用户将由组中的用户完成,select * from table where GroupID = {GroupID}并返回与组中的用户一样多的行。
  2. 使用 Cassandra Set Collection 每组一行:该表将有两列,第一列 (GroupID) 类型为 TEXT,第二列 (UserID) 类型为 SET[TEXT],并以 Pimary Key (GroupID) 为键。读取组中的用户将通过select * from table where GroupID = {GroupID}并返回一行,其中包含其 UserID 列集中包含的用户 ID 集。

我找不到很多关于这种情况下更好的设计的文档。对这两种情况有什么想法或利弊吗?

collections schema cql cassandra

4
推荐指数
1
解决办法
1661
查看次数