title: Resize page with ABCPdf before rendering (huge images in the pdf)
body: <p>I have a problem with ABCPdf, when I try to convert a pdf files into seperate image files as fallbacks for old browsers.</p>
  
  <p>I have some working code that perfectly renders the page and resizes the rendering into the wanted size. Now my problem occurs when the pdf page is huge <code>w7681px x h10978px</code>. It nearly kills my development machine and the deployment machine cannot even chew the file.</p>
  
  <p>I normally just render the page 1-to-1 as the pdf page and then uses other algorithms to resize this image. This is not efficient since ABCPdf takes alot of power to output this image.</p>
  
  <p>I have the following code:</p>
  
  <pre><code>    private byte[] GeneratePng(Doc pdfDoc, int dpi)
      {
          var useDpi = dpi;
          pdfDoc.Rendering.DotsPerInch = useDpi;
          pdfDoc.Rendering.SaveQuality = 100;
          pdfDoc.Rect.String = pdfDoc.CropBox.String;
          pdfDoc.Rendering.ResizeImages = true;
  
          int attemptCount = 0;
  
          for (;;)
          {
              try
              {
                  return pdfDoc.Rendering.GetData("defineFileTypeDummyString.png");
              }
              catch
              {
                  if (++attemptCount == 3) throw;
              }
          }
      }
  </code></pre>
  
  <p>I have tried the following solutions:</p>
  
  <p><strong>Resizing the page</strong></p>
  
  <pre><code>pdfDoc.SetInfo(pdfDoc.Page, "/MediaBox:Rect", "0 0 200 300");
  </code></pre>
  
  <p>Resizing the page and outputting it. Which doesn't seem to make any changes at all.</p>
  
  <p><strong>Resizing the images before rendering it:</strong></p>
  
  <pre><code>foreach (IndirectObject io in pdfDoc.ObjectSoup) {
    if (io is PixMap) {
      PixMap pm = (PixMap)io;
      pm.Realize(); // eliminate indexed color images
      pm.Resize(pm.Width / 4, pm.Height / 4);
    }
  }
  </code></pre>
  
  <p>Didn't do anything either and still resulted in a long load time.</p>
  
  <p><strong>Running the reduzed size operation before rendering:</strong></p>
  
  <pre><code>  using (ReduceSizeOperation op = new ReduceSizeOperation(pdfDoc))
      op.Compact(true);
  </code></pre>
  
  <p>Didn't do anything either. Just went directly to rendering and took a long time.</p>
  
  <p>Can anyone help me here? Maybe point me to some ABCPdf resizing algorithm or something.</p>