惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

K
Kaspersky official blog
罗磊的独立博客
F
Fortinet All Blogs
人人都是产品经理
人人都是产品经理
量子位
V
Visual Studio Blog
Blog — PlanetScale
Blog — PlanetScale
M
MIT News - Artificial intelligence
B
Blog RSS Feed
腾讯CDC
博客园_首页
aimingoo的专栏
aimingoo的专栏
博客园 - 三生石上(FineUI控件)
博客园 - Franky
S
SegmentFault 最新的问题
N
Netflix TechBlog - Medium
小众软件
小众软件
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
L
LINUX DO - 热门话题
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Martin Fowler
Martin Fowler
D
Docker
P
Privacy & Cybersecurity Law Blog
S
Securelist
V
V2EX
Jina AI
Jina AI
阮一峰的网络日志
阮一峰的网络日志
T
Tor Project blog
The Hacker News
The Hacker News
Microsoft Azure Blog
Microsoft Azure Blog
AWS News Blog
AWS News Blog
The GitHub Blog
The GitHub Blog
有赞技术团队
有赞技术团队
T
The Exploit Database - CXSecurity.com
Help Net Security
Help Net Security
酷 壳 – CoolShell
酷 壳 – CoolShell
Application and Cybersecurity Blog
Application and Cybersecurity Blog
博客园 - 叶小钗
Recent Announcements
Recent Announcements
Cloudbric
Cloudbric
Y
Y Combinator Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Latest news
Latest news
MongoDB | Blog
MongoDB | Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Recorded Future
Recorded Future
V2EX - 技术
V2EX - 技术

博客园 - Ekin.S.Sun

