Print Scaling

Skip Navigation LinksHome  /  Support  /  Forums  /  DynamicPDF PrintManager for .NET (v2)  /  Print Scaling

DynamicPDF PrintManager for .NET (v2) Forum

 Jan 17 2014 5:03 PM
I have a TIFF image which is slightly large than a letter size page.  I want to scale this automatically, and print it so that the entire TIFF fits on the printed page.

Here's a summary of the steps I'm currently doing:

Document doc = new Document();
doc.InitialPageZoom = PageZoom.FitPage;
Image img = new Image(TIFFImageFile, 0.0f, 0.0f);
Page page = new Page(PageSize.Letter, 0.0f);
page.Elements.Add(img);
doc.Pages.Add(page);
doc.Draw(tempPdfFilePath);
PrintJob printJob = new PrintJob(Printer.Default);
printJob.Pages.Add(tempPdfFilePath);
printJob.Print();

No scaling occurs, so part of the image is truncated.  How might I avoid this?

Thanks,
Paul
 Jan 20 2014 9:44 AM
Posted by a ceTe Software moderator
Hello Paul,

Yes, you can set the desired width and height to the image without any problem using our DynamicPDF Generator for .NET product. Please try setting the image width and height as of PDF page dimensions using SetBounds method of Image class and this will work for you. Below is the sample code for it.

            string TIFFImageFile = @"C:\Temp\GOOD.TIF";
            string tempPdfFilePath = @"C:\Temp\GOOD.pdf";

            Document doc = new Document();
            doc.InitialPageZoom = PageZoom.FitPage;
            Image img = new Image(TIFFImageFile, 0.0f, 0.0f);
            Page page = new Page(ceTe.DynamicPDF.PageSize.Letter, 0.0f);
            //Setting width and height to the image as of Page.
            img.SetBounds(page.Dimensions.Width, page.Dimensions.Height);
            page.Elements.Add(img);
            doc.Pages.Add(page);
            doc.Draw(tempPdfFilePath);

            PrintJob printJob = new PrintJob(Printer.Default);
            printJob.Pages.Add(tempPdfFilePath);
            //Setting the scaling to the print job.
            AutoPageScaling scaling = new AutoPageScaling(ScaleTo.PagePrintableArea, true, true);
            printJob.PrintOptions.Scaling = scaling;
            printJob.Print();

Thanks,
ceTe Software Support Team.
 Jan 20 2014 9:23 PM
Works beautifully, thanks!
 Jul 24 2017 2:55 PM
I need to print legal sized PDF's and have them scaled correctly to letter size, so they need to shrink.  Would the following code work to have them shrunk and print to letter size?

AutoPageScaling scaling = new AutoPageScaling(ScaleTo.PagePrintableArea, true, false);
                                    printJob.PrintOptions.Scaling = scaling;
 Jul 25 2017 10:22 AM
Posted by a ceTe Software moderator
Hello,

Yes, you can achieve your requirement of printing the Legal sized PDF to Letter sized by setting  paper size using PaperSize property for the PrintJob along with specifying the AutoPageScaling. Below is the code sample for it.

            InputPdf pdf = new InputPdf(= @"Path of input PDF");
            PrintJob printJobObj = new PrintJob(Printer.Default,pdf );
            printJobObj.PrintOptions.PaperSize = printJobObj.Printer.PaperSizes.Letter;
            AutoPageScaling scaling = new AutoPageScaling(ScaleTo.PagePrintableArea, true, false);
            printJobObj.PrintOptions.Scaling = scaling;
            printJobObj.Print();

Thanks,
ceTe Software Support Team.

All times are US Eastern Standard time. The time now is 1:58 AM.