Microsoft MVP성태의 닷넷 이야기
글쓴 사람
정성태 (techsharer at outlook.com)
홈페이지
첨부 파일
 

웹에 공개되어 있는 Sept '05 WinFX CTP 예제가 아래와 같습니다.

// Save XPS Document page(s) to .bmp
// Current as of Sept '05 WinFX CTP

using System.IO;
using System.Windows.Documents;
using System.Windows.Xps.Packaging;
using System.Windows.Media.Imaging;


namespace GenerateXpsBitmaps
{
    static public class XpsBitmapHelper
    {
        static public void SaveXpsPageToBitmap(string xpsFileName, int[] pages)
        {
            XpsDocument xpsDoc = new XpsDocument(xpsFileName, System.IO.FileAccess.Read);
            FixedDocumentSequence docSeq = xpsDoc.GetPackageRoot();

            // You can get the total page count from docSeq.PageCount

            foreach (int pageNum in pages)
            {
                DocumentPage docPage = docSeq.GetPage(pageNum);
                BitmapImage bitmap = new BitmapImage();
                RenderTargetBitmap renderTarget =
                    new RenderTargetBitmap( (int) docPage.Size.Width,
                                            (int) docPage.Size.Height,
                                            96, // WPF (Avalon) units are 96dpi based
                                            96, 
                                            System.Windows.Media.PixelFormats.Bgra32);

                renderTarget.Render(docPage.Visual);

                BitmapEncoder encoder = new BmpBitmapEncoder();  // Choose type here ie: JpegBitmapEncoder, etc
                encoder.Frames.Add(BitmapFrame.Create(renderTarget));

                FileStream pageOutStream = new FileStream(xpsDoc + ".Page" + pageNum + ".bmp", FileMode.Create, FileAccess.Write);
                encoder.Save(pageOutStream);
                pageOutStream.Close();
            }
        }
    }
}

물론,,, ^^; Feb '06 WinFX CTP에서는 위의 코드가 정상적으로 동작하지 않습니다. 아래의 코드와 같이 변경이 되었기 때문입니다. 또한, 정식 릴리즈되는 WinFX 버전에서는 아래의 코드도 동작하지 않을 것입니다. 참고하십시오. ^^
using System.IO;
using System.Windows.Documents;
using System.Windows.Xps.Packaging;
using System.Windows.Media.Imaging;
using System.Windows.Xps.Serialization;

namespace WindowsApplication1
{
    public class XpsBitmapHelper
    {
        static public void SaveXpsPageToBitmap(string xpsFileName, int[] pages)
        {
            XpsDocument xpsDoc = new XpsDocument(xpsFileName, System.IO.FileAccess.Read);

            FixedDocumentSequence fixedDocumentSeq = xpsDoc.GetFixedDocumentSequence();

            for ( int i = 0; i < fixedDocumentSeq.DocumentPaginator.PageCount; i ++ )
            {
                DocumentPage aPage = fixedDocumentSeq.DocumentPaginator.GetPage( i );

                BitmapImage bitmap = new BitmapImage();

                RenderTargetBitmap renderTarget =
                    new RenderTargetBitmap((int)aPage.Size.Width,
                                            (int)aPage.Size.Height,
                                            96, // WPF (Avalon) units are 96dpi based
                                            96,
                                            System.Windows.Media.PixelFormats.Default);

                renderTarget.Render(aPage.Visual);

                BitmapEncoder encoder = new BmpBitmapEncoder();  // Choose type here ie: JpegBitmapEncoder, etc
                encoder.Frames.Add(BitmapFrame.Create(renderTarget));

                FileStream pageOutStream = new FileStream(xpsDoc + ".Page" + i.ToString() + ".bmp", FileMode.Create, FileAccess.Write);
                encoder.Save(pageOutStream);
                pageOutStream.Close();
            }
        }
    }
}









[최초 등록일: ]
[최종 수정일: 10/18/2006]

Creative Commons License
이 저작물은 크리에이티브 커먼즈 코리아 저작자표시-비영리-변경금지 2.0 대한민국 라이센스에 따라 이용하실 수 있습니다.
by SeongTae Jeong, mailto:techsharer at outlook.com

