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

... 61  62  63  64  65  [66]  67  68  69  70  71  72  73  74  75  ...
NoWriterDateCnt.TitleFile(s)
950이성환2/9/201119315Windows application 프로젝트를 참조 했을 때 생성되는 실행파일을 직접 실행 불가능하도록 하고 싶습니다. [6]파일 다운로드1
947김순조1/24/201118951.NET based Com에서 Native ActiveX로 이벤트 보내기?? [2]파일 다운로드1
943김기룡1/3/201122047닷넷 에러시 조치사항관련... [2]
942김기룡12/27/201017051Thread 안정성 관련 문의 드립니다. [2]
941최광욱12/20/201016814정성태님 올리신 글중에 [1]
940최광욱12/20/201018539Assembly Unloading 관련해서 [2]
939최광욱12/20/201017182IIS 로그 읽기 [1]
938날쌘돌이12/14/201017977자바로 asp.net 인증하기 [3]
935김기룡12/13/201028329c#에서 c++로 개발된 dll에 byte[] 전달 관련하여 문의 드립니다. [6]
934임동찬12/7/201015777System.Reflection.Assembly.GetTypes() 메서드에 대해 [1]
929김준호12/2/201016024안녕하세요 비주얼베이직 2005 닷넷 관련 문의입니다 [1]
928김준호11/30/201016576안녕하세요 비주얼베이직 2005 닷넷 관련 문의입니다 [1]파일 다운로드1
927임동찬11/30/201017917Windows\\Temp 폴더의 이름모를 .tmp 파일들에 대해서 [1]
926이승규11/26/201037881IP접속 시도시 ORA-12504 에러 [1]
925임동찬11/11/201015462다른 프로그램의 컨트롤 건드려보기_추가질문(2) [1]
924임동찬11/10/201016260다른 프로그램의 컨트롤 건드려보기_추가질문 [1]
923임동찬11/9/201018740다른 프로그램의 컨트롤 건드려보기 [1]
922박태근11/2/201017382html5의 shape파일 관련 [1]파일 다운로드1
921박태근11/1/201018137DataTable 의 Binary변환! [1]
920김재영10/26/201018306GAC에 등록된 어셈블리를 Visual Studio에서 참조 대화상자에 보이게 할려면 어떤 방법이 있습니까? [2]
919임동찬10/22/201016749IStream [1]
918임동찬10/21/201015999System.Runtime.InteropServices.ComTypes.IStream 관련 [1]
917한귀순10/20/201020223IIS 최초 loading 시 속도 [2]
916임동찬10/15/201016401file lock 관련 [2]
915오병태10/11/201015205바쁘신대 답변 감사드립니다. [1]
914오병태10/11/201015402감사드립니다. 염치없지만 또 한번 문의드립니다. [2]
... 61  62  63  64  65  [66]  67  68  69  70  71  72  73  74  75  ...