Pdf formatting not correct on print

I have a pdf that I created in Adobe Live Cycle Designer, and am filling the fields from a .NET application using aspose’s pdfForm.FillField. The first page of alignments is correct for the text boxes I am filling but the indentation for the larger multi-line boxes is printing as if it were 0. The second page of the pdf has text boxes that the formatting is not correct. Font and font size is correct, but alignment is not.

Hi Christopher,


Thanks for your inquiry. Could you please share your source/output Pdf document here? So we will test it at our end and provide your more information accordingly.

Sorry for the inconvenience faced.

Best Regards,

Here is a copy of the PDF form that I am filling. All the fills in the c# code are the same, using fillfield.

Hi Christopher,


I have tested the scenario where I have first filled the PDF form field on second page, with multi-line text using following code snippet. As per my observations, the fields are having center alignment and after filling the field, the alignment remains same.

[C#]

//create Form object<o:p></o:p>

Aspose.Pdf.Facades.Form pdfForm = new Aspose.Pdf.Facades.Form();

// bind the source PDF file

pdfForm.BindPdf("c:/pdftest/OrderRefillRequest.pdf");

//Fill the field multiline text

pdfForm.FillField("form1[0].#subform[2].payment[0].TextField[0]", "this is a large multiline text which will \n span two lines and cannot be displayed in one");

//save updated PDF

pdfForm.Save(“c:/pdftest/new_test_form_updated_output.pdf”);



Then I have used the code snippet specified below to print the file and as per my observations, the alignment and width of field remains the same.

[C#]

//create PdfViewer object and bind PDF
file
<o:p></o:p>

PdfViewer pdfViewer = new PdfViewer();

pdfViewer.OpenPdfFile("c:/pdftest/new_test_form_updated_output.pdf");

//set PrinterSettings and PageSettings

System.Drawing.Printing.PrinterSettings printerSetttings = new System.Drawing.Printing.PrinterSettings();

printerSetttings.Copies = 1;

printerSetttings.PrinterName = "Microsoft XPS Document Writer";

//set output file name and PrintToFile attribute

printerSetttings.PrintFileName = "C:\\pdftest\\printoutput.xps";

printerSetttings.PrintToFile = true;

//disable print page dialog

pdfViewer.PrintPageDialog = false;

//pass printer settings object to the method

pdfViewer.PrintDocumentWithSettings(printerSetttings);

pdfViewer.ClosePdfFile();


In case I am unable to understand the problem, please share some further details along with code snippet. We are sorry for your inconvenience.

That is slightly different than how I’m using it. Here is the code to create the stream and form


[C#]
pdfStream = new System.IO.MemoryStream();
pdfForm = new Aspose.Pdf.Kit.Form(HttpContext.Current.Server.MapPath("~/App_Data/Templates/OrderRefillRequest.pdf"), pdfStream);

It is a web application so that’s why I have to use MapPath, but that should work just as well as a filepath.

To fill the fields I am just referencing them by their field names.

[C#]
pdfForm.FillField(“TextFieldDate”, textBoxCurrentDate.Text);
pdfForm.FillField(“TextFieldDate2”, textBoxCurrentDate.Text);
pdfForm.FillField(“TextFieldSpecialty”, textBoxSpecialty.Text);

and so on. At the end I am simply printing it out from the stream instead of saving it, since I don’t want to save the file.

[C#]
pdfForm.Save();
//Create PdfViewer object
Aspose.Pdf.Kit.PdfViewer viewer = new Aspose.Pdf.Kit.PdfViewer();
//Open input PDF file
viewer.OpenPdfFile(pdfStream);
//Print PDF document
viewer.PrintDocument();
//Close PDF file
viewer.ClosePdfFile();

Hi Christopher,

Thanks for sharing the information.

As per my observations, you are using Aspose.Pdf.Kit for .NET whereas in my earlier attempt, I have tested the scenario with Aspose.Pdf for .NET 7.8.0. Please note that since July-2011, Aspose.Pdf.Kit for .NET has been discontinued as separate product and all its classes and enumerations have been merged under Aspose.Pdf.Facades namespace of Aspose.Pdf for .NET.

christopher.schraer:
To fill the fields I am just referencing them by their field names.

[C#]
pdfForm.FillField("TextFieldDate", textBoxCurrentDate.Text);
pdfForm.FillField("TextFieldDate2", textBoxCurrentDate.Text);
pdfForm.FillField("TextFieldSpecialty", textBoxSpecialty.Text);
...
I have tried filling the form fields by simply referencing their names but as per my observations, the fields are not being filled. Can you please share the output PDF (form fields containing data/information).
christopher.schraer:
At the end I am simply printing it out from the stream instead of saving it, since I don't want to save the file.

[C#]
pdfForm.Save();
//Create PdfViewer object
Aspose.Pdf.Kit.PdfViewer viewer = new Aspose.Pdf.Kit.PdfViewer();
//Open input PDF file
viewer.OpenPdfFile(pdfStream);
//Print PDF document
viewer.PrintDocument();
//Close PDF file
viewer.ClosePdfFile();
Can you please try using Aspose.Pdf for .NET to print the PDF file and see if the problem still persists with new MergedAPI or it only occurs in Aspose.Pdf.Kit for .NET. We are sorry for this inconvenience.