비밀번호

댓글 작성자
 




... 151  152  153  154  155  156  157  158  159  [160]  161  162  163  164  165  ...
NoWriterDateCnt.TitleFile(s)
1043정성태5/24/201131222.NET Framework: 214. 무료 Linq Provider - DbLinq를 이용한 Firebird 접근파일 다운로드1
1042정성태5/23/201137556개발 환경 구성: 122. PHP 소스를 윈도우 환경에서 빌드하기
1041정성태5/22/201128449.NET Framework: 213. Linq To SQL - ALinq Provider를 이용하여 Firebird 사용파일 다운로드1
1040정성태5/21/201138800개발 환경 구성: 121. .NET 개발자가 처음 설치해 본 Apache + PHP [2]
1039정성태5/17/201131529.NET Framework: 212. Firebird 데이터베이스와 ADO.NET [2]파일 다운로드1
1038정성태5/16/201133464개발 환경 구성: 120. .NET 프로그래머에게도 유용한 Firebird 무료 데이터베이스 [2]
1037정성태5/11/201128311개발 환경 구성: 119. Visual Studio Professional 이하 버전에서도 TFS의 정적 코드 분석 정책 연동이 가능할까? [3]
1036정성태5/7/201194180오류 유형: 121. Access DB에 대한 32bit/64bit OLE DB Provider 관련 오류 [11]
1035정성태5/7/201128845오류 유형: 120. File cannot be opened. Ensure it is a valid Data Link file.
1034정성태5/2/201125898.NET Framework: 211. 파일 잠금 없이 .NET 어셈블리의 버전을 구하는 방법 [2]파일 다운로드1
1033정성태5/1/201131611웹: 19. IIS Express - appcmd.exe를 이용한 applicationHost.config 변경 [2]
1032정성태5/1/201128241웹: 18. IIS Express를 NT 서비스로 변경
1031정성태4/30/201129385웹: 17. IIS Express - "IIS Installed Versions Manager Interface"의 IIISExpressProcessUtility 구하는 방법 [1]파일 다운로드1
1030정성태4/30/201151680개발 환경 구성: 118. IIS Express - localhost 이외의 호스트 이름으로 접근하는 방법 [4]파일 다운로드1
1029정성태4/28/201140820개발 환경 구성: 117. XCopy에서 파일/디렉터리 확인 질문 없애기 [2]
1028정성태4/27/201138207오류 유형: 119. Visual Studio 2010 SP1 설치 후 Windows Phone 개발자 도구로 인한 재설치 문제 [3]
1027정성태4/25/201127387디버깅 기술: 40. 상황별 GetFunctionPointer 반환값 정리 - x86파일 다운로드1
1026정성태4/25/201145634디버깅 기술: 39. DebugDiag 1.1을 사용한 덤프 분석 [7]
1025정성태4/24/201127692개발 환경 구성: 116. IIS 7 관리자 - Active Directory Certification Authority로부터 SSL 사이트 인증서 받는 방법 [2]
1024정성태4/22/201129116오류 유형: 118. Windows 2008 서버에서 Event Viewer / PowerShell 실행 시 비정상 종료되는 문제 [1]
1023정성태4/20/201129980.NET Framework: 210. Windbg 환경에서 확인해 본 .NET 메서드 JIT 컴파일 전과 후 [1]
1022정성태4/19/201125551디버깅 기술: 38. .NET Disassembly 창에서의 F11(Step-into) 키 동작파일 다운로드1
1021정성태4/18/201127805디버깅 기술: 37. .NET 4.0 응용 프로그램의 Main 함수에 BreakPoint 걸기
1020정성태4/18/201128413오류 유형: 117. Failed to find runtime DLL (mscorwks.dll), 0x80004005
1019정성태4/17/201129028디버깅 기술: 36. Visual Studio의 .NET Disassembly 창의 call 호출에 사용되는 주소의 의미는? [1]파일 다운로드1
1018정성태4/16/201132690오류 유형: 116. 윈도우 업데이트 오류 - 0x8020000E
... 151  152  153  154  155  156  157  158  159  [160]  161  162  163  164  165  ...