newDocument.getPages().add(pdfPage); // Save as PDF newDocument.save("page_" + pageCount + "_out" + ".pdf"); pageCount++; } 使用Java按页面集合拆分PDF文件 为了演示,让我们看一下另一个PDF拆分方案。在此示例中,我们将基于偶数和奇数页码拆分PDF。以下是执行此操作的
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-Java// Open a Word documentDocument doc = new Document("Word.docx");// Split nodes in the document into separate pagesDocumentPageSplitter splitter = new DocumentPageSplitter(doc);// Sav...
三、在线裁剪 PDF 您还可以使用我们的在线应用程序来裁剪 PDF 页面,该应用程序基于 Aspose.PDF for Java。这是一款免费的 PDF 裁剪应用程序,甚至不需要您注册。 本文演示了如何使用 Java 裁剪 PDF 文件中的页面。通过执行几个简单的步骤并编写几行代码,您就可以以编程方式裁剪所需的 PDF 页面。此外,我们还提供了...
以下是使用Java在PDF文件中添加图像的步骤。首先,创建Document 类的实例 以加载PDF文档。 使用Document.getPages()。get_Item(int)方法获取要添加图像的页面。 将图像文件加载到FileInputStream对象中。 将新页面添加到PDF文档并设置其属性。 从列表中将每个图像文件加载到文件流中。 将图像添加到页面的段落集合中...
1.java实现对pdf文件压缩: 引用的maven坐标 <!--文件压缩--> <dependency> <groupId>com.aspose</groupId> <artifactId>aspose-pdf</artifactId> <version>18.2</version> </dependency> 1. 2. 3. 4. 5. 6. 整理的代码片段 package tvap.pdfutil; import com.aspose.pdf.Document; import tvap.pdf...
您可以使用Aspose PDF for Java在PDF文件的页面上添加文本或图像水印。 importcom.aspose.pdf.Document;importcom.aspose.pdf.Page;importcom.aspose.pdf.TextStamp;publicclassAddWatermark{publicstaticvoidmain(String[]args){// 打开PDF文档DocumentpdfDocument=newDocument("input.pdf");// 创建一个文本水印TextStam...
看起来你的平台是Java,共享的代码是C#。所以要在java中工作,你需要使用Aspose.Pdf for Java jar,将...
在您的 Java 应用程序中安装 Aspose.PDF for Java 。 使用以下 Java 代码将多张 JPG 图像合并为一个 PDF: // Create a new PDF document Document pdfDocument = new Document(); // Define JPG files to merge String[] jpgFiles = {"image1.jpg", "image2.jpg", "image3.jpg"}; ...
要使用 C# 和 Aspose.PDF for .NET 旋转 PDF 中的页面,请按照以下步骤操作:在您的应用程序中安装 Aspose.PDF for .NET。使用以下代码片段在 C# 中旋转 PDF 的单个页面。using Aspose.Pdf;// Load the PDF documentDocument pdfDocument = new Document("input.pdf");// Rotate the first page by 90 ...
}case"EXCEL": {returnswitchFile(file, com.aspose.pdf.SaveFormat.Excel, "xlsx"); }case"PPT": {returnswitchFile(file, com.aspose.pdf.SaveFormat.Pptx, "pptx"); }case"PNG": {//图片类型的需要获取每一页PDF,一张一张转换Document pdfDocument =newDocument(file.getInputStream());//分辨率Resolu...