将一个PDF页面拆分为两个

编程入门 行业动态 更新时间:2024-10-11 21:20:30
本文介绍了将一个PDF页面拆分为两个的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想将一个宽PDF页面分成两个PDF页面。我的原始页面宽两个A4页面大小但高度正常(对于A4)。我试图使用IText但没有效果。感谢您的关注。

i want to split one wide PDF page into two PDF pages. My original page is wide as two A4 page size but height is normal(for A4). I trying to use IText but with no effects. Thanks for attention.

推荐答案

我不知道iText API,但您可以按照以下步骤前往:

I don't know the iText API, but you can follow these steps to get there:

创建现有页面的两个新副本。这意味着您拥有相同的资源,相同的ContentStream等。

Create two new copies of the existing page. This means that you have the same Resources, the same ContentStream, etc.

获取第一页的MediaBox,这是一个列为[llx lly urx ury]的数组。

Get the MediaBox for the first page which is an array laid out as [llx lly urx ury].

if MediaBox[2] - MediaBox[0] == long edge of A4 page then HalfPageWidth = MediaBox[2] - MediaBox[0]; PageCopy1.CropBox = [MediaBox[0] MediaBox[1] (MediaBox[0] + HalfPageWidth) MediaBox[3]] PageCopy2.CropBox = [(MediaBox[0] + HalfPageWidth) MediaBox[1] MediaBox[2] MediaBox[3]] else HalfPageHeight = MediaBox[3] - MediaBox[1]; PageCopy1.CropBox = [MediaBox[0] MediaBox[1] MediaBox[2] (MediaBox[1] + HalfPageHeight)] PageCopy2.CropBox = [MediaBox[0] (MediaBox[1] + HalfPageHeight)] MediaBox[2] MediaBox[3]]

删除原始页面并保存这两页。基本上,您正在制作两个相同的页面副本,并将每个页面裁剪为一半。您可能还需要设置页面旋转。

Remove the original page and save these two pages. Basically, you're making two identical copies of the page and cropped each to half the page. You may also need to set the page rotation.

更多推荐

将一个PDF页面拆分为两个

本文发布于:2023-10-08 01:06:02,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1471059.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:两个   页面   PDF

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!