- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 FPDF() 方法(来自 FPDI_Protection.php)导入现有的 PDF 并应用密码保护。
我遇到的问题是原始 PDF 混合了纵向和横向页面(8.5"X11"& 11"X8.5"),而导入方法让您定义一次。我可以将新创建的 pdf 定义为 11"X11",这解决了其中一个方向裁剪的问题,但这对于打印来说并不理想,因为 PDF 被缩放并左对齐,导致可读性/打印输出不佳。
在循环遍历原始文档时,我可以使用任何类型的例程来检测原始大小并即时设置新页面方向吗?
function pdfEncrypt ($origFile, $password, $destFile) // RESPONSIBLE FOR ADDING PASSWORD PROTECTION TO PDF FILES
{
require_once('fpdi/FPDI_Protection.php');
$pdf = new FPDI_Protection();
// set the format of the destinaton file, in our case 6×9 inch
$pdf->FPDF('P', 'in', array('11','11'));
//calculate the number of pages from the original document
$pagecount = $pdf->setSourceFile($origFile);
// copy all pages from the old unprotected pdf in the new one
for ($loop = 1; $loop <= $pagecount; $loop++)
{
$tplidx = $pdf->importPage($loop);
$pdf->addPage();
$pdf->useTemplate($tplidx);
}
// protect the new pdf file, and allow no printing, copy etc and leave only reading allowed
$pdf->SetProtection(array('print'), $password, '');
$pdf->Output($destFile, 'F');
return $destFile;
}
最佳答案
好吧,我在这个头发上拔了几天。在不知疲倦地谷歌搜索与我的问题相关的术语的每次迭代后,我能够找到一个实际有效的解决方案实例(我尝试安装 pdflib lite、phpinfo、ghostscript、xpdf 等,以测量尺寸无济于事)。有效的是这个(你需要 FPDI_Protection package [免费]):
$specs = $pdf->getTemplateSize($tplidx);
$pdf->addPage($specs['h'] > $specs['w'] ? 'P' : 'L');
function pdfEncrypt ($origFile, $password, $destFile) // RESPONSIBLE FOR ADDING PASSWORD PROTECTION TO PDF FILES
{
require_once('fpdi/FPDI_Protection.php');
$pdf = new FPDI_Protection();
// set the format of the destinaton file
$pdf->FPDF('P', 'in', array('8.5','11'));
//calculate the number of pages from the original document
$pagecount = $pdf->setSourceFile($origFile);
// copy all pages from the old unprotected pdf in the new one
for ($loop = 1; $loop <= $pagecount; $loop++)
{
$tplidx = $pdf->importPage($loop);
$specs = $pdf->getTemplateSize($tplidx);
$pdf->addPage($specs['h'] > $specs['w'] ? 'P' : 'L');
$pdf->useTemplate($tplidx);
}
// protect the new pdf file
$pdf->SetProtection(array('print'), $password, '');
$pdf->Output($destFile, 'F');
return $destFile;
}
关于php - FPDF - 它可以处理混合方向(纵向/横向)的原始 PDF 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15235935/
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 这个问题似乎是题外话,因为它缺乏足够的信息来诊断问题。 更详细地描述您的问题或include a mi
如何将我的 phonegap 应用程序的方向锁定为纵向? 我当前的 config.xml正在使用此首选项: 但这没有什么区别,我仍然可以通过旋转我的移动测试设备来在两个方向上定位我的应用程序。 此外
我正在用Xcode 7开发一个iPhone应用程序,该应用程序只能以纵向模式打开。我的问题是我是否还需要为横向模式提供启动/启动/默认屏幕,或者以各种纵向模式提供它就足够了吗? 最佳答案 我认为只添加
我正在试用 BluetoothChat sample ,问题是,当您在纵向/横向模式之间切换时,它会断开连接。我需要做什么才能通过该更改来维护连接和数据? 最佳答案 几个选项: 将所有蓝牙通信位移动到
所以我仍在学习移动设备的 css/html。我有一个网站,在桌面上看起来不错。当您在移动设备上将其拉起时,菜单消失了。如果你进入景观模式,菜单就会出现。对原因有什么帮助吗? 菜单代码。
我们的 React 应用程序有大约 10 个不同的路由,我们希望它们都可以打印。我们正在使用 css 打印媒体查询来清理样式以进行打印,并且前端有一个调用 window.print() 的按钮。单击时
我想让我的按钮为我的纵向 View 和横向 View 以不同的方式排列。我还希望能够将现在可能在我的纵向 View 中的东西添加到我的横向 View 中。我知道这是可能的原因显然是每部 iphone
我正在使用 jQuery 为交互式网站触发不同的 css 转换,例如单击时将对象 A 移动到位置 1。现在这些选项在不同的视口(viewport)上应该是不同的。 虽然在 css 中使用类很容易实现这
我正在开发一个画廊,我想根据图片方向自动旋转 View 。例如,两张照片: 1200 宽 x 800 高像素 550 宽 x 800 高像素 现在要确定哪个是肖像,我只需要检查是否高度>宽度?这是唯一
我有一个简单的幻灯片(列表项),但结合了纵向和横向图像。我在流体网格上工作,所以一切基本上都是 100% 的。 我想知道是否有一种方法可以让所有图像保持相同的高度,但宽度保持符合它们的比例。所有图片在
我想仅在平板电脑中为我的应用程序启用屏幕方向更改,同时将手机中的布局限制为仅纵向。你是怎么做到的? 最佳答案 无论如何,请阅读this .它应该给你一个关于如何去做的想法。 标签允许您声明您希望您的应
我正在使用 UIImagePickerController 拍摄和编辑照片。它在风景中工作正常,但在肖像中它会将图片裁剪成正方形(不允许像在风景中那样缩小图像以完全适合方形裁剪区域。有什么想法吗? 代
根据产品要求,我必须将应用程序的方向保持为手机纵向和平板电脑横向。在调用 super.onCreate() 之前,使用以下代码为 onCreate() 回调中的每个 Activity 设置方向 pub
我的网站在 iPad 上显示不正确 - 纵向模式。它在横向模式下看起来很好,但是当我将它变成纵向模式时,我最终得到一个凌乱的网站。所有元素散布在整个站点。我怎样才能解决这个问题?请帮我。 这是我网站的
我已经为网页设置了背景,并且通过提供媒体查询来响应它。当我在 ipadpeek.com 上查看结果时(请查看网站 here 一次以查看原始纵向模式背景和横向模式背景) 对于 ipad 的分辨率,它在横
即使我的设备旋转(纵向->横向->纵向),我也需要始终以横向模式录制视频。 取角度很简单,我用的是hyroscope。我的问题是总是横向录制视频。需要任何建议。 我正在使用 AVCaptureSess
我正在从 PHAsset 中获取视频,以便用户可以选择视频并导入以执行编辑。但是用户应该只能选择横向视频,如果用户选择纵向视频,她/他会收到警告消息,说明其纵向视频因此无法导入进行编辑。 实现此目的的
如果你去here在 iPad 上,点击 Chapter1 > Chapter 1 > Get started... 您将在加载屏幕后看到第 1 章页面。 基本上,这是将 html 嵌入到由 HTML5
我有一个可以纵向或横向启动的应用程序。我希望 Default.png 文件(应用程序启动时出现的初始图像)以正确的方向显示图像,因此我希望我需要使用两个不同的图像(不同尺寸)。但是,我不知道如何让应用
我正在寻找一个脚本来检测屏幕是横向还是纵向,而无需旋转手机(如果需要,则为初始屏幕尺寸),以便在游戏为横向游戏时显示图像以旋转设备(并且页面的初始加载是纵向的)。 我找到了很多有关“方向更改”事件的信
我是一名优秀的程序员,十分优秀!