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.

Sat Nov 28, 2020 7:43 am

Hi,

I have an issue with the formatting of PDF documents when printing.
When I have tried to print with Visual Studio with IISExpress and Chrome, it works well.
BUT, when using it on IIS, it is the wrong format, wrong font...
But I don't know why, I have tried to research and found a suggestion about inserting meta tag is "meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"", but I don't know how can do that and not sure it will work or not. And this is my line codes below:
Code: Select all
byte[] Temdata = Convert.FromBase64String(convertData.data);
PdfDocument doc = new PdfDocument();
doc.LoadFromBytes(Temdata);
doc.CustomHandleLandscape = true;
doc.PrintDocument.DefaultPageSettings.Landscape = false;
doc.PrinterName = convertData.localprintername;
doc.PrintDocument.Print();

lazycatit
 
Posts: 3
Joined: Fri Nov 27, 2020 2:35 am

Mon Nov 30, 2020 8:32 am

Hello,

Thanks for your inquiry and sorry for the late reply as weekend.
According to your description, I did an initial test but did not enounter the issue you mentioned. To help us further investigate your issue, please provide your PDF file. You can upload it here or send it to us via email ([email protected]). Thanks in advance!
In addition, the methods you used are outdated, please use the following code instead.
Code: Select all
            doc.PrintSettings.Landscape = false;
            doc.PrintSettings.PrinterName= convertData.localprintername;
            doc.Print()


Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Mon Nov 30, 2020 10:14 am

Hi Brian,

This is my full lines code below, including PDF data also:
Code: Select all
https://dotnetfiddle.net/OZqPRS


I hope you can suggest me a solution.

Thanks,

lazycatit
 
Posts: 3
Joined: Fri Nov 27, 2020 2:35 am

Tue Dec 01, 2020 5:47 am

Hello,

Thank you for sharing more information.
I tested your case with the latest Spire.PDF Pack(Hot Fix) Version:6.11.6 but found that it works well on IIS. If you are using an older version, I’d suggest you try again with the latest version.
Meanwhile, I also uploaded my testing project for your reference, you can deploy it on your environment and test it.

If there is still any issue, please provide your OS information (e.g. Windows Sever 2012, 64bit) and region settings (e.g. China, Chinese) for further investigation.

Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Tue Dec 01, 2020 7:27 am

Hi Brian,

I have tried your lines code, it only works on IIS Express and Google Chrome as I said but it doesn't work on IIS. I have used it on the latest version (6.11.6). All of my settings below:
My OS: Windows 10 (64bit)
Region: US
Printer: Xprinter XP-365B

Image

lazycatit
 
Posts: 3
Joined: Fri Nov 27, 2020 2:35 am

Tue Dec 01, 2020 11:09 am

Hello,

Sorry we don’t have the same printer Xprinter XP-365B as yours, but we used our printer (HP Color LaserJet MFP M281fdw) to test your case, everything works well. I suggest you can use the .NET printing API to print directly to see if the similar issue occurs, like the code below.
Moreover, are there any special settings for fonts on your IIS? If possible, please provide some screenshots of your IIS settings. Looking forward to your further feedback.
Code: Select all
        public static void Main()
        {
            PrintDocument printDocument1 = new PrintDocument();
            var printerSettings = new System.Drawing.Printing.PrinterSettings();
            printerSettings.PrinterName = "your printer name";
            printDocument1.PrinterSettings = printerSettings;
            printDocument1.PrintPage += printDocument1_PrintPage;
            printDocument1.Print();
        }
        public static void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            e.Graphics.DrawString("Trà sữa (L)", new Font("Times New Roman", 25), Brushes.Black, 100, 100);
            e.Graphics.DrawString("1 Thêm CreamCake", new Font("Times New Roman", 25), Brushes.Black, 100, 200);
            e.Graphics.DrawString("+ Không đá, 30% đường", new Font("Times New Roman", 25), Brushes.Black, 100, 300);
            e.Graphics.PageUnit = GraphicsUnit.Inch;
        }


Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Return to Spire.PDF