Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase 12»»

convert vb code to t-sql (pdf automation) Expand / Collapse
Author
Message
Posted Wednesday, August 14, 2013 9:23 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Friday, December 5, 2014 1:07 PM
Points: 103, Visits: 241
Want to convert VB Code to SQL
Dim objMyForm
objMyForm = CreateObject("CutePDF.Document")
objMyForm.initialize("DEMO-SDK-84232865-00514228")
objMyForm.openFile("x:\skb\rmfg-0202.pdf")

objMyForm.setField("KO No", "Acro Software Inc.")

objMyForm.saveFile("x:\skb\Form01.pdf")

Above code works fine.

This is what attempted but its not working

declare @objMyForm integer, @rs integer
execute @rs = dbo.sp_OACreate 'CutePDF.Document', @objMyForm OUTPUT
execute @rs = master.dbo.sp_OAMethod @objMyForm, 'initialize' , 'DEMO-SDK-84232865-00514228'
execute @rs = master.dbo.sp_OAMethod @objMyForm, 'OpenFile' , 'x:\skb\RMFG-0202.pdf'
execute @rs = master.dbo.sp_OAMethod @objMyForm, 'SaveFile' , 'x:\skb\Form01.pdf'
execute @rs = master.dbo.sp_OADestroy @objMyForm
Post #1484365
Posted Wednesday, August 14, 2013 9:32 AM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Friday, December 26, 2014 9:08 AM
Points: 1,510, Visits: 8,472

Nice code. Thanks for posting here.

You might want to add whatever question you have.




Alvin Ramard
Memphis PASS Chapter

All my SSC forum answers come with a money back guarantee. If you didn't like the answer then I'll gladly refund what you paid for it.
Post #1484369
Posted Wednesday, August 14, 2013 9:48 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Tuesday, December 23, 2014 12:10 PM
Points: 13,330, Visits: 12,829
Why do you want to do this in t-sql? It is the wrong tool for the job. A CLR proc, SSIS or even an application would be a much better choice here.

_______________________________________________________________

Need help? Help us help you.

Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

Need to split a string? Try Jeff Moden's splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Post #1484380
Posted Wednesday, August 14, 2013 9:50 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Friday, December 5, 2014 1:07 PM
Points: 103, Visits: 241
I want to populate the pdf form using large sql data
Post #1484382
Posted Wednesday, August 14, 2013 9:54 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Tuesday, December 23, 2014 12:10 PM
Points: 13,330, Visits: 12,829
skb 44459 (8/14/2013)
I want to populate the pdf form using large sql data


OK.

Why do you want to do this in t-sql? It is the wrong tool for the job. A CLR proc would be a much better choice here.


_______________________________________________________________

Need help? Help us help you.

Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

Need to split a string? Try Jeff Moden's splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Post #1484384
Posted Wednesday, August 14, 2013 10:02 AM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Friday, December 26, 2014 9:08 AM
Points: 1,510, Visits: 8,472
Sean Lange (8/14/2013)
skb 44459 (8/14/2013)
I want to populate the pdf form using large sql data


OK.

Why do you want to do this in t-sql? It is the wrong tool for the job. A CLR proc would be a much better choice here.


I agree.




Alvin Ramard
Memphis PASS Chapter

All my SSC forum answers come with a money back guarantee. If you didn't like the answer then I'll gladly refund what you paid for it.
Post #1484389
Posted Wednesday, August 14, 2013 10:02 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Tuesday, December 23, 2014 12:10 PM
Points: 13,330, Visits: 12,829
Maybe instead of taking code you found in a 6 year old thread here on ssc and asking us to convert it to t-sql you can tell us what you are actually trying to do.

(http://www.sqlservercentral.com/Forums/Topic383628-131-1.aspx)

The code posted there only saves a copy of a pdf, you sound like you want to create your own pdfs using data found in your database? If you can provide the details of what you want to accomplish we can help you figure out a good way to it. Using t-sql with sp_OACreate to generate a pdf is not the best way.


_______________________________________________________________

Need help? Help us help you.

Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

Need to split a string? Try Jeff Moden's splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Post #1484390
Posted Wednesday, August 14, 2013 10:53 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Friday, December 5, 2014 1:07 PM
Points: 103, Visits: 241
I am not aware of CLR Procs at all. But I am open to any good solutions.

I want to write a Stored Procedure which will
- Open a PDF template (Template has all the form field defined)
- put sql data into the pdf file.
-Save the pdf file on network location.

Post #1484403
Posted Wednesday, August 14, 2013 12:38 PM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Tuesday, December 23, 2014 12:10 PM
Points: 13,330, Visits: 12,829
skb 44459 (8/14/2013)
I am not aware of CLR Procs at all. But I am open to any good solutions.

I want to write a Stored Procedure which will
- Open a PDF template (Template has all the form field defined)
- put sql data into the pdf file.
-Save the pdf file on network location.



In a nutshell a CLR procedure is a way to write your code in .NET and call that from sql as a stored procedure. Can you write the code to do this in .NET? The CLR portion is pretty simple.


_______________________________________________________________

Need help? Help us help you.

Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

Need to split a string? Try Jeff Moden's splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Post #1484454
Posted Wednesday, August 14, 2013 9:00 PM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Yesterday @ 11:38 PM
Points: 35,858, Visits: 32,529
skb 44459 (8/14/2013)
This is what attempted but its not working


What's not working about it? Are you getting any error messages?

Also, what do you get when you run the following?

EXEC xp_dirtree 'x:\skb\',1,1;




--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."

(play on words) "Just because you CAN do something in T-SQL, doesn't mean you SHOULDN'T." --22 Aug 2013

Helpful Links:
How to post code problems
How to post performance problems
Post #1484565
« Prev Topic | Next Topic »

Add to briefcase 12»»

Permissions Expand / Collapse