WebView pdf representation - div background colours AWOL
I create local mustache template driven HTML content and display it in my OS X 10.9 app using WebView. I get the WebView PDF representation like so: NSView *webDocumentView = [[[self.webView mainFrame] frameView] documentView]; NSData *pdfData = [webDocumentView dataWithPDFInsideRect:webDocumentView.frame]; However, the pdf rendering is missing some simple div background colouring (like alternating backgrounds on table rows). The HTML looks as required in the WebView. What have I missed? Jonathan ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: WebView pdf representation - div background colours AWOL
On Mar 11, 2014, at 8:55 AM, jonat...@mugginsoft.com wrote: > However, the pdf rendering is missing some simple div background colouring > (like alternating backgrounds on table rows). When I print from Safari there’s a checkbox to hide backgrounds (to save ink). Maybe that’s a WebView option that’s on by default? You could look for a property in the API that controls that. —Jens smime.p7s Description: S/MIME cryptographic signature ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: WebView pdf representation - div background colours AWOL
On 11 Mar 2014, at 16:03, Jens Alfke wrote: > > On Mar 11, 2014, at 8:55 AM, jonat...@mugginsoft.com wrote: > >> However, the pdf rendering is missing some simple div background colouring >> (like alternating backgrounds on table rows). > > When I print from Safari there’s a checkbox to hide backgrounds (to save > ink). Maybe that’s a WebView option that’s on by default? You could look for > a property in the API that controls that. > There is WebView -drawsBackground but this has no disernable effect. I will dig into the API a bit more. I was hung up on thinking that it was a CSS problem. Jonathan ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: WebView pdf representation - div background colours AWOL
> On 11 Mar 2014, at 16:03, Jens Alfke wrote: > >> >> On Mar 11, 2014, at 8:55 AM, jonat...@mugginsoft.com wrote: >> >>> However, the pdf rendering is missing some simple div background colouring >>> (like alternating backgrounds on table rows). >> >> When I print from Safari there’s a checkbox to hide backgrounds (to save >> ink). Maybe that’s a WebView option that’s on by default? You could look for >> a property in the API that controls that. >> > Thinking again about this. Perhaps I need to use an NSPrintOperation instead. Jonathan ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Getting a selection range from a pdfselection...
Dear cocoa-devs, Trying to figure out how to get a pages selection range (offset and length) for a pdfselection. I've been using the bounding rect, but if I have a selection that is a sentence that crosses lines and terminates half way in the last line, the rect includes everything to the edge (of course). But if I just want the offset and length, how do I extract that? Frustrated Matthew Weinstein ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: WebView pdf representation - div background colours AWOL
On 11 Mar 2014, at 17:12, jonat...@mugginsoft.com wrote: > There is WebView -drawsBackground but this has no disernable effect. That property is for the case where you want a transparent webview on screen. > Thinking again about this. > Perhaps I need to use an NSPrintOperation instead. Yeah, that's what I would have suggested. ISTR that PDF generation generally goes through the printing mechanism, so if you want to modify some options there, that's probably the way to go. Cheers, -- Uli Kusterer "The Witnesses of TeachText are everywhere..." http://www.zathras.de ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Draw image within a NSBezierPath with no border
Hi Kyle, thank you for your suggestions, but the clearColor doesn't cast shadow. I tried the transparency layers too, but when I export the view to a PDF using dataWithPDFInsideRect, I get no compression (specified in the quartzFilter). Instead, If I do not use the transparency layers, I properly get the compression. pdfData = [printView dataWithPDFInsideRect:printRect]; pdfDoc = [[PDFDocument alloc] initWithData:pdfData]; [pdfDoc writeToFile:outFilePath withOptions:optionsDictWithQuartzFilter]; By ³get the shadow out of the fillPath² I mean that I have a view 100 x 100 pixels, I draw an image 50 x 50 in the center of the view, so the shadow should be well visible. But since I clip the image rect, the shadow doesn't appear. Regards -- Leonardo > Da: Kyle Sluder > Data: Thu, 6 Mar 2014 09:54:04 -0800 > A: Leonardo > Cc: Kevin Meaney , "cocoa-dev@lists.apple.com" > > Oggetto: Re: Draw image within a NSBezierPath with no border > > >> On Mar 6, 2014, at 9:25 AM, Leonardo wrote: >> >> That's make sense. Do you know any workaround? >> I have to draw the background color because: >>1) the user could choose to see a background color on the area not >> covered by the image. Let's imagine a circle divided in 3 slices by two >> vertical lines. In the middle we have the image, and on the left and right >> areas we see the color. So, at the top and bottom of the image I see that >> bad blue curved border. > > Create a CGLayer from your destination context that is the size of your image. > Fill it with your background color. Draw your image into it. Set the clipping > path on the destination context. Draw the CGLayer into the destination > context. > >>2) In case of shadow, if I do not fill with a color before clipping the >> path I can't get the shadow out of the path. If I do >> >> CGContextSetShadowWithColor... >> [fillPath addClip]; >> [image drawInRect:fillBounds fromRect:NSZeroRect >> operation:NSCompositeSourceOver fraction:1.0]; >> >> I can't get the shadow out of the fillPath. > > I don¹t know what you mean by ³get the shadow out of the fillPath². > > Do you mean that you don¹t want the shadow to appear below transparent parts > the your image? > >> Instead If I do: >> >> CGContextSetShadowWithColor... >>[aBlueColor set]; >>[fillPath fill]; >> RemoveShadow >>[fillPath addClip]; >>[image drawInRect:fillBounds fromRect:NSZeroRect >>operation:NSCompositeSourceOver fraction:1.0]; >> >> The problem is that I must clip the path before drawing the image, and as >> result the image itself can't project shadow outside the clipped path. >> I am puzzled. > > If you use my above technique, you should be able to create the shadow and > then draw the layer on top of it: > > - drawRect: { > // Draw the shadow > CGContextSaveGState(); > NSBezierPath *oval = ; > [[NSColor clearColor] setFill]; > CGContextSetShadowWithColor(); > [oval fill]; > CGContextRestoreGState(); > > // Draw the clipped image > CGLayerRef layer = MakeLayerFromImage(); > CGContextSaveGState(); > [oval addClip]; > CGLayerDrawAtPoint(layer, ); > CGContextRestoreGState(); > } > > This might not work. I¹m unsure of the behavior of Quartz shadows when drawing > with +clearColor. If it doesn¹t work, you might want to look into Quartz > transparency layers (which are not the same thing as CGLayerRefs). > > --Kyle Sluder ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: WebView pdf representation - div background colours AWOL
On 11 Mar 2014, at 18:09, Uli Kusterer wrote: > On 11 Mar 2014, at 17:12, jonat...@mugginsoft.com wrote: >> There is WebView -drawsBackground but this has no disernable effect. > > That property is for the case where you want a transparent webview on screen. > >> Thinking again about this. >> Perhaps I need to use an NSPrintOperation instead. > > Yeah, that's what I would have suggested. ISTR that PDF generation generally > goes through the printing mechanism, so if you want to modify some options > there, that's probably the way to go. The WebPreferences API has the required property: WebPreferences *webPref = [[WebPreferences alloc] initWithIdentifier:@“Foo"]; [webPref setShouldPrintBackgrounds:YES]; [self.webView setPreferences:webPref]; It appears that using an NSPrintOperation is only a necessity for PDF generation if the output scaling and pagination has to be modified. Jonathan ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com