gpt4 book ai didi

html - 打印 (Cocoa) WebView 内容会生成剪切图像

转载 作者:行者123 更新时间:2023-12-03 17:16:07 48 4
gpt4 key购买 nike

有没有办法避免打印时 WebView 中渲染的 HTML 元素被剪切?

这是我试图避免的示例:

WebView image rendered in webview, cut when printed

我使用以下代码打印为 PDF:

// Copy the NSPrintInfo's sharedPrintInfo dictionary to start off with sensible defaults
NSDictionary* defaultValues = [[NSPrintInfo sharedPrintInfo] dictionary];
NSMutableDictionary* printInfoDictionary = [NSMutableDictionary dictionaryWithDictionary:defaultValues];

// Set the target destination for the file
[printInfoDictionary setObject:[savePanel URL] forKey:NSPrintJobSavingURL];

// Create the print NSPrintInfo instance and change a couple of values
NSPrintInfo* printInfo = [[[NSPrintInfo alloc] initWithDictionary: printInfoDictionary] autorelease];
[printInfo setJobDisposition:NSPrintSaveJob];
[printInfo setRightMargin:30.0];
[printInfo setLeftMargin:30.0];
[printInfo setTopMargin:70.0];
[printInfo setBottomMargin:70.0];
[printInfo setHorizontalPagination: NSFitPagination];
[printInfo setVerticalPagination: NSAutoPagination];
[printInfo setVerticallyCentered:NO];
[printInfo setHorizontallyCentered:NO];

// Create the print operation and fire it up, hiding both print and progress panels
NSPrintOperation* printOperation = [NSPrintOperation printOperationWithView:view printInfo:printInfo];
[printOperation setShowsPrintPanel:NO];
[printOperation setShowsProgressPanel:NO];
[printOperation runOperation];

最佳答案

问题很可能出在您用来渲染 webview 的 CSS 中。只需确保您没有使用任何带有“position:fixed”的容器 div。

关于html - 打印 (Cocoa) WebView 内容会生成剪切图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6297744/

48 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com