• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
How can I access full source of a WebView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How can I access full source of a WebView


  • Subject: How can I access full source of a WebView
  • From: Ömer Kardaş <email@hidden>
  • Date: Wed, 08 Oct 2008 01:45:22 +0300

Hi

I am trying to send the contents of a webwiew with email. I have found several ways to do that, but there are minor problems.

// get the attributes string of the webview
id res = (id <WebDocumentText> )[[[myWebView mainFrame] frameView] documentView];
NSAttributedString *p = [res attributedString];
NSPasteboard *pb = [NSPasteboard pasteboardWithName:@"PBtoMail"];


// init a private pastebord for data transfer, this time use webarchive for transfer
[pb declareTypes:[NSArray arrayWithObject:NSRTFDPboardType] owner:self];


// convert the attributed string to rtfd and place it on the private pasteboard
NSRange range;
range.location = 0;
range.length = [p length];
[pb setData:(NSData *)[p RTFDFromRange:range documentAttributes:nil forType:NSRTFDPboardType];

// open mail window using the rtfd data using services...
NSPerformService(@"Mail/Send Selection", pb);

This works, but quality is no so good. So I tried a different approach


// init a private pastebord for data transfer, this time use webarchive for transfer
NSPasteboard *pb = [NSPasteboard pasteboardWithName:@"PBtoMail"];
[pb declareTypes:[NSArray arrayWithObject:WebArchivePboardType] owner:self];


// get the webarchive and place it on pboard
[pb setData:[[[myWebView mainFrameDocument] webArchive] data] forType:WebArchivePboardType];


	NSPerformService(@"Mail/Send Selection", pb);

This works better. However external CSS code is not copied, which makes the page look different. When I select all and copy from the webview manualy and then paste it on a new mail window it works fine, the external CSS is copied as well. Is there any way I get the full source (including the external CSS) so that I can place it on the pasteboard?

Thanks in advance.

_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:
This email sent to email@hidden


  • Follow-Ups:
    • Re: How can I access full source of a WebView
      • From: Rob Keniger <email@hidden>
  • Prev by Date: Re: Getting the values from the selected row of a table?
  • Next by Date: Re: How can I access full source of a WebView
  • Previous by thread: Re: Trouble with NSSplitView
  • Next by thread: Re: How can I access full source of a WebView
  • Index(es):
    • Date
    • Thread