Page 1 of 1

Scale Large Pages, but not small pages when printing

Posted: Fri May 23, 2014 4:29 pm
by nschafer
Hello,

I am trying to give my users an option that will shrink large pages but leave small pages alone. We have many types of documents that we scan or capture from web pages. The documents are saved as multi-page Tiff files. The user has an option to select several documents to be printed, exported to PDF or e-mailed (also as a PDF). My process is to merge all of the selected documents into a single PDF and then print, save or e-mail.

My problem is that some items (usually captured web pages) are too wide to fit a page when printing. If I use PrintDialogFit this solves this problem, but other documents, scanned ID cards for instance, are much smaller than a page and PrintDialogFit expands them to fit the page. I'd like the large pages to be reduced, but I don't want the smaller documents to be expanded. Is this possible?

Using version 10.112

Thank you,

Neal Schafer

Re: Scale Large Pages, but not small pages when printing

Posted: Sat May 24, 2014 4:14 pm
by Loïc
Hello Neal,

This option is not currently supported but it is already on our road-map. It should be available in a next release soon.

With best regards,

Loïc

Re: Scale Large Pages, but not small pages when printing

Posted: Wed Jul 02, 2014 6:22 pm
by nschafer
I've worked out a way to do this, but it has a problem. My process is simply to check to see if the image is more than 8.5" wide and if so resize it to 8.5" wide then set the horizontal and vertical resolution back to what they originally were. This resized my test image that was originally 26.375" x 47.153" to 8.5" x 15.19". I have two problems though.

First, only the first 11 inches are printed. How can I get it to print the entire image even if it needs a second sheet?
Second, the quality of the printed image is very poor.

Any thought would be appreciated.
Neal.

Here's my code:

Code: Select all

            GdPicture10.GdPictureImaging Imaging1 = new GdPictureImaging();
            Imaging1.SetLicenseNumber("abcdabcd");
            int CurrentDocument = 0;
            CurrentDocument = Imaging1.CreateGdPictureImageFromFile(@"C:\test\longtest.png");
            if (CurrentDocument > 0)
            {
                // Resize with to 8.5" if larger than 8.5"
                double startwidthinches = Imaging1.GetWidthInches(CurrentDocument);
                int startwidth = Imaging1.GetWidth(CurrentDocument);
                float hres = Imaging1.GetHorizontalResolution(CurrentDocument);
                float vres = Imaging1.GetVerticalResolution(CurrentDocument);

                if (startwidthinches > 8.5)
                {
                    double ratio = startwidthinches / 8.5;
                    int newwidth = (int)(startwidth / ratio);
                    Imaging1.ResizeWidthRatio(CurrentDocument, (int)(startwidth / ratio), System.Drawing.Drawing2D.InterpolationMode.Default);
                    Imaging1.SetHorizontalResolution(CurrentDocument, hres);
                    Imaging1.SetVerticalResolution(CurrentDocument, vres);

                }
                Imaging1.PrintDialog(CurrentDocument);
            }
        }

Re: Scale Large Pages, but not small pages when printing

Posted: Thu Jul 03, 2014 6:48 pm
by nschafer
I found another way around my issue. Rather than trying to print the original long image I am now splitting that image into pages before printing. This way I don't have to resize or play with resolution so I'm not losing any quality from my original image.

In case anyone is interested I'll post my code below.

Neal.

Code: Select all

// Split long page so that it will be the correct ratio for 8.5" x 11" printing
// Not actually resizing any pages, just splitting into pages with a length 1.3 x the width (11/8.5)
GdPicture10.GdPictureImaging Imaging1 = new GdPictureImaging();
Imaging1.SetLicenseNumber("xxxxxxxxxxxxxxxxx");
int CurrentDocument = 0;
CurrentDocument = Imaging1.CreateGdPictureImageFromFile(@"C:\test\longtest.jpg");
if (CurrentDocument > 0)
{
     int docheight = Imaging1.GetHeight(CurrentDocument);
     int remainder = docheight;
     int docwidth = Imaging1.GetWidth(CurrentDocument);
     int pageheight = (int)((double)docwidth * 1.3);
     int nleft = 0, ntop = 0, nheight;
     if (docheight < pageheight ) nheight = docheight;
     else nheight = pageheight;
     int page = Imaging1.CreateClonedGdPictureImageArea(CurrentDocument,nleft,ntop,docwidth,nheight);
     int tifid = Imaging1.TiffCreateMultiPageFromGdPictureImage(page);
     Imaging1.ReleaseGdPictureImage(page);
     remainder -= pageheight;
     while (remainder > 0)
     {
          ntop = ntop + pageheight;

          // Last page must be treated differently because it is probably not a full page height
          // if we have a shorter page use printfit() the width won't match the rest of the printed pages.
          // Here we create an image the same size as the other pages and draw the last page onto it.
          if (remainder < pageheight)  
          {
               int lastpage = Imaging1.CreateNewGdPictureImage(docwidth, pageheight, (short)Imaging1.GetBitDepth(tifid), Color.White);
               nheight = remainder;
               page = Imaging1.CreateClonedGdPictureImageArea(CurrentDocument, nleft, ntop, docwidth, nheight);
               Imaging1.DrawGdPictureImage(page, lastpage, 0, 0, docwidth, nheight, System.Drawing.Drawing2D.InterpolationMode.Bicubic);
               Imaging1.ReleaseGdPictureImage(page);
               Imaging1.TiffAppendPageFromGdPictureImage(tifid, lastpage);
               Imaging1.ReleaseGdPictureImage(lastpage);
          }
          else  // Pages between first and last are simply appended to the multi-page tiff
          {
               nheight = pageheight;
               page = Imaging1.CreateClonedGdPictureImageArea(CurrentDocument, nleft, ntop, docwidth, nheight);
               Imaging1.TiffAppendPageFromGdPictureImage(tifid, page);
               Imaging1.ReleaseGdPictureImage(page);
          }
          remainder -= pageheight;
     }

     // If the image will fit on paper without resizing use PrintDialog otherwise use PrintDialogFit to resize to page
     if (Imaging1.GetWidthInches(tifid) > 8.5 || Imaging1.GetHeightInches(tifid) > 11)
     {
          Imaging1.PrintDialogFit(tifid);
     }
     else
     {
          Imaging1.PrintDialog(tifid);
     }
}

Re: Scale Large Pages, but not small pages when printing

Posted: Thu Jul 03, 2014 9:11 pm
by Loïc
Thank you very much for sharing this workaround.

W"re still working on a version that will implement this feature.

Cheers,

Loïc