document.execCommand Web文件ContentType类型大全 ArcGIS符号库制作过程说明 JavaScript中的一些重要却容易被忽视的东西 AJAX and the ASP.NET 2.0 Callback Framework My heart hurt:( Working with the ArcGIS Server ArcObjects API : ArcObjects API Js网页打印处理 c#和js的交互(转) MapInfo格式到ArcGIS格式的转换方法 .net学习站点推荐 AJAX .Net组件用户指南(译文&原文) New characteristic of Visual Studio 2005 ASP.NET中常用发送邮件功能代码总结 C#常用正则表达式 ASP.NET系统用户权限设计与实现 how to use Form Authentication in ASP.NET. web.config文件详解 [转] 软件测试的一些认识
ArcGIS Server 9.2建立的web Application实现打印的一篇文章。
Ekin.S.Sun · 2007-09-04 · via 博客园 - Ekin.S.Sun

Description:
This sample demonstrates printing from a Web ADF application. The sample is a custom task that prints the contents of a Map control by merging its resources into a single image. It also enables the user to choose results from a TaskResults control to print below the map. A user-customizable title is displayed at the head of the page. The page is opened as a new browser window from the current window.
The sample task may be used as-is or may be customized. See directions below for both options.
In addition to demonstrating how a task works and the use of Web ADF features such as the use of CallbackResults to handle client callbacks, the code for the task illustrates:

  • Export of map resources in the Map to bitmaps, and the use of GDI+ in ASP.NET to merge the bitmaps into a single image for printing.
  • Printing at specific scale, size and resolution in the browser.
  • Dynamic detection of changes in the TaskResults in order to update the list of available tasks for printing.
  • Output from a task result node to a GridView for table-formatted view.
  • Streaming of the print image to the client from server memory.

Using the Print Task

To use this sample as-is, without compiling it or opening it in Visual Studio, use the steps below. For more details, see the Readme.doc file included with the downloaded zip file.

  1. Verify that the Web ADF for the .NET Framework is installed and functioning properly. For information on installing and configuring the Web ADF, consult the installation guide.
  2. Extract either the Common_PrintTask_CSharp.zip or Common_PrintTask_VBNet.zip file to a location of your choice. An example would be to C:\ArcGIS\CustomTasks. You should have a Common_PrintTask_CSharp or Common_PrintTask_VBNet folder after extracting the files.
  3. Register the PrintTask_<language>.dll in the Global Assembly Cache (GAC). The <language> variable may be either CSharp or VBNet. Open two Windows Explorer windows, one to the bin\Release subfolder of the sample (e.g., C:\ArcGIS\CustomTasks\Common_PrintTask_CSharp\PrintTask_CSharp\bin\Release), and the other to the C:\Windows\Assembly folder. Drag the PrintTask_<language>.dll file into the C:\Windows\Assembly folder. Verify that PrintTask_<language> is now in the list.
  4. If desired, add the task to the Visual Studio toolbox. Open Visual Studio 2005 to any Web page, right-click on the location in the toolbox where you want the task, and use Choose Items to browse to the PrintTask_<language>.dll. Click Open, then OK. The tool should now appear every time you open a Web page in Visual Studio. Now the task may be added to any Web ADF application by dragging the task onto the page (into a TaskManager if available).
  5. If desired, add the task into Manager. Open the C:\Inetpub\wwwroot\ArcGIS\Manager\Applications\App_Data\Tasks.xml file in Visual Studio, Notepad or other XML or text editor. Just before the closing </Tasks> tag, insert the following (all on one line):

    For the CSharp version:

    <Task Name="PrintTask_CSharp"
        DisplayName="Print Task CSharp"
        Type="PrintTask_CSharp.PrintTask_CSharp, PrintTask_CSharp, Version=1.1.0.0, Culture=neutral, PublicKeyToken=2a7e7966c16048d7"
        TagPrefix="printTaskCS" />

    For the VBNet version:

    <Task Name="PrintTask_VBNet"
        DisplayName="Print Task VBNet"
        Type="PrintTask_VBNet.PrintTask_VBNet, PrintTask_VBNet,Version=1.1.0.0, Culture=neutral, PublicKeyToken=2a7e7966c16048d7"
        TagPrefix="printTaskVB" />

    Then restart IIS using Control Panel-Administrative Tools-Services. Now the task should appear in the available tasks list when creating or editing a Web applications. You can add the task to the application. Remember to click Configure so that the task will actually be added into the application.

Products:
Server: C#, VB.NET
Platforms: Windows Minimum ArcGIS Release: 9.2

How to use:

  1. Design Time:
    1. Verify that the Web ADF for the .NET Framework is installed and functioning properly. For information on installing and configuring the Web ADF, consult the installation guide.
    2. In Windows Explorer, navigate to <ArcGIS install location>\DeveloperKit\SamplesNet\Server\Web_Applications and unzip Common_PrintTaskCSharp.zip or Common_PrintTaskVBNet.zip (if available) to a location of your choice. You should see either a CSharp or VBNet folder appear where you unzipped the files.
    3. In Windows Explorer, open the directory referencing the language of your choice: CSharp or VBNet. Copy the folder, Common_PrintTask_<language>, to c:\inetpub\wwwroot. The <language> variable may be either CSharp or VBNet.
    4. Open the IIS Manager from Control Panel > Administrative Tools > Internet Information Services (IIS) Manager or Internet Information Services
    5. In the console tree view on the left, navigate to Local Computer > Web Sites > Default Web Site.
    6. Open the Common_PrintTask_<language> folder, right-click the PrintTaskWebApp_<language> folder and click Properties.
    7. On the Directory tab, click the Create button in the Application Settings section of this panel. Click OK to dismiss the Properties dialog.
    8. Launch Microsoft Visual Studio 2005 and open the Common_PrintTask_<language> solution (for example, Common_PrintTask_CSharp.sln) located in c:\inetpub\wwwroot\Common_PrintTask_<language>.
    9. In the Solution Explorer, right-click the PrintTaskWebApp_<language> project and select 'Set as StartUp Project'. Also, right-click Default.aspx and select 'Set As Start Page'.
    10. Save the solution.
    11. Click the "Debug" drop-down menu and choose "Start". The custom task class library should build successfully and be added to the GAC using build events in the task project. The Default.aspx should start and display a menu item to initialize the custom task and the dialog for the custom task control.
    12. To add the custom task to the Visual Studio toolbox:
      1. Right-click on the toolbar and select Add Tab.  Enter a name for the new tab, for example "Custom Task Controls".
      2. Right-click on the new tab and select "Choose Items...".
      3. On the Choose Items dialog, click the Browse button and navigate to the location of the PrintTask_<language>.dll and click the Open button.  Two new controls will be added to and selected in the Choose Items dialog.  Select and check the box next to the "PrintTask_<language>" item.  Click OK to exit the dialog.
      4. The new tab should contain the custom task control.
    13. You may choose to distribute this custom task for use in the Manager application. To add this custom task, do the following:
      1. Confirm that the assembly is signed. By default, the task project includes a key it uses to sign the class library. In Visual Studio, right-click on the class library project and select Properties in the context menu. Click the Signing tab and confirm the "Sign the assembly" check box is checked. Optionally, you can change this by generating your own key using the sn.exe utility included with the .NET SDK. To do this, open a Visual Studio 2005 Command Prompt and enter:
        sn -k MyKeyPair.snk
                    
      2. Confirm that the assembly has been added to the GAC. By default, the task project uses build events to register the assembly in the GAC. Optionally, you can use the gacutil.exe utility included with the .NET SDK to add the assembly to the GAC. To do this, open a Visual Studio 2005 Command Prompt and enter (using the CSharp version as an example):
        gacutil -i PrintTask_CSharp.dll
                    
      3. Add the custom task details to the Manager Tasks.xml file. In the App_Data folder for the Manager Web application (e.g. C:\Inetpub\wwwroot\ArcGIS\Manager\Applications\App_Data) open the Tasks.xml file in a text editor. Add the following line within the <Tasks> tags (using the CSharp version as an example):
        <Task Name="PrintTask_CSharp"
                    DisplayName="Print Task CSharp"
                    Type="PrintTask_CSharp.PrintTask_CSharp, PrintTask_CSharp, Version=1.1.0.0, Culture=neutral, PublicKeyToken=2a7e7966c16048d7"
                    TagPrefix="customTask" />
                    
        Confirm the content of this entry, namely the version, and public key token. In a Visual Studio 2005 Command Prompt and enter (using the CSharp version as an example):
        gacutil -l PrintTask_CSharp
                    
      4. Restart IIS. Manager should recognize the new task and make it available in the Tasks dialog during new Web application creation. In a Visual Studio 2005 Command Prompt and enter:
        iisreset
                    
  2. Run Time:
    1. Run in debug mode to open the Web application as above.
    2. Zoom or pan the map to an area to be printed (use the Ctrl/Shift keys with the mouse to zoom in/out).
    3. If you added a query task at design time, use it to find a set of features.
    4. Open the Print task if necessary from the task menu. In the task dialog, set the print options such as size and task results to print, if any are available.
    5. Click Print to display the print page. Note that any popup blockers may need to be disabled or set to allow popups for this site. Print the page to your local printer if desired.

Download the C# files

Common_PrintTask_CSharp.sln The solution file. References two projects: a class library and web site.
PrintTask_CSharp.csproj Class library project file for print task control.
Default.aspx User interface for the Web application.
Common_PrintTask_CSharp/PrintTaskWebApp_CSharp/Default.aspx.cs The code behind the user interface.
Common_PrintTask_CSharp/PrintTask_CSharp/PrintTask_CSharp.cs Custom task implementation code.
Common_PrintTask_CSharp/PrintTask_CSharp/PagePrinter.cs Creates the output for the print page.
Common_PrintTask_CSharp/PrintTask_CSharp/MapPrinter.cs Called by PagePrinter to create the output for the map.
Common_PrintTask_CSharp/PrintTask_CSharp/ScaleBarPrinter.cs Creates the output version of the scalebar.
Common_PrintTask_CSharp/PrintTask_CSharp/Utilities.cs Utility methods for the custom task.
Common_PrintTask_CSharp/PrintTask_CSharp/PrintTaskWebConfigurator_CSharp.cs Class for configuring the custom task in Manager.
Common_PrintTask_CSharp/PrintTask_CSharp/Properties/AssemblyInfo.cs Assembly specific information used when compiling the assembly. Note the custom tagprefix.
Common_PrintTask_CSharp/PrintTask_CSharp/Designer/MapControlsEditor.cs Design-time control used to display a list of Map controls to buddy to the Print Task.

Download the files for all languages