Creating a PDF from a Stored Procedure in SQL Server

  • arronwall1 (8/8/2013)


    Hi, I think you can do it yourself. I am not a long-term user working with document and image processing. But I can do a lot work about it totally by myself with the help of some fine 3rd party document and image tools. As for myself, I used to format PDFs with the help of another PDF SDK. It is just one of many but I do appreciate its simple way of processing. Even though I only tried its free trial package to generate PDFs according to its tutorials about how to generate PDFs using C#.NET[/url] and didn't check the cost and licensing conditions, it worked great for me. Share with you. And I hope you success. Good luck.

    Best regards,

    Arron

    Hi there

    Thanks for your sharing.That sounds great.I'd like to have a try.But if it is expensive for pdf creating[/url]?By the way ,i want to know that whether this pdf program can work

    offline?Thanks a lot.

  • This doesn't work in MS-SQL 2005 where I created the example and PDF reader 9.00

  • Sory. I take my comment back. It works! My bug.

  • This does not work for me. Here is my attempt at trying to get it to work. The pdf generated is blank.

    System - Local SQL server 2008 R2 Dev edition, Windows 7 64 home premium bit. Adobe PDF reader 11.

    I got several errors of the same type -

    SQL Server blocked access to procedure 'sys.sp_OADestroy' of component 'Ole Automation Procedures' because this component is turned off as part of the security configuration for this server. A system administrator can enable the use of 'Ole Automation Procedures' by using sp_configure. For more information about enabling 'Ole Automation Procedures', see "Surface Area Configuration" in SQL Server Books Online.

    Solution -

    sp_configure 'show advanced options', 1;

    GO

    RECONFIGURE;

    GO

    sp_configure 'Ole Automation Procedures', 1;

    GO

    RECONFIGURE;

    GO

    Source - http://blog.consultdba.com/2010/09/how-to-enable-ole-automation-procedures.html

    Exec result -

    Configuration option 'show advanced options' changed from 0 to 1. Run the RECONFIGURE statement to install.

    Configuration option 'Ole Automation Procedures' changed from 0 to 1. Run the RECONFIGURE statement to install.

    Now trying to create pdf ...

    Blank PDF created, with one error in SQL server.

    Error -

    SQL Server blocked access to procedure 'sys.xp_cmdshell' of component 'xp_cmdshell' because this component is turned off as part of the security configuration for this server. A system administrator can enable the use of 'xp_cmdshell' by using sp_configure. For more information about enabling 'xp_cmdshell', see "Surface Area Configuration" in SQL Server Books Online.

    Solution -

    ---- To allow advanced options to be changed.

    EXEC sp_configure 'show advanced options', 1

    GO

    -- To update the currently configured value for advanced options.

    RECONFIGURE

    GO

    -- To enable the feature.

    EXEC sp_configure 'xp_cmdshell', 1

    GO

    -- To update the currently configured value for this feature.

    RECONFIGURE

    GO

    Source - http://blog.sqlauthority.com/2007/04/26/sql-server-enable-xp_cmdshell-using-sp_configure/%5D

    Exec result -

    Configuration option 'show advanced options' changed from 1 to 1. Run the RECONFIGURE statement to install.

    Configuration option 'xp_cmdshell' changed from 0 to 1. Run the RECONFIGURE statement to install.

    Attempting to make pdf again...

    Query successful. ZERO errors.

    PDF file created, but BLANK.

    END RESULT = Failure.

  • Nice stored procedure...

    good work..

    It would be great if you can make it customized to use different data sources.

    Awaiting your feedback for the same.

    Cheers!!

    🙂

  • the file is located in the machine where the sql server is installed.

  • Excellent work man!!!! This is one of the finest SP I have ever seen so far. I would love to use this code in my Production Database. Thanks for sharing such an important information.

  • It doesn't create the file. Did I miss something? Can somebody help?

  • I have created the procedure sql2pdf using code which you have provided. It ran successfully by i did not find the pdf generated in my C:/root directory. Can somebody please suggest, did i miss something ?

  • Hi did you get any reply for this...even i have the same problem. SP running successfully but output file is not generating :crying:

  • Its not working pdf file is not generating

    please help.

  • srinivassrivas (11/6/2015)


    Its not working pdf file is not generating

    please help.

    Where did you look for the file?

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Hi did save me for now. Also can you please suggest, how I can insert my company logo in the pdf?

    Thanks

    Santhosh

  • Hi found any solution

  • This solution has worked well for me on an MS SQL 2005 Standard Edition 64 bit.

    I am using the spSQL2PDF_2 version as illustrated in a previous reply.

    It is a very simple yet effective way to render text to an output PDF file.

    The procedure solved a problem I was having with sending out a daily email for an operator shift log report.

    Thank you for submitting. Grady Christie🙂

Viewing 15 posts - 121 through 135 (of 152 total)

You must be logged in to reply to this topic. Login to reply