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.
Sun Jun 14, 2020 10:04 pm
Hi, i want to print a pdf file. I have a custom paper size. If i use first code, there is no problem. I can print my pdf document. But i want to print
slienty so i use second code but i cant print correctly.
- Code: Select all
/* This code is ok. but i don't want to show printing message */
Spire.Pdf.PdfDocument pdfdocument = new Spire.Pdf.PdfDocument();
pdfdocument.LoadFromFile(Filepath);
SizeF size = pdfdocument.Pages[0].Size;
PaperSize paper = new PaperSize("Custom", 840, (int)size.Height);
paper.RawKind = (int)PaperKind.Custom;
pdfdocument.PrintSettings.Color = false;
pdfdocument.PrintSettings.PaperSize = paper;
pdfdocument.PrintSettings.SelectSinglePageLayout(PdfSinglePageScalingMode.ActualSize, false, 100);
pdfdocument.PrintSettings.SetPaperMargins(15, 0, 10, 10);
pdfdocument.Print();
pdfdocument.Dispose();
- Code: Select all
/* This code prints slienty. There is no messagebox or printing message but doesn't print correctly. I can't use my custom paper size */
Spire.Pdf.PdfDocument pdfdocument = new Spire.Pdf.PdfDocument();
pdfdocument.LoadFromFile(Filepath);
SizeF size = pdfdocument.Pages[0].Size;
PaperSize paper = new PaperSize("Custom", 840, (int)size.Height);
paper.RawKind = (int)PaperKind.Custom;
pdfdocument.PrintSettings.Color = false;
pdfdocument.PrintSettings.PaperSize = paper;
pdfdocument.PrintSettings.SelectSinglePageLayout(PdfSinglePageScalingMode.ActualSize, false, 100);
pdfdocument.PrintSettings.SetPaperMargins(15, 0, 10, 10);
PrintDocument printDoc = pdfdocument.PrintDocument;
printDoc.PrintController = new StandardPrintController();//don't show the dialog box;
printDoc.Print();
pdfdocument.Close();
-

Snoopthy
-
- Posts: 2
- Joined: Sun Jun 14, 2020 9:54 pm
Mon Jun 15, 2020 2:57 am
Hello,
Thanks for your inquiry.
Kindly note that "pdfdocument.PrintDocument" is now obsolete and may be removed in the future, please use the following code instead. If you have further questions, just feel free to let us know.
- Code: Select all
Spire.Pdf.PdfDocument pdfdocument = new Spire.Pdf.PdfDocument();
pdfdocument.LoadFromFile("test.pdf");
SizeF size = pdfdocument.Pages[0].Size;
PaperSize paper = new PaperSize("Custom", 840, (int)size.Height);
paper.RawKind = (int)PaperKind.Custom;
pdfdocument.PrintSettings.Color = false;
pdfdocument.PrintSettings.PaperSize = paper;
pdfdocument.PrintSettings.SelectSinglePageLayout(PdfSinglePageScalingMode.ActualSize, false, 100);
pdfdocument.PrintSettings.SetPaperMargins(15, 0, 10, 10);
/******!!!*******/
pdfdocument.PrintSettings.PrintController = new StandardPrintController();
pdfdocument.Print();
pdfdocument.Close();
/******!!!*******/
Sincerely,
Rachel
E-iceblue support team
-


rachel.lei
-
- Posts: 1571
- Joined: Tue Jul 09, 2019 2:22 am
Mon Jun 15, 2020 11:52 am
Hi rachel.lei,
Thank you for your help. That's what i want. Now, i can print sliently.
-

Snoopthy
-
- Posts: 2
- Joined: Sun Jun 14, 2020 9:54 pm
Tue Jun 16, 2020 1:17 am
Hello,
Glad to hear that!
If you have encounter any issues related to our product in the future, please feel free to contact us.
Have a nice day!
Sincerely,
Rachel
E-iceblue support team
-


rachel.lei
-
- Posts: 1571
- Joined: Tue Jul 09, 2019 2:22 am