כלים ללכידה ולהמרה של האינטרנט

המרת כתובות URL ו- HTML ל- DOCX

ממשק API של ASP.NET

הוספת היכולת להמיר HTML או דפי אינטרנט into מסמכי Word ליישום שלך מעולם לא היו קלים יותר ממשק ה- API של ASP.NET של GrabzIt. עם זאת לפני שתתחיל לזכור את זה לאחר התקשרות אל URLToDOCX, HTMLToDOCX or FileToDOCX שיטות Save or SaveTo יש לקרוא לשיטה ליצירת DOCX בפועל.

אפשרויות בסיסיות

לכידת דפי אינטרנט כאשר DOCX ממיר את כל דף האינטרנט intoa מסמך Word שיכול להכיל עמודים רבים. כדי להמיר דף אינטרנט נדרש פרמטר אחד בלבד intמסמך Word או ל- המרת 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 אתה יכול לבקש שתרצה להחיל מסוים תבנית ל- DOCX שנוצר. תבנית זו חייבת להיות saved מראש ופרט את תוכן הכותרת העליונה התחתונה יחד עם כל משתנים מיוחדים. בקוד הדוגמה למטה המשתמש משתמש בתבנית שהם יצרו בשם "התבנית שלי".

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");

המר אלמנט HTML ל- DOCX

אם ברצונך להמיר אלמנט HTML כגון div או span ישירות intoa מסמך Word שאתה יכול עם ספריית ASP.NET של GrabzIt. עליך לעבור את בורר CSS של אלמנט ה- HTML שברצונך להמיר ל- TargetElement רכוש של DOCXOptions מעמד.

...
<span id="Article">
<p>This is the content I am interested in.</p>
<img src="myimage.jpg">
</span>
...

בדוגמה זו ברצוננו ללכוד את כל התוכן בטווח שיש לו מזהה Articleלכן אנו מעבירים זאת ל- API של GrabzIt כמוצג להלן.

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");