HTMLまたはWebページを変換する機能を追加する intoアプリケーションへのWord文書がこれまでになく簡単になりました GrabzItのASP.NET API。 ただし、開始する前に、 URLToDOCX, HTMLToDOCX or FileToDOCX メソッド Save or SaveTo DOCXを実際に作成するには、メソッドを呼び出す必要があります。
DOCXとしてWebページをキャプチャすると、Webページ全体が変換されます intoa多くのページで構成できるWord文書。 Webページを変換するために必要なパラメーターは1つだけです intワード文書または HTMLをDOCXに変換する 以下の例に示すように。
grabzIt.URLToDOCX("https://www.tesla.com"); //Then call the Save or SaveTo method
grabzIt.HTMLToDOCX("<html><body><h1>Hello World!</h1></body></html>"); //Then call the Save or SaveTo method
grabzIt.FileToDOCX("example.html"); //Then call the Save or SaveTo method
にカスタム識別子を渡すことができます DOCX 次に示すメソッドを使用すると、この値はGrabzIt ASP.NETハンドラーに返されます。 たとえば、このカスタム識別子はデータベース識別子であり、DOCXドキュメントを特定のデータベースレコードに関連付けることができます。
GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret"); DOCXOptions options = new DOCXOptions(); options.CustomId = "123456"; grabzIt.URLToDOCX("https://www.tesla.com", options); //Then call the Save method grabzIt.Save("http://www.example.com/Home/Handler");
GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret"); DOCXOptions options = new DOCXOptions(); options.CustomId = "123456"; grabzIt.HTMLToDOCX("<html><body><h1>Hello World!</h1></body></html>", options); //Then call the Save method grabzIt.Save("http://www.example.com/Home/Handler");
GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret"); DOCXOptions options = new DOCXOptions(); options.CustomId = "123456"; grabzIt.FileToDOCX("example.html", options); //Then call the Save method grabzIt.Save("http://www.example.com/Home/Handler");
Word文書にヘッダーまたはフッターを追加するには、特定の適用を要求できます。 template 生成されるDOCXに。 このテンプレートは savedを事前に指定し、ヘッダーとフッターの内容を特別な変数とともに指定します。 以下のコード例では、ユーザーは「my template」という名前で作成したテンプレートを使用しています。
GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret"); DOCXOptions options = new DOCXOptions(); options.TemplateId = "my template"; grabzIt.URLToDOCX("https://www.tesla.com", options); //Then call the Save or SaveTo method grabzIt.SaveTo("result.docx");
GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret"); DOCXOptions options = new DOCXOptions(); options.TemplateId = "my template"; grabzIt.HTMLToDOCX("<html><body><h1>Hello World!</h1></body></html>", options); //Then call the Save or SaveTo method grabzIt.SaveTo("result.docx");
GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret"); DOCXOptions options = new DOCXOptions(); options.TemplateId = "my template"; grabzIt.FileToDOCX("example.html", options); //Then call the Save or SaveTo method grabzIt.SaveTo("result.docx");
divやspanなどのHTML要素を直接変換する場合 intGrabzItのASP.NETライブラリを使用して作成できるWordドキュメント。 あなたは合格しなければなりません CSSセレクター に変換するHTML要素の TargetElement
の財産 DOCXOptions とに提供されます。
... <span id="Article"> <p>This is the content I am interested in.</p> <img src="myimage.jpg"> </span> ...
この例では、次のIDを持つスパン内のすべてのコンテンツをキャプチャします。 Article
、したがって、以下に示すようにこれをGrabzIt APIに渡します。
GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret"); DOCXOptions options = new DOCXOptions(); options.TargetElement = "#Article"; grabzIt.URLToDOCX("http://www.bbc.co.uk/news", options); //Then call the Save or SaveTo method grabzIt.SaveTo("result.docx");