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

안녕하세요?

Vista Beta2 에서 잘 동작하던 코드가 RC1 에서 동작하지 않네요?
어떤 이유인지 모르겠습니다.

정성태님이 알려주신 소스를 다소 수정하여서 사용하고 있는데,
해당 소스의 내용은,
XPS Document를 읽어와서 Bitmap 이미지로 변환하는 소스입니다.

알려주신 소스는 하기 URL 의 게시판에 있구요,
게시판에 쓰여진 소스를 아래에 한번 더 붙여넣기 하였습니다.

https://www.sysnet.pe.kr/Default.aspx?mode=2&sub=0&pageno=0&detail=1&wid=229

동작되지 않는 부분은

DocumentPage aPage = fixedDocumentSeq.DocumentPaginator.GetPage( i );
부분으로,

XPS Document 의 각 페이지를 가져와서 DocumentPage Type 에 할당해 준 다음,
Bitmap 이미지로 생성해 주어야 하는데...

fixedDocumentSeq.DocumentPaginator.GetPage(Zero Based 페이지 번호);
부분에서 동작하지 않고 죽어 버립니다.

혹시 원인을 알고 계신지 여쭙겠습니다. 감사합니다.


=====<알려주신 소스 원본>=======================================================

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();
            }
        }
    }
}










[최초 등록일: ]
[최종 수정일: 9/20/2006]


비밀번호

댓글 작성자
 



2006-09-25 08시57분
죄송합니다. 답변이 무지 늦어지고 있습니다.
아직 검토도 안해 봤고요. ^^; 가능하면... 이번 주중으로 한번 보고 답변을 다시 드리도록 하겠습니다.

kevin25
2006-09-28 10시58분
이상하군요. 저도 예전 소스로 해봤지만... 문제가 없습니다.
한가지 틀린 것이라면, 저는 테스트를 Vista RC1 Build 5728 버전에서 수행했습니다. 암튼, 위의 소스는 잘 구동이 되었습니다.
kevin25

... 16  17  [18]  19  20  21  22  23  24  25  26  27  28  29  30  ...
NoWriterDateCnt.TitleFile(s)
5522질문6/28/202115952WPF에서 splash screen이 나타나는 위치를 변경할 수 있나요? [3]
5521김민혁6/24/202118463.exe 파일 에러에 관한 질문 입니다. [3]
5520한예지 donator6/21/202117651랜덤함수 질문있습니다!! [2]
5519리얼킴6/19/202115384.net framwork 4.0 에서 4.8로 꼭 가야할까요?? [1]
5518한예지 donator6/18/202115720ArrayList, IList에 대해 질문 있습니다. [3]
5517wunsy6/18/202115477winform에서 Button 활성화, 비활성화 [4]
5516ocm6/15/202114328mips 어셈블리 연산 다시 질문드려요 (첨부파일 갱신됨) [2]파일 다운로드1
5515ocm6/14/202116791mips 어셈블리 연산 [6]파일 다운로드1
5514jongs6/11/202117671GethashCode와 String대한 질문 [2]
5513labe...6/11/202116913C# Winform 에서 Label에 동일한 Color를 넣었을 때 처리방법이 궁금합니다. [2]
55126/11/202116935xlwings 가 실행조차 되지 않습니다. ㅠㅠ [7]
5511Syong6/9/202114991User Control에 string array 속성 추가하는 방법 [4]
5510jay6/8/202114744string 문자열에 쌍따옴표(")를 넣고 싶습니다. [1]파일 다운로드1
5509한예지 donator6/3/202114469ExeccuteNonQuery 질문있습니다! [2]
5508최재남6/3/202116027마우스 이벤트 관련 질문 좀 드리겠습니다. [6]
5507한예6/2/202114027static과 스택오버플로우 질문있습니다. [5]파일 다운로드1
5506이창석6/1/202116049센서의 값을 받아서 PC를 통해 모니터링 하는 것을 만들고 있습니다. [1]
5505kss5/31/202114483.net5에서 소멸자가 어떻게 바뀐건가요? [1]
5503xing...5/24/202115276xingapinet 에 수정 요청 부탁 드립니다. [1]
5501한예지 donator5/23/202115798IProgress 사용법이 궁금합니다. [2]
5500한예ㅈ5/23/202117849비동기 코드 흐름 질문있습니다. [3]
5498곰장어5/21/202115310List에 static 변수를 추가했을때의 궁금증 [3]파일 다운로드1
5497지평선5/20/202117371윈도우 배율을 알 수 있을까요? [1]
5496cs린이5/20/202114041C# 8.0 질문입니다. [2]파일 다운로드6
5495Natie5/13/202113578객체를 생성과 동시에 초기화 하는 방법 [1]
5494지예예지5/13/202115862비동기 코드 흐름이 궁금합니다! [2]
... 16  17  [18]  19  20  21  22  23  24  25  26  27  28  29  30  ...