Printing to PDF

Posted by: mrugesh11 on 8 September 2017, 3:20 pm EST

  • Posted 8 September 2017, 3:20 pm EST

    Hello,

    I am using farpoint spread windows dll into my web application, while printing to PDF

    1) PrintSheet method creates a blank PDF
    2) Save method crates a corrupted PDF

    Thanks,
  • Replied 8 September 2017, 3:20 pm EST

    Hello,

    Could you please clarify if you are using Spread for Winforms / Spread for Webforms. Please go through this documentation links for printing to PDF using Spread Win/ Spread Web controls:-

    http://sphelp.grapecity.com/WebHelp/SpreadNet8/WF/webframe.html#spwin-printPDF.html
    http://sphelp.grapecity.com/WebHelp/SpreadNet8/ASP2/webframe.html#CSSR-PrintPDF.html
    http://sphelp.grapecity.com/WebHelp/SpreadNet8/ASP2/webframe.html#spweb-filesave-pdf.html

    Hope it helps. Else please send us a sample replicating the issue wherein you are getting blank PDF file and also please let us know with which version of Spread are you testing your case with?

    Please confirm.

    Thanks,
    Reeva
  • Replied 8 September 2017, 3:20 pm EST

    I am using Spread for Winforms (version 6.0.3505.2008) into my webapplication
  • Replied 8 September 2017, 3:20 pm EST

    Hello,

    Can you send me your stripped out sample replicating the issue. It would help us in providing you with a fix at the earliest.

    Thanks,
    Reeva
  • Replied 8 September 2017, 3:20 pm EST

    Hello,

    I have uploaded sample projects for the Far Point version 6 as well as version 8. Link to download those project are as follows

    Far Point (version 6) : http://speedy.sh/UkQeK/FarPointDemo-6.zip
    Far Point (version 8) : http://speedy.sh/gtyXV/FarPointDemo-8.2.zip

    Thanks,
    Mrugesh
  • Replied 8 September 2017, 3:20 pm EST

    Hello,

    We are unable to run your sample and it is throwing attached exception.

    Could you please send us a working sample. We will look into this issue further.

    Thanks,
    Reeva


  • Replied 8 September 2017, 3:20 pm EST

    Hello Reeva,

    Please find out the link of runnable version of projects.

    For Version 6 : http://speedy.sh/T4mmG/FarPointDemo-6.rar
    For Version 8 : http://speedy.sh/s9ffR/FarPointDemo-8.2.rar

    Here I want to highlight 2 things

    1) we are migrating 1 of the Windows application into web application.

    In which to Generate the PDF we use the same windows code and the FarPoint.winforms DLLs they have used in windows environment instead of using a Farpoint.web dlls.

    The reason was that we were unable to find equivalent all the methods and their behaviour of FarPoint.winforms dlls.

    2) We have used FarPoint.WinForms dlls as a reference to the web application.

    Thanks,
    Mrugesh
  • Replied 8 September 2017, 3:20 pm EST

    Hello,

    Unfortunately, I am still unable to run your attached sample. However, you can directly save Spread Web to pdf using below mentioned code:-

    FarPoint.Web.Spread.PrintInfo pi = new FarPoint.Web.Spread.PrintInfo();
    pi.Orientation = FarPoint.Web.Spread.PrintOrientation.Landscape;
    FpSpread1.Sheets[0].PrintInfo = pi;
    FpSpread1.SavePdf("c:\\test.pdf");


    Here is the documentation link for the same as well:-
    http://sphelp.grapecity.com/WebHelp/SpreadNet8/ASP2/webframe.html#spweb-pdfpapersize.html

    Hope it helps.

    Thanks,
    Reeva
  • Replied 8 September 2017, 3:20 pm EST

    Hello,

    I have test the same code with the newer version of spread (i.e. 8) but the issue remain the same as in version (6).

    Sample class attached here.


    public void DrowPdf()
    {

    Form frm = new Form();
    FpSpread ssc = new FarPoint.Win.Spread.FpSpread();
    SheetView ss = new FarPoint.Win.Spread.SheetView();


    ss.SheetName = "Blad 1";
    ss.Protect = false;
    ss.Rows.Default.VerticalAlignment = FarPoint.Win.Spread.CellVerticalAlignment.Center;
    ssc.AllowCellOverflow = true;
    FarPoint.Win.Spread.PrintInfo pi = ss.PrintInfo;

    pi.ShowGrid = false;
    pi.ShowRowHeader = FarPoint.Win.Spread.PrintHeader.Hide;
    pi.ShowColumnHeader = FarPoint.Win.Spread.PrintHeader.Hide;
    pi.ShowColor = true;

    ss.PrintInfo = pi;
    ss.PrintInfo.ShowColumnHeader = FarPoint.Win.Spread.PrintHeader.Hide;
    ss.PrintInfo.ShowRowHeader = FarPoint.Win.Spread.PrintHeader.Hide;
    ss.PrintInfo.ShowColor = true;
    ss.SetClip(1, 1, 1, 1, "test");
    ss.PrintInfo.PrintToPdf = true;
    ss.PrintInfo.ShowBorder = false;

    try
    {
    ss.PrintInfo.PdfFileName = "D:\\results1.pdf";
    ssc.Sheets.Add(ss);
    ssc.PrintSheet(ss);
    }
    catch (Exception ex)
    {
    throw ex;
    }
    }

    I am trying to upload my complete project but the forum doesn't allow me to do so. If via mail it can be possible then please provide me the same.
  • Replied 8 September 2017, 3:20 pm EST

    Hello,

    You can upload the same on http://www.speedyshare.com/ and share the link with us.

    Thanks,
    Reeva
  • Replied 8 September 2017, 3:20 pm EST

    Hello,

    We request you to please send us a working sample then. Because the samples which you have sent across so far aren't working.

    Please send us working sample. We will look into this issue further.

    Thanks,
    Reeva
  • Replied 8 September 2017, 3:20 pm EST

    Hello,

    Your issue will be fixed in next release of Spread which is expected by this month's end.

    Thanks,
    Reeva
  • Replied 8 September 2017, 3:20 pm EST

    Hello Reeva,

    Can you please let me know when this release will be available and in which version ?

    Thanks,
    Chintan Dalwadi
  • Replied 8 September 2017, 3:20 pm EST

    Hello Reeva,

    I have attached here another solution

    http://speedy.sh/3sFQz/Demo.rar

    Hope it works at your machine.

    Thanks,
    mrugesh
  • Replied 8 September 2017, 3:20 pm EST

    Hello,

    Thanks for the working sample now. We are able to replicate the issue and could see that we are getting a corrupted PDF file. Hence we are escalating the same to the concerned team for the fix.

    #135145 is tracking id for your issue.

    We will update you once we hear anything from them.

    Thanks,
    Reeva
  • Replied 8 September 2017, 3:20 pm EST

    Thanks Reeva for your suggestion but Here I want to highlight you that due to complex business logic, We have decided to use same code of farpoint which is there in our current windows application. This code is using FarPoint.winforms in which there is no method like SavePdf.

    So basically we are using FarPoint.winforms DLL in our new web application and trying to generate PDF file using PrintSheet method and that is creating BLANK pdf file.


  • Replied 8 September 2017, 3:20 pm EST

    Hello,

    Your issue has been fixed with the latest build of Spread Studio 9 which can be downloaded from this link:-
    http://spread.grapecity.com/Downloads/Download/?productID=1

    Hope it helps.

    Thanks,
    Reeva
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels