destination

iText教程:创建带导航的目标
/*
 * $Id: Destinations.java,v 1.3 2005/05/09 11:52:45 blowagie Exp $
 * $Name:  $
 *
 * This code is part of the 'iText Tutorial'.
 * You can find the complete tutorial at the following address:
 * http://itextdocs.lowagie.com/tutorial/
 *
 * This code is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 *
 * itext-questions@lists.sourceforge.net
 */

package com.lowagie.examples.objects.bookmarks;

import java.io.FileOutputStream;

import com.lowagie.text.Document;
import com.lowagie.text.pdf.PdfContentByte;
import com.lowagie.text.pdf.PdfDestination;
import com.lowagie.text.pdf.PdfOutline;
import com.lowagie.text.pdf.PdfTemplate;
import com.lowagie.text.pdf.PdfWriter;

/**
 * Creates a document with some goto actions.
 * 
 * @author blowagie
 */

public class Destinations {

	/**
	 * Creates a document with some goto actions.
	 * 
	 * @param args
	 *            no arguments needed
	 */
	public static void main(String[] args) {

		System.out.println("Destinations");

		// step 1: creation of a document-object
		Document document = new Document();
		try {

			// step 2:
			PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("Destinations.pdf"));
			// step 3:       
            writer.setViewerPreferences(PdfWriter.PageModeUseOutlines);
			document.open();
            // step 4: we grab the ContentByte and do some stuff with it
            PdfContentByte cb = writer.getDirectContent();
            
            // we create a PdfTemplate
            PdfTemplate template = cb.createTemplate(25, 25);
            
            // we add some crosses to visualize the destinations
            template.moveTo(13, 0);
            template.lineTo(13, 25);
            template.moveTo(0, 13);
            template.lineTo(50, 13);
            template.stroke();
            
            // we add the template on different positions
            cb.addTemplate(template, 287, 787);
            cb.addTemplate(template, 187, 487);
            cb.addTemplate(template, 487, 287);
            cb.addTemplate(template, 87, 87);
            
            // we define the destinations
            PdfDestination d1 = new PdfDestination(PdfDestination.XYZ, 300, 800, 0);
            PdfDestination d2 = new PdfDestination(PdfDestination.FITH, 500);
            PdfDestination d3 = new PdfDestination(PdfDestination.FITR, 200, 300, 400, 500);
            PdfDestination d4 = new PdfDestination(PdfDestination.FITBV, 100);
            PdfDestination d5 = new PdfDestination(PdfDestination.FIT);
            
            // we define the outlines
            PdfOutline out1 = new PdfOutline(cb.getRootOutline(), d1, "root");
            PdfOutline out2 = new PdfOutline(out1, d2, "sub 1");
            PdfOutline out3 = new PdfOutline(out1, d3, "sub 2");
            PdfOutline out4 = new PdfOutline(out2, d4, "sub 2.1");
            PdfOutline out5 = new PdfOutline(out2, d5, "sub 2.2");
		} catch (Exception de) {
			de.printStackTrace();
		}

		// step 5: we close the document
		document.close();
	}
}
### 关于CMake中`DESTINATION lib`的相关配置和技术信息 在CMake构建系统中,`install()`命令用于定义如何安装目标文件(如库、可执行文件或头文件)。其中,`DESTINATION`参数指定了这些文件的目标安装路径。对于`lib`相关的配置,通常涉及以下几个方面: #### 1. 安装共享库到`lib`目录 当开发一个库项目时,可以将其编译后的共享库文件(`.so`, `.dll`, 或 `.dylib`)安装到系统的标准库路径下,通常是`lib`子目录。以下是实现这一功能的典型代码片段[^1]: ```cmake add_library(MyLib SHARED src/my_lib.cpp) target_include_directories(MyLib PUBLIC include) install(TARGETS MyLib LIBRARY DESTINATION lib ARCHIVE DESTINATION lib/static RUNTIME DESTINATION bin ) ``` 在此示例中,`LIBRARY DESTINATION lib`表示将共享库文件安装到`${CMAKE_INSTALL_PREFIX}/lib`路径下。 #### 2. 配置包管理工具支持 为了使其他项目能够轻松找到并链接该库,可以通过CMake生成相应的配置文件,并指定其安装位置。例如,在引用[1]中的例子展示了如何创建和安装`MyLibConfig.cmake`以及版本控制文件[^1]: ```cmake include(CMakePackageConfigHelpers) configure_package_config_file( MyLibConfig.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/MyLibConfig.cmake" INSTALL_DESTINATION lib/cmake/MyLib ) write_basic_package_version_file( "${CMAKE_CURRENT_BINARY_DIR}/MyLibConfigVersion.cmake" VERSION 1.2.3 COMPATIBILITY SameMajorVersion ) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/MyLibConfig.cmake" "${CMAKE_CURRENT_BINARY_DIR}/MyLibConfigVersion.cmake" DESTINATION lib/cmake/MyLib ) ``` 这里的关键在于`INSTALL_DESTINATION lib/cmake/MyLib`,它表明生成的配置文件会被放置在一个特定的子目录结构中,方便后续通过`find_package()`调用定位。 #### 3. 错误排查与常见问题解决方法 如果遇到关于`DESTINATION lib`的错误或者不期望的行为,可能的原因包括但不限于以下几点: - **权限不足**: 如果尝试写入受保护区域(比如 `/usr/lib`),需要管理员权限来完成操作。 - **路径冲突**: 当多个组件试图覆盖相同名称下的资源时会发生冲突;确保每个模块都有唯一的命名空间是非常重要的。 - **跨平台差异处理不当**: 不同操作系统对动态加载库有不同的约定(Linux 使用 `lib/*.so`, Windows 则可能是 `bin/*.dll` 和 `lib/*.lib` 等)。因此应该适当地调整 `RUNTIME`, `ARCHIVE`, 及 `LIBRARY` 的具体行为以适应目标环境需求。 针对这些问题,建议仔细检查项目的顶层 `CMakeLists.txt` 文件及其依赖关系声明是否正确无误[^2]。 --- ### 结合实际案例分析 假设我们正在设计类似于导航插件(`nav2_voronoi_planner`)这样的ROS节点程序,则除了基本的功能实现外还需要考虑如何发布供他人使用的接口文档及二进制产物。基于给定资料[^3],我们可以推测该项目已经包含了必要的源码组织形式,接下来只需补充合适的安装指令即可满足分发条件。 最终完整的 `CMakeLists.txt` 应至少包含如下部分逻辑: ```cmake # ... (省略其余设置) set_target_properties(nav2_voronoi_planner PROPERTIES EXPORT_NAME nav2_voronoi_planner) export(EXPORT Nav2VoronoiPlannerTargets FILE "${CMAKE_CURRENT_BINARY_DIR}/Nav2VoronoiPlannerTargets.cmake") install(TARGETS nav2_voronoi_planner EXPORT Nav2VoronoiPlannerTargets LIBRARY DESTINATION lib/${PROJECT_NAME} INCLUDES DESTINATION include/${PROJECT_NAME} ) install(DIRECTORY include/ DESTINATION include/${PROJECT_NAME} ) install(FILES voronoi_planner_plugin.xml DESTINATION share/${PROJECT_NAME}) ``` 此脚本不仅涵盖了核心库本身的安置策略,还兼顾到了额外元数据(XML 描述符)同步部署的要求。 ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值