Print PDF File by C# program using Aspose.PDF - Page Size is condensed

I am replacing some text in bottom of a pdf file. After replacing the file i am saving the file in a particular location. If open that file and print direct(without using program) then it is coming correct but if i print the pdf file using the below code then the page is not printing in its actual size. The page content height and width is shrinked. How i will print the pdf file with program in its actual height and width. Here i am uploading two pages. One is without program(Direct Printing) and other is with program. if you see the the pdf with program,its contents are condensed.

Aspose.Pdf.Facades.PdfViewer viewer = new Aspose.Pdf.Facades.PdfViewer();
viewer.BindPdf(@fileName.ToString());
//viewer.AutoResize = true;
// viewer.AutoRotate = true;
viewer.PrintPageDialog = false; // Do not produce the page number dialog when printing
System.Drawing.Printing.PrinterSettings ps = new System.Drawing.Printing.PrinterSettings();
ps.PrinterName= cmbPrinter.Text;
//ps.PrintToFile = true;
ps.Copies= short.Parse(txtCount.Text.Trim());
System.Drawing.Printing.PrintDocument prtdoc = new System.Drawing.Printing.PrintDocument();
System.Drawing.Printing.PageSettings pgs = new System.Drawing.Printing.PageSettings();
pgs.Landscape = true;
// Set PageSize (if required)
// pgs.PaperSize = new System.Drawing.Printing.PaperSize(“A4”, 827, 1169);
// Set PageMargins (if required)
// pgs.Margins = new System.Drawing.Printing.Margins(12, 0, 2, 0);
// Print document using printer and page settings
viewer.PrintDocumentWithSettings(pgs, ps);
// Close the PDF file after priting
viewer.Close();

@ikramshams

Would you kindly share original source PDF document which you are trying to print. We will test the scenario in our environment and address it accordingly.

I am replacing the text like @color_arabic, @color_english etc by the below code then printing it. by above code which i have mentioned above. The problem is that it is not printing in exact size.
TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber("@color_arabic");
pdfDocument.Pages.Accept(textFragmentAbsorber);
TextFragmentCollection textFragmentCollection = textFragmentAbsorber.TextFragments;
foreach (TextFragment textFragment in textFragmentCollection)
{
textFragment.Text = txtColorArabic.Text.ToString().Trim();
textFragment.TextState.FontStyle = FontStyles.Bold;

            }
            textFragmentAbsorber = new TextFragmentAbsorber("@color_english");
            pdfDocument.Pages.Accept(textFragmentAbsorber);
            textFragmentCollection = textFragmentAbsorber.TextFragments;
            foreach (TextFragment textFragment in textFragmentCollection)
            {
                textFragment.Text = txtColorEnglish.Text.Trim();
                textFragment.TextState.FontStyle = FontStyles.Bold;
            }

Size 1 (290 x 150) blank A4.pdf (319.6 KB)

Now, If i print using below code then it is also not coming perfect which is in attachment. Height is going down and it is also more right alignment.

pdfDocument.Save(@fileName.ToString());
Aspose.Pdf.Facades.PdfViewer viewer = new Aspose.Pdf.Facades.PdfViewer();
viewer.BindPdf(fileName.ToString());
viewer.PrintPageDialog = false;
System.Drawing.Printing.PrinterSettings ps = new System.Drawing.Printing.PrinterSettings();
ps.PrinterName = cmbPrinter.Text;
ps.Copies = short.Parse(txtCount.Text.Trim());
System.Drawing.Printing.PageSettings pgs = new System.Drawing.Printing.PageSettings();
pgs.Landscape = true;
pgs.Margins = new System.Drawing.Printing.Margins(0, 0, 0, 0);
viewer.PrintDocumentWithSettings(pgs, ps);
viewer.Close();

PrintByProgram2.pdf (265.5 KB)

@ikramshams

The source and printed documents that you have shared, seem different. The document which was obtained after printing (PrintByProgram2.pdf) has background colors in it whereas (Size 1 (290 x 150) blank A4.pdf) does not. Furthermore, can you also share an annotated screenshot showing the errors that you are trying to point out in printed PDF document?

I am printing the source paper(Size 1 (290 x 150) blank A4) on a pre printed paper(which i am attaching). If i am printing on this paper after changing the text directly to printer(not by program) then it is coming good as it is in “PrintByDirectPrinter” but if i print by program then it is not coming exact height and width as it is given in “PrintByProgram2”.
The source and printed are same in height and width. The only difference is in background and text.
I am not getting any error when i am printing the pdf document. I have only issue that it is not printing with exact size (height and width) by program.

Size 1 (290 x 150) SASO without content A4.pdf (888.6 KB)

@ikramshams

Thanks for further elaboration.

We have noticed that the PDF document which was printed using the program, had content closer to the margins as compared to the content in other PDF (printed directly). We have logged an issue as PDFNET-47492 in our issue tracking system for further investigation on this scenario. We will further look into details of the issue and keep you posted with the status of its correction. Please be patient and spare us little time.

We are sorry for the inconvenience.

Can you please fix this issue today because it is very urgent.

@ikramshams

We would like to inform you that your issue has been logged under free support model where issues have low priority and are resolved on first come first serve basis. In case of urgent issues, we request you to please check our priority support option where issues are resolved with high priority and blocker/urgent issues are recommended to be reported there.

Furthermore, please note that priority support does not guarantee any immediate resolution but it does escalate the process of investigation and you may receive an ETA sooner. Nevertheless, we have recorded your concerns and will surely update you as soon as we have some additional updates. Please spare us some time.

We are sorry for the inconvenience.

@asad.ali
Is there any update possible today? It is very very urgent. Thanks in advance.

@ikramshams

We regret to share that there are no updates at the moment regarding issue resolution. We have recorded your concerns and will surely consider them during issue investigation. Please spare us some time.

We are sorry for the inconvenience.