Revision: 14612
http://sourceforge.net/p/skim-app/code/14612
Author: hofman
Date: 2024-10-30 17:30:36 +0000 (Wed, 30 Oct 2024)
Log Message:
-----------
add annotation to temporary page to draw when it has no page
Modified Paths:
--------------
trunk/SkimNotes/PDFAnnotation_SKNExtensions.m
Modified: trunk/SkimNotes/PDFAnnotation_SKNExtensions.m
===================================================================
--- trunk/SkimNotes/PDFAnnotation_SKNExtensions.m 2024-10-29 17:37:45 UTC
(rev 14611)
+++ trunk/SkimNotes/PDFAnnotation_SKNExtensions.m 2024-10-30 17:30:36 UTC
(rev 14612)
@@ -162,10 +162,15 @@
#if defined(PDFKIT_PLATFORM_IOS)
static UIImage *appearanceImageForAnnotation(PDFAnnotation *annotation) {
+ CGRect rect = [annotation bounds];
+ BOOL needsRemove = NO;
PDFPage *page = [annotation page];
- if (page == nil)
- return nil;
- CGRect rect = [annotation bounds];
+ if (page == nil) {
+ page = [[PDFPage alloc] init];
+ [page setBounds:CGRectMake(0.0, 0.0, CGRectGetMaxX(rect),
CGRectGetMaxY(rect)) forBox:kPDFDisplayBoxMediaBox];
+ [page addAnnotation:annotation];
+ needsRemove = YES;
+ }
CGRect bounds = [page boundsForBox:kPDFDisplayBoxCropBox];
UIGraphicsImageRenderer *renderer = [[UIGraphicsImageRenderer alloc]
initWithSize:rect.size];
UIImage *image = [renderer
imageWithActions:^(UIGraphicsImageRendererContext *context) {
@@ -188,6 +193,8 @@
CGContextRotateCTM(ctx, [page rotation] * M_PI / 180.0);
[annotation drawWithBox:kPDFDisplayBoxCropBox inContext:ctxt];
}];
+ if (needsRmove)
+ [page removeAnnotation:annotation];
return image;
}
@@ -194,10 +201,15 @@
#else
static NSImage *appearanceImageForAnnotation(PDFAnnotation *annotation) {
+ NSRect rect = [annotation bounds];
+ BOOL needsRemove = NO;
PDFPage *page = [annotation page];
- if (page == nil)
- return nil;
- NSRect rect = [annotation bounds];
+ if (page == nil) {
+ page = [[PDFPage alloc] init];
+ [page setBounds:NSMakeRect(0.0, 0.0, NSMaxX(rect), NSMaxY(rect))
forBox:kPDFDisplayBoxMediaBox];
+ [page addAnnotation:annotation];
+ needsRemove = YES;
+ }
NSRect bounds = [page boundsForBox:kPDFDisplayBoxCropBox];
NSImage *image = [[NSImage alloc] initWithSize:rect.size];
[image lockFocus];
@@ -217,6 +229,8 @@
#endif
[annotation drawWithBox:kPDFDisplayBoxCropBox
inContext:[[NSGraphicsContext currentContext] CGContext]];
[image unlockFocus];
+ if (needsRemove)
+ [page removeAnnotation:annotation];
return image;
}
#endif
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit