首页 \ 问答 \ 使用Apache PDFBox将实心圆圈添加到PDF页面(Adding of filled circles to PDF page using Apache PDFBox)

使用Apache PDFBox将实心圆圈添加到PDF页面(Adding of filled circles to PDF page using Apache PDFBox)

我正在尝试使用Apache PDFBox库以编程方式创建PDF文档。 类PDPageContentStream包含写入文本,绘制线条,贝塞尔曲线,矩形的方法。 但我找不到一种方法来绘制一个简单的实心圆。 有没有办法使用这个库来绘制它? 如果没有,您可以请建议一个免费的Java库,提供灵活的API以编程方式创建PDF文档? 提前致谢。


I'm trying to use the Apache PDFBox library to create a PDF document programmatically. The class PDPageContentStream contains methods to write text, draw lines, bezier curves, rectangles. But I can't find a way to draw a simple filled circle. Is there a way to draw it using this library? If not, can you please suggest a free Java library that provides flexible API to create PDF documents programmatically? Thanks in advance.


原文:https://stackoverflow.com/questions/42811353
更新时间:2024-05-06 07:05

最满意答案

我看到几个问题..

如果使用表单助手Form::open() / Form::close() ),则无需手动包含隐藏的CSRF令牌元素。 然而,更大的问题是你的javascript:

$('.profile-image .delete a.delete').click(function() {
    $(this).parent().find('.deletepic').click();
});

$.('form[name=delete-profile-image]')({
    url: $('form[name=update-account]').data('image-delete'),
    type: 'POST',
    dataType: 'json'
});

AJAX呼叫在哪里? (提示,它只是不存在..)当你可以在锚点本身触发AJAX调用时,为什么你会有一个锚元素触发单击表单内的隐藏按钮? 尝试将HTML更改为类似的内容......

@if (!empty($image))
    <a href="#" class="delete">Delete</a>
    {{ Form::open(array('url' => route('customer.account.profile.image.delete'), 'style' => 'display: none', 'id' => 'image_delete')) }}
        {{ Form::text('image', $image) }}
    {{ Form::close() }}
@endif

并将您的javascript更新为以下内容:

$('.profile-image .delete a.delete').click(function() {
    $('#image_delete').submit()
});

Couple of issues I see..

If you use the form helpers ( Form::open() / Form::close() ) you won't need to include the hidden CSRF token element manually. However the bigger issue is your javascript:

$('.profile-image .delete a.delete').click(function() {
    $(this).parent().find('.deletepic').click();
});

$.('form[name=delete-profile-image]')({
    url: $('form[name=update-account]').data('image-delete'),
    type: 'POST',
    dataType: 'json'
});

Where is the AJAX call? (Hint, it's just not there..) Why would you have an anchor element trigger a click on a hidden button inside a form when you can just fire off the AJAX call on the anchor itself? Try changing your HTML to something like this...

@if (!empty($image))
    <a href="#" class="delete">Delete</a>
    {{ Form::open(array('url' => route('customer.account.profile.image.delete'), 'style' => 'display: none', 'id' => 'image_delete')) }}
        {{ Form::text('image', $image) }}
    {{ Form::close() }}
@endif

And update your javascript to something like this:

$('.profile-image .delete a.delete').click(function() {
    $('#image_delete').submit()
});

相关问答

更多
  • 看起来这是因为jQuery将#符号视为锚点指示符,并将其后的所有内容都删除。 那不是jQuery,那是浏览器。 片段标识符永远不会作为URL的一部分发送到服务器。 您提供的URL会引发404错误(可能是您尝试提供示例URL,请使用example.com , foo.com是一个真实的网站!)但我会假设页面上显示的任何内容都会发生变化基于#被客户端JavaScript放在页面中,而不是服务器。 为了复制它,您需要对其JS进行反向工程,并在您自己的代码中重现它对页面所做的更改。 It appears as th ...
  • I want to call a controller method from jsp 你不能从jsp这样做,因为jsp将在服务器上的servlet中编译,这个servlet将返回一个html页面到客户端。 所以你可以从html而不是从jsp这样做。 But i wish to know is it possible in jquery to call a controller method (Or to hit a url as a normal url hit) without ajax. 您可以重 ...
  • 尝试改变路线 Route::post('/controle/pending/concludeAll', function() { $input = Input::only('ids'); $input = $input['ids']; foreach($input as $id) { $student = new App\Aluno(); $student = $student->where('id', '=', $id)->first(); ...
  • var url = '/ajax/?act=url&u=' + encodeURIComponent(website); 这应该工作! var url = '/ajax/?act=url&u=' + encodeURIComponent(website); this should work!
  • 默认情况下,Laravel在获得POST请求时需要_token参数。 您通常使用带有{!! csrf_token !!}刀片将其添加到表单中 {!! csrf_token !!} 。 使用Ajax也没有什么不同。 如果要执行POST请求,则需要将_token参数添加到请求中。 您可以通过将其直接添加到Ajax参数中,或者通过将jQuery添加到布局视图中告诉jQuery来处理它来实现此操作; 。 这是你 ...
  • 你可以保持url干净并将变量作为ajax调用中的数据传递。 var urlGetUser = "{{ URL::route('getUser') }}", userId = $(this).attr('user_id'); $.ajax({ type: "POST", url: urlGetUser, data: { id: userId } }).done(function( msg ) { alert( msg ); }); 这样您就不必为每个可能的用户ID创建ajax调用。 ...
  • 您可以通过验证设置参数的最小长度。 将它放入您的控制器并限制js代码minLength: 3中的最小长度。 use Validator; // at the top of controller public function search(Request $request) { $v = Validator::make($request->all(), [ 'q' => 'required|min:3', ]); if ($v->fails()) { ...
  • 相关文章

    更多
  • PDFBox在PDF文档中添加页面
  • PDFBox创建PDF文档
  • PDFBox环境配置
  • Apache Solr索引富文本(html word pdf)
  • 《基于Apache CXF构建SOA应用》PDF 下载
  • lucene读取word,excel,pdf
  • Apache Solr 介绍
  • apache solr之我们的应用
  • 《Apache源代码全景分析-第1卷:体系结构与核心模块》扫描版[PDF]
  • Apache Nutch(一)
  • 最新问答

    更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)