首页 \ 问答 \ 如何使用pdfbox将/ UF命令添加到pdf?(How do I add /UF command to a pdf using pdfbox?)

如何使用pdfbox将/ UF命令添加到pdf?(How do I add /UF command to a pdf using pdfbox?)

我已经实现了使用pdfbox库将相对链接添加到pdf的功能。下面是我用来添加链接的代码:

 PDAnnotationLink txtLink = new PDAnnotationLink();
 PDActionRemoteGoTo remoteGoto = new PDActionRemoteGoTo();
 PDComplexFileSpecification fileDesc = new PDComplexFileSpecification();
 fileDesc.setFile(System.IO.Path.GetFileName(path));
 remoteGoto.setOpenInNewWindow(true);
 remoteGoto.setFile(fileDesc);
 txtLink.setAction(remoteGoto);
 txtLink.setRectangle(rect);
 page.getAnnotations().add(txtLink);

这里是在pdf中输入的命令:

14 0 obj
<<
/Type /Filespec
/F (A-201-NORTH & SOUTHSITE ELEVATIONS.pdf)
>>
endobj

链接在adobe,ios查看器中工作。 但在PSPDF中不起作用。 另外,我有文件链接PSPDF的工作。 但是该文件中的命令与上面略有不同。以下是PSPDF中的链接命令:

113 0 obj
<<
/Type /Filespec
/F (A8.1 - INTERIOR ELEVATION.pdf)
/UF (A8.1 - INTERIOR ELEVATION.pdf)
/Desc()
>>

那么,我该如何使用pdfbox来创建这个命令。


I have implemented functionality to add a relative link into a pdf using the pdfbox library.Below is the code that I am using for adding the link:

 PDAnnotationLink txtLink = new PDAnnotationLink();
 PDActionRemoteGoTo remoteGoto = new PDActionRemoteGoTo();
 PDComplexFileSpecification fileDesc = new PDComplexFileSpecification();
 fileDesc.setFile(System.IO.Path.GetFileName(path));
 remoteGoto.setOpenInNewWindow(true);
 remoteGoto.setFile(fileDesc);
 txtLink.setAction(remoteGoto);
 txtLink.setRectangle(rect);
 page.getAnnotations().add(txtLink);

Here is the command entered in the pdf:

14 0 obj
<<
/Type /Filespec
/F (A-201-NORTH & SOUTHSITE ELEVATIONS.pdf)
>>
endobj

The links work in adobe, ios viewer. But does not work in PSPDF. Also, I have file whose link work in PSPDF. But the commands in that file differ slightly from the above.Here is the link command that works in the PSPDF:

113 0 obj
<<
/Type /Filespec
/F (A8.1 - INTERIOR ELEVATION.pdf)
/UF (A8.1 - INTERIOR ELEVATION.pdf)
/Desc()
>>

So, how do I create this command using pdfbox.


原文:https://stackoverflow.com/questions/46968111
更新时间:2022-05-27 08:05

最满意答案

$(this).text().indexOf("1") -

  1. $(this)是jQuery的选择器
  2. .text() jQuery函数从选择中选择文本(不是html)(点1)
  3. .indexOf("1") JavaScript核心函数在所选文本中找到1的位置(点2)[1出现在第一段](如果indexOf("Find_What")找不到我们要求的内容,则返回-1

基本上indexOf返回字符串匹配的索引,它可能是0,1 ...

例如-

"1st paragraph".indexOf("1");

IndexOf(“1”)将返回0,因为它位于第一个位置。

"<p>paragraph 1</p>".indexOf("1")在这种情况下,它将返回13。

所以-1肯定是在字符串中没有“1”(匹配)的情况。

PS-另外indexOf是更快和首选的函数,用于在JavaScript中搜索字符串中的内容。

在这里,您可以解渴以获得更多关于'indexOf'的知识。


In $(this).text().indexOf("1")-

  1. $(this) is selector from jQuery
  2. .text() jQuery function selects text (not html) from the selection (point 1)
  3. .indexOf("1") JavaScript core function finds the position of 1 in the selected text (point 2) [1 is present in the first paragraph] (If indexOf("Find_What") does not finds what we ask, it returns -1.

Basically indexOf returns index of the match in the string and it may be 0, 1 ...

For example-

"1st paragraph".indexOf("1");

IndexOf("1") will return 0 as it is at first position.

"<p>paragraph 1</p>".indexOf("1") In this case it will return 13.

So -1 is sure case for the absence of "1" (match) in the string.

PS- Also indexOf is faster and preferred function to search something in a string in JavaScript.

Here you can quench your thirst for more knowledge of 'indexOf'.

相关问答

更多
  • 这种类型的查询有时被称为关系划分 ,对此的常见解决方案是使用双重否定并要求饮用者不存在Bobbys所服务的任何啤酒,而不是他们喜欢的啤酒 。 遵循它可能有点棘手,但逻辑是合理的。 请注意,只要他们喜欢Bobbys所服务的所有东西,它就会包含可能也喜欢其他啤酒的饮用者。 select distinct drinker from likes l1 where not exists ( select * from sells s where bar = 'Bobbys' and n ...
  • 因为&*取消了彼此。 *提供c的值的解引用d 。 然后&给出c的地址或者d的值。 Because the &* cancels each other out. * dereference d which gives the value of c. And then & gives the address of c, or the value of d.
  • 代替: if ($startup = $currentDate) { 它应该是 if ($startup == $currentDate) { 而且,而不是使用 $currentDate = echo date("Y"); 尝试: $currentDate = date("Y"); Instead of: if ($startup = $currentDate) { it should be if ($startup == $currentDate) { Moreover, inst ...
  • 这里有一篇好文章。 它以“事件是一种机制,通过该机制,当某些事情发生时类可以通知其客户端。例如,当您单击按钮时,按钮单击事件通知将发送到托管该按钮的窗口。” 我认为这很好地解释了事情。 There is a good article here. It starts with "An event is a mechanism via which a class can notify its clients when something happens. For example when you click a ...
  • 首先,定义一个名为iterate的函数,并将返回类型指定为Int 。 它具有arity 1,类型为List[Int]参数l 。 List类型在整个函数式编程中都很突出,它的主要特征是它具有高效的前置,并且很容易将任何List分解为头尾。 头部将是列表的第一个元素(如果非空),尾部将是List的其余部分(它本身就是List ) - 这对于在List上运行的递归函数很有用。 这种match称为模式匹配..它本质上是C语言中的switch语句,但更强大 - switch将你限制为常量(至少在C语言中),但matc ...
  • 您需要将第二个IF嵌套在第一个的ELSE中,如下所示: if (Test-Path 'C:\Program Files (x86)\Microsoft Office\office15\lync.exe') { Start-Process 'C:\Program Files (x86)\Microsoft Office\office15\lync.exe' } Else { write-host "Lync is not installed" if (Test-Path 'C:\Progr ...
  • 在$(this).text().indexOf("1") - $(this)是jQuery的选择器 .text() jQuery函数从选择中选择文本(不是html)(点1) .indexOf("1") JavaScript核心函数在所选文本中找到1的位置(点2)[1出现在第一段](如果indexOf("Find_What")找不到我们要求的内容,则返回-1 。 基本上indexOf返回字符串匹配的索引,它可能是0,1 ... 例如- "1st paragraph".indexOf("1"); IndexOf ...
  • echo $row['active'] == 1 ? ''.htmlspecialchars($row['username']).'' : htmlspecialchars($row['username']); 在这里解释一下http://www.addedbytes.com/php/ternary-conditionals/ echo $row['active'] == 1 ? ''.htmlspecia ...
  • 做到了。 但是无法弄清楚如何进行datepicker值。