Alignment wrong when printing on pre-printed forms

I have an application that prints a pdf document on a pre-printed form using a PdfViewer object. The alignment in the printed document is off. However, if I print the same document using Acrobat Reader XI, the alignment in the printed document is correct.

I’m using AutoResize, and margins set to (0,0,0,0) without any improvement. Any ideas on how I could improve the alignment? The code to print the document using the PdfViewer is shown below:

        _PdfViewer viewer = new PdfViewer();_

_ viewer.BindPdf(document);_
_ viewer.PrinterJobName = Path.GetFileName(document.FileName);_
_ viewer.Resolution = 110;_
_ // Set attributes for printing_
_ viewer.AutoResize = true; // Print the file with adjusted size_
_ viewer.AutoRotate = false; // Print the file with adjusted rotation_
_ viewer.PrintPageDialog = false; // Do not produce the page number dialog when printing_
_ viewer.RenderingOptions.UseNewImagingEngine = true;_

_ // Create objects for printer and page settings and PrintDocument_
_ System.Drawing.Printing.PrinterSettings ps = new System.Drawing.Printing.PrinterSettings();_
_ System.Drawing.Printing.PageSettings pgs = new System.Drawing.Printing.PageSettings();_

_ // Set printer name_
_ ps.PrinterName = printerName;_

_ pgs.PaperSize = new System.Drawing.Printing.PaperSize(paperTypeName, paperWidth, paperHeight);_
_ pgs.Margins = new System.Drawing.Printing.Margins(margins.Left, margins.Right, margins.Top, margins.Bottom);_
_ pgs.PaperSource = GetPaperSource(printerName, trayName);_

_ // Print document using printer and page settings_
_ viewer.PrintDocumentWithSettings(pgs, ps);_

If I print the document on the pre-printed form using Acrobat Reader XI,

@cdonahue

Thank you for contacting support.

We would like to request you to share the source and generated document with us, along with the file printed using Acrobat Reader XI so that we may try to reproduce and investigate it in our environment. Moreover, before sharing requested data, please ensure using Aspose.PDF for .NET 18.4 in your environment.

Hi Farhan,

I see your using NuGet now for distribution so I was able to download Aspose.PDF for .NET 18.5 but I get the same results.

Attached you should find the following:

  • PdfPrintTest2.zip - is a Visual Studio 2015 project with PdfPrintTest2\obj\Debug, PdfPrintTest2\bin\Debug, and packages\Aspose.PDF.18.5.0 emptied out (figured you don’t need these).
  • cms_1500_TMM82712A2_NoPHI2.pdf - is the pdf document I’m trying to print on the pre-printed form.
  • claim-form-cms-1500.pdf - is the pre-printed form.

I’ll follow this email with a scanned image of the resulting output using the above and an email with a scanned image of the output using Adobe Reader XI.

PdfPrintTest2.zip (16.3 KB)
cms_1500_TMM82712A2 _NoPHI2.pdf (13.0 KB)
claim-form-cms-1500.pdf (2.2 MB)

Hi Farhan,

Attached is a scanned image of the resulting about using Aspose.PDF via PdfPrintTest2 application
IMG_20180508_Bad.pdf (2.6 MB)
.

Hi Farhan,

Attached is a scan image when Adobe Reader XI is used.

IMG_20180507_Good.pdf (2.5 MB)

Hi Farhan,

Following is a screen shot of PdfPrintTest2 showing the parameters I used to reproduce the problem

image.png (13.2 KB)

@cdonahue

Thank you for sharing requested data.

We are investigating the scenario and will get back to you with our findings soon.

@cdonahue

Thank you for being patient.

We have tested the scenario by printing 2 copies of claim-form-cms-1500.pdf and then printing cms_1500_TMM82712A2 _NoPHI2.pdf file on those pre-printed copies. With Aspose.PDF API and with Adobe Reader but the results are almost same. Can you please test the same with some other printer to check if this is a printer specific problem because we are unable to reproduce it in our environment. Kindly share your observations so that we may investigate further to help you out.

Hi Farhan,

It took a while to get a test sample out of our production printer but we get the same results in that the results a misaligned. However, the misalignment is different with each printer. My test printer is a Canon MX 920 and the production printer is HP LaserJet M608. When using either printer, the top half of the form is ok but the bottom half is way off. The attached images are scans of the form printed on each of the two printers. The forms contain protected health information which has been redacted from the scan images. Each scan is from the same original document.

HP Laserjet M608.jpg (401.7 KB)

Sorry. I didn’t finish the upload of the Cannon MX920 image before I sent the last post.

Cannon MX920.jpg (822.6 KB)

@cdonahue

We have logged an investigation ticket with ID PDFNET-44734 to investigate it further in our environment. The ticket ID has been linked with this thread so that you will receive notification as soon as the ticket is resolved.

We are sorry for the inconvenience.

Hi Farhan,

I haven’t see any change in status on this ticket. Has any progress been made?

@cdonahue

The issue reported by you has been logged in our issue management system a couple of weeks ago, and is pending owing to previously logged tickets. It will be investigated on its due turn which can take a few months. We appreciate your patience and comprehension in this regard.

However, we also offer Paid Support, where issues are used to be investigated with higher priority. Our customers, who have paid support subscription, report their issue there which are meant to be investigated urgently. In case your reported issue is a blocker, you may please consider subscribing for Paid Support. For further information, please visit Paid Support FAQs.

Hi Farhan,

So how long do paid support issues typical take to get resolved?

@cdonahue

We are investigating the ticket and will let you know about tentative ETA for resolution of this ticket with Paid Support subscription.

Hi Farhan,

Any update on what kind of ETA for resolution we might expect with Paid Support subscription?

@cdonahue

We need a little more time before we share tentative ETA for the resolution of this ticket. We will get back to you as soon as we can. Please be patient and spare us little more time.

Hi Farhan,

Any news on this issue? It’s been over 30 days since your last response.

On this same topic, I’ve done some more testing and have discovered that if I set the following options, I get better results:

        PdfViewer.RenderingOptions.ScaleImagesToFitPageWidth = true;
        PdfViewer.AutoResize = false;
        PdfViewer.AutoRotate = false;

The result is almost correct but everything needs to be shifted up one line and 2 characters to the left to make the alignment with the underlying form correct.

Is there a way to shift all the text up and two the right through the API? I’ve got my margins (top, bottom, left, and right) set to zero. I tried using a negative value for the top and left margin but that caused an exception. Any other ideas?

I’m attaching some files for your reference as follows:

  1. CMS_1500_Azalea_Standard.pdf (10.5 KB)
  2. claim-form-cms-1500.pdf (2.2 MB)
  3. Scanned_Of_Azalea_CMS_1500_TestDoc_Printed_Using_AsposePDF.pdf (2.4 MB)
  4. Scanned_Of_Azalea_CMS_1500_TestDoc_Perfect.pdf (2.5 MB)

The first document is the source document that I’m printing.

The second document is the pre printed form.

The third document is a scan image of the output when the source document (1) is printed on to the pre-printed form (2) using Aspose.PDF with the parameters mentioned above.

The fourth document is a scanned image of the output when the source document (1) is printed on the pre-printed form (2) using Acrobat.

One other thing that I find odd is the text is much clearer when the document is printed using Acrobat then it is when using Aspose.PDF. Why is that?

Any help you can provide would be appreciated.

@cdonahue

Thank you for sharing your findings.

We would like to update you that tentative ETA for resolution of this ticket is Aspose.PDF for .NET 18.8 which will probably be released around first week of August 2018. We have updated your findings under the same ticket and will share our feedback with you as soon as the ticket will be resolved. Please be patient and spare us little more time.

Hi Frahan,

Thank you for your response. I would like to clarify my understanding of your response. Are you indicating that your development team has identified a deficiency (bug) and your goal is to provide a fix and include that fix in Aspose.PDF for .NET 18.8? I would like to make sure I am setting the correct expectation level when I report this information to my management team.