2

I am trying to rasterize pdf's using TallComponents PDF Rasterizer

It works fine going to tiff.. Although I wanted to ConvertToWpf..

I asked this question to them directly although no response..

so, I followed their example code..

        TallComponents.PDF.Rasterizer.Document _document;
        using (FileStream file = new FileStream(pSource, FileMode.Open, FileAccess.Read))
        {
            _document = new TallComponents.PDF.Rasterizer.Document(file);
        }

        TallComponents.PDF.Rasterizer.Configuration.RenderSettings rSettings = new TallComponents.PDF.Rasterizer.Configuration.RenderSettings();
        rSettings.TextSettings.ResolveFont += new TallComponents.PDF.Rasterizer.Fonts.ResolveFontEventHandler(TextSettings_ResolveFont);

        TallComponents.PDF.Rasterizer.ConvertToWpfOptions rOptions = new TallComponents.PDF.Rasterizer.ConvertToWpfOptions();
        TallComponents.PDF.Rasterizer.Diagnostics.Summary summary = new TallComponents.PDF.Rasterizer.Diagnostics.Summary();

        int count = _document.Pages.Count;
        for (int i = 0; i < count; i++)
        {

        using (FileStream outStream = new FileStream(path, FileMode.Create)) 
        { 
             System.Windows.Documents.FixedPage fpage = _document.Pages[i].ConvertToWpf(rSettings, rOptions, summary); 

             double width = fpage.Width * rasterize.rast_dpiX / system.scr_dpiX; 
             double height = fpage.Height * rasterize.rast_dpiY / system.scr_dpiY; 

             RenderTargetBitmap renderTarget = new RenderTargetBitmap( 
             (int)width, 
             (int)height, 
             rasterize.rast_dpiX, 
             rasterize.rast_dpiY, 
             System.Windows.Media.PixelFormats.Default); 

             renderTarget.Render(fpage); 

             PngBitmapEncoder enc = new PngBitmapEncoder(); 
             enc.Frames.Add(BitmapFrame.Create(renderTarget)); 
             enc.Save(outStream); 

        } 

It works when I use a pdf that has only 1 page..

When I use a pdf with more then 1 page, I get insufficient memory errors..

When I use a pdf with more then 1 page and start at page 2, and skip the first page it works.. Although all the pages come up blank, saying I can only rasterize the first page because its a trial..

Am I getting the memory error because its a trial product?

1
  • I checked this problem with other PDF files that have multiple pages.. It seems to only be the 1 file which is PDF version 1.5.. Although it worked with version 1.4 and 1.6 Apr 17, 2013 at 12:44

1 Answer 1

1

Most probably you have an image (or another huge PDF object) on a first page, after processing of which you have got an exception. This exception breaks the further rendering and you have a blank 2,3,4... pages.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.