- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我一直在使用似乎是在 MacOS 上生成打印件/PDF 的标准方法,方法是使用 WebView
生成内容,然后使用以下内容打印/另存为 PDF。
NSPrintOperation *printOperation = [NSPrintOperation printOperationWithView:[[[sender mainFrame] frameView] documentView]
printInfo:self.printInfo];
这很好用,但是 WebView
自 10.14 以来已被弃用,并且 10.15 即将转移到 WKWebView
。将 WKWebView
的 View 传递给 NSPrintOperation
总是会给出一个空白页面,这已在此处的其他几个问题中报告过。
我使用以下代码完成了所有工作:
WKWebViewConfiguration *configuration = [[WKWebViewConfiguration alloc] init];
self.webView = [[WKWebView alloc] initWithFrame:printRect configuration:configuration];
self.webView.navigationDelegate = self;
[self.webView loadHTMLString:htmlString baseURL:nil];
.
- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation API_AVAILABLE(macosx(10.13))
{
if (@available(macOS 10.13, *))
{
[webView takeSnapshotWithConfiguration:nil completionHandler:^(NSImage *snapshotImage, NSError *error) {
if (!error)
{
NSRect vFrame = NSZeroRect;
vFrame.size = [snapshotImage size];
NSImageView *imageView = [[NSImageView alloc] initWithFrame:vFrame];
[imageView setImage:snapshotImage];
NSPrintOperation *printOperation = [NSPrintOperation printOperationWithView:imageView
printInfo:self.printInfo];
if (self.saveToFilename)
{
printOperation.showsPrintPanel = NO;
printOperation.showsProgressPanel = YES;
}
else
{
printOperation.showsPrintPanel = YES;
printOperation.showsProgressPanel = YES;
}
BOOL success = [printOperation runOperation];
if (self.printCompletionBlock) self.printCompletionBlock(success);
}
}];
}
}
它生成 WKWebView
的图像快照,然后使用 NSImageView
传递给 NSPrintOperation
。问题是 PDF/Print 的质量不如旧方法。
如何从 WKWebView 获得与旧 WebView 相同的质量?
最佳答案
目前不支持从 WKWebView 在 macOS 上进行打印。
参见:
How does one Print all WKWebView On AND Offscreen content OSX and iOS
关于objective-c - MacOS PDF/WKWebView 打印质量差,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57509495/
我使用透视滤镜在视频上放了一张图片。 示例 https://yadi.sk/i/MXtWUArJ3TyWBm 我怎样才能提高质量? 代码 ffmpeg -y -i bg.mp4 -loop 1 -i
我是 Matlab 的新手,虽然我知道一些其他的编程语言,所以如果这很简单,请原谅我。我无法在 StackOverflow 或其他地方找到任何答案。 我使用以下代码生成一个图形: figure(6)
我是 Matlab 的新手,虽然我知道一些其他的编程语言,所以如果这很简单,请原谅我。我无法在 StackOverflow 或其他地方找到任何答案。 我使用以下代码生成一个图形: figure(6)
在包含另一个类时,我总是需要写#include "headername.h"。是否可以在不编写其他类或使用“#include”包含多个类的情况下访问其他类? 最佳答案 什么 #include指令的作用
我有一个 .webm我想加速以延时拍摄的视频。我的原创.webm视频是 1280x720 并且质量非常好,但是当我用 FFMPEG 加速它时质量真的很差(即使分辨率保持不变)。这是我正在使用的命令:
我正在使用以下命令生成缩略图: mogrify -resize 128x128 -quality 75 "some thumb file" 对于示例文件: 如果我不指定质量 75,我会得到一个 40K
我想使用流体库的模型。谁能解释一下(我是建模/模拟的新手):质量/能量/动量平衡的公式:稳态、动态和初始猜测初始固定-->之间有什么区别以及对初始化时间/计算的影响是什么时间;我什么时候需要哪一个。
我通过解析“fmt 流映射”得到流 URL, 问题是如果我的视频时长不到 1 小时,我会得到这个: { "comment_count" = 1; description = ""; "dislikes
我试图根据用户的屏幕高度分辨率显示不同的视频分辨率,我有这段代码,但我不是 javascript 专家。它应该改变 src 属性,如果 res 低于 o 等于 360px 高度,等等。有什么建议吗?
我有播放 HLS 视频的 ExoPlayer,问题是我需要让用户能够更改视频质量(自动/1080/720/480)。 我发现使用 AdaptiveTrackSelection.Factory 确实可以
我的应用程序使用 phpmyadmin 连接到 mysql 中的数据库并将图像存储在数据库中,但我的问题是当我从数据库下载图像并将图像发布到 imageview 上时,图像的质量非常低颜色也受到影响。
大家好,我一直在使用 JavaFx 场景构建器来构建一个包含一些 png 图片的图形用户界面。 到目前为止,我一直在使用标签,然后将它们放大以适合图片(以便图片可见。但是这个解决方案并不令人满意,因为
我注意到,在显示比例为 1:1 的小图片时,它们通常看起来呈 block 状。我可以在使用 时解决问题通过使用更大比例的图像并使用 css 设置所需的大小来标记。 但是,我想用 background
我是自定义 CSS 的新手。我的老板希望我在 Qualtrics 中添加自定义 CSS(在外观/高级下)。在编辑预览窗口中,一切似乎都格式正确,但在实际调查页面上,许多元素的格式并未应用:图像是原始大
所以我尝试使用 CreateFont 尝试创建一种类似于我在 Photoshop 中使用的字体,但如果你仔细观察,Photoshop 中的质量要好得多。 这是我用来创建字体的代码: CreateFon
在自动去歪斜和裁剪之后我得到了下面的图像: 我需要对这张图片进行 OCR。现在 ABBYY Engine SDK 11 For Linux 产生的结果不是很好: IMerasers - www,rai
我目前在我的项目中使用 xorshift128+,我知道它通过了 Big Crush,并且被认为可以根据其速度生成相当高质量的随机数。但是,它会生成 64 位数字,而我需要的绝大多数随机数都是小整数(
我使用 python 以较小的质量保存 jpeg im = Image.open(file) im.save(cached_file, quality=80, optimize=True, progr
我在保存或使用 Gmagick PHP 扩展时找不到任何属性。 http://php.net/manual/en/book.gmagick.php 如何在 Gmagick 中更改 JPEG 质量? 最
youtube视频通常具有多种视频分辨率(质量),例如240p,360p,720p等,我如何检索youtube视频具有的视频分辨率(质量)是否有可以获取此信息的youtube api?Google.A
我是一名优秀的程序员,十分优秀!