Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Mon Jun 12, 2017 11:51 am

Hi,
I want to print a pdf file without opening adobe acrobat or other pdf readers and I can't really do that. I tried using you library (Spire.pdf) and when i print the text is incredibly streched in height. This is the c# code:


PdfDocument doc = new PdfDocument();
doc.LoadFromFile(@"C:\Users\Daniele\Desktop\etichettaGruppo.pdf");
doc.PrinterName = "Star TSP100 Cutter (TSP143)";
// doc.PageSettings.Orientation = PdfPageOrientation.Portrait; <<<these are examples of what i tried to do
//doc.PageSettings.Height = 5; <<<
doc.PrintDocument.Print();

I'm printing on a Star TSP100 Cutter (TSP143) which is printer for receipts.
It's not the file because when i try to print it the old fashioned way it's fine
thank you in advance for your help

effecitech
 
Posts: 3
Joined: Mon Jun 12, 2017 6:37 am

Tue Jun 13, 2017 2:43 am

Dear effecitech,

Thanks for your inquiry.
After an initial test, sorry that I didn't find the text was stretched. Could you please provide us the input/output PDF files for investigation.

Thanks,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Tue Jun 13, 2017 7:35 am

PDF:
etichetta.7z


Printed it's something like this:
P_20170613_092343.7z

(it's only a part. I stopped the printing because i didn't want to waste paper)

When I print in Acrobat it says that the height is 3 metres but it cuts the paper when the file is done printing, so it come out the right size.
By the photo one could think that the height is still 3 metres and it's streching the paper, so that the height matches the file, but that's not what I want

thank you again for looking into this

effecitech
 
Posts: 3
Joined: Mon Jun 12, 2017 6:37 am

Tue Jun 13, 2017 8:56 am

Dear effecitech,

Thanks for your inquiry.
Please try to use following code to set the actual size.
Code: Select all
            doc.PageScaling = PdfPrintPageScaling.ActualSize;

In addition, I found the size of the document you provided is 3.07 X 4.60 in instead of 3 metres you mentioned.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Tue Jun 13, 2017 10:21 am

I've tried adding your code and the result hasn't changed.
But when I try to print i still get 3m:
screenshot.png


I tried setting a max size and it kinda works, but if I have to print a pdf longer than 20cm it's gonna be a problem.
But aside from that, since it could work, I noticed another problem.

As I said the max size is 20 cm, and when I print, the first 5 cm are blank, then there is the pdf and then it cuts the paper when it's finished (but there would still be 5 cm of blank space). How can I align it to the top? On acrobat when printing there's an option:
" orientation : vertical " and that works. Is there a way to set such a thing in code?

effecitech
 
Posts: 3
Joined: Mon Jun 12, 2017 6:37 am

Wed Jun 14, 2017 9:06 am

Dear effecitech,

Thanks for your information.
After further investigation, I found you set the paper size as 72 mm X receipt in Page Setup when printing with the printer "Star TSP100 Cutter (TSP143)". Yet the actual size of the document is the size I mentioned before.
As for setting "orientation:vertical", I found there are some issues and posted it to our Dev team, once there is any progress, we will let you know.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Fri Jun 30, 2017 8:28 am

Dear effecitech,

Thanks for waiting.
We just publish Spire.PDF Pack(Hot Fix) Version:3.9.189, please use this version and following code to solve your issue.
Code: Select all
PdfDocument doc = new PdfDocument();
doc.LoadFromFile(@"F:\testing\pdf form testing\original document\etichetta.pdf");
doc.CustomHandleLandscape = true;
doc.PrintDocument.DefaultPageSettings.Landscape = false;
doc.PageScaling = PdfPrintPageScaling.ActualSize;
doc.PrintDocument.Print();

Looking forward to your feedback.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Return to Spire.PDF