16,013,816 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View .NET questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by Mahesh.Dhiman27 (Top 3 by date)
Mahesh.Dhiman27
30-Mar-15 3:12am
View
Hi,
Here my code, please check.
public static void GenerateNAVPDF(string strBoxID, string strWebOrder, string strDocketNo, string ftpIP, string folderName)
{
ReportViewer rptViewer = new ReportViewer();
try
{
logger.Debug("Generate PDF start");
Warning[] warnings;
string[] streamIds;
string mimeType = string.Empty;
string encoding = string.Empty;
string extension = string.Empty;
string devInfo = "<deviceinfo><outputformat>PDF" +
"<PageWidth>5.83in</PageWidth>" +
"<PageHeight>8.27in</PageHeight>" +
"<margintop>0in" +
"<marginleft>0in" +
"<marginright>0in" +
"<marginbottom>0in" +
"";
ProcessInvoiceDataBL objInvoiceBL = new ProcessInvoiceDataBL();
DataSet dsInvoice = null;
dsInvoice = objInvoiceBL.GetPostedInvoiceDetail(strBoxID);
logger.Debug("Fetch Invoice Data Successfully.");
if (dsInvoice != null && dsInvoice.Tables.Count > 1)
{
if (dsInvoice.Tables[0].Rows.Count > 0)
{
if (Convert.ToString(dsInvoice.Tables[0].Rows[0]["giftorder"]) == "1")
{
logger.Debug("This is a Gift Order,Please use Nav for Printing this Invoice. Shipment label is being printed.");
}
else
{
logger.Debug("Invoice Pdf start");
BarcodeLib.Barcode b = new BarcodeLib.Barcode();
b.Alignment = BarcodeLib.AlignmentPositions.CENTER;
b.LabelPosition = BarcodeLib.LabelPositions.TOPCENTER;
BarcodeLib.TYPE type = BarcodeLib.TYPE.CODE128;
b.IncludeLabel = false;
b.LabelPosition = BarcodeLib.LabelPositions.TOPCENTER;
System.Drawing.Image img = b.Encode(type, Convert.ToString(dsInvoice.Tables[0].Rows[0]["DocketNo"]), 400, 100);
dsInvoice.Tables[0].Columns.Add("ImgData", typeof(byte[]));
dsInvoice.Tables[0].Rows[0]["ImgData"] = imageToByteArray(img);
rptViewer.ProcessingMode = ProcessingMode.Local;
rptViewer.LocalReport.DataSources.Clear();
rptViewer.LocalReport.ReportPath = @"C:\UploadNAVPDFToFTPLog\Invoice.rdlc";
rptViewer.LocalReport.DataSources.Clear();
rptViewer.LocalReport.DataSources.Add(new ReportDataSource("dsInvoice_Header", dsInvoice.Tables[0]));
rptViewer.LocalReport.DataSources.Add(new ReportDataSource("dsInvoice_Lines", dsInvoice.Tables[1]));
logger.Debug("RPT Datasource Assiged, Render Start");
byte[] bytes = rptViewer.LocalReport.Render("PDF", devInfo, out mimeType, out encoding, out extension, out streamIds, out warnings);
logger.Debug("RPT Render Ends");
string file_name = strWebOrder + "_" + strDocketNo + ".pdf"; //save the file
System.Net.FtpWebRequest ftpRequest = null;
logger.Debug("FTP Request Start");
ftpRequest
Mahesh.Dhiman27
30-Mar-15 3:05am
View
Hi,
My service fetching data from sqlserver database and create pdf using report viewer and then save that pdf on ftp server. I am not using any window form.
Steps:
1) craeting report viewer object in method like ReportViewer rptViewer = new ReportViewer();
2) Fetching data from database and fill dataset.
3) Set all report viewer properties.
4) Create ftp request.
5) write report viewer bytes data on the ftp server using ftp stream.
6) rptViewer.LocalReport.Refresh(); rptViewer.RefreshReport();
7) Clear and Dispose dataset object.
8) clear and Dispose report viewer object
After that same process for next record.
Thanks
Mahesh Dhiman
Mahesh.Dhiman27
1-Jul-11 7:59am
View
Thanks Sir