Field Type Description Example
Sales Territory 2A SOAP sales territory for that order .See SOAP-2207 SA
Invoice/Credit- Value is either I or C 1A I for invoice and C for credit card payment I
Hard Coded "XX" 2A XX
Hard Coded Underscore 1A _
Invoice Number 8A A2R invoice number, received in Payment Status Update 467087HI
Hard Coded Underscore 1A _
Hard Coded "X" 1A X
Hard Coded Underscore 1A _
Date YYMMDD 6A Date sent to A2R 230327
Hard Coded Underscore 1A _
Time HHMM 4A Time sent to A2R 1442
Example: SAIXX_123456KI_X_231130_1153.PDF
Format of pdf file generation if we have
14 records that time 14 pdf files generated.
This is our Records and generate pdf files and send to ftp.
this


Deepak RawatRank #646 · 3.7K reputationPosted Aug 17, 2023, 1:57 AM EDT
You can use various libraries to generate a PDF file in Python. One commonly used library is
report lab.from reportlab.lib.pagesizes import letter from reportlab.pdfgen import canvas from ftplib import FTP def create_pdf(file_path, content): c = canvas.Canvas(file_path, pagesize=letter) c.drawString(100, 750, content) c.save() pdf_content = "This is the content of the PDF." pdf_file_path = "output.pdf" create_pdf(pdf_file_path, pdf_content) ftp_host = "ftp.example.com" ftp_user = "your_username" ftp_pass = "your_password" ftp = FTP(ftp_host) ftp.login(user=ftp_user, passwd=ftp_pass) remote_path = "/path/on/remote/server/output.pdf" with open(pdf_file_path, "rb") as pdf_file: ftp.storbinary("STOR " + remote_path, pdf_file) ftp.quit()Tasadduq BurneyRank #1,427 · 1.1K reputationPosted Aug 17, 2023, 4:05 AM EDT
Generate PDF Files: You can use a library like
fpdfin Python to create PDF files. Here's an example of how you might generate a PDF file for each record:from fpdf import FPDF records = [ {"SalesTerritory": "SA", "InvoiceCredit": "I", "InvoiceNumber": "467087HI", "Date": "230327", "Time": "1442"}, # ... other records ... ] for record in records: pdf = FPDF() pdf.add_page() pdf.set_font("Arial", size=12) pdf.cell(200, 10, "Sales Territory: " + record["SalesTerritory"], ln=True) pdf.cell(200, 10, "Invoice/Credit: " + record["InvoiceCredit"], ln=True) pdf.cell(200, 10, "Invoice Number: " + record["InvoiceNumber"], ln=True) pdf.cell(200, 10, "Date: " + record["Date"], ln=True) pdf.cell(200, 10, "Time: " + record["Time"], ln=True) filename = record["SalesTerritory"] + "XX_" + record["InvoiceNumber"] + "X_" + record["Date"] + "_" + record["Time"] + ".pdf" pdf.output(filename)Send PDF Files to FTP: To send the generated PDF files to an FTP server, you can use the
ftpliblibrary in Python. Here's how you can do it:from ftplib import FTP ftp = FTP('ftp.example.com') ftp.login(user='username', passwd='password') for record in records: filename = record["SalesTerritory"] + "XX_" + record["InvoiceNumber"] + "X_" + record["Date"] + "_" + record["Time"] + ".pdf" with open(filename, 'rb') as file: ftp.storbinary('STOR ' + filename, file) ftp.quit()Saravanan GanesanRank #153 · 15.1K reputationPosted Aug 16, 2023, 1:30 PM EDT
To generate PDF files based on the provided format and data for 14 records in an MVC5 application and then send them to an FTP server, you can follow these steps:
{
public string SalesTerritory { get; set; }
public string InvoiceCreditType { get; set; }
public string HardCodedXX { get; set; }
// ... other properties
}
Here's a simplified example of how you might generate PDFs and upload them to an FTP server:
using iTextSharp.text;
using iTextSharp.text.pdf;
using System.IO;
using FluentFTP;
// ...
foreach (var record in records)
{
// Generate the filename
string filename = $"{record.SalesTerritory}{record.HardCodedXX}_{record.InvoiceNumber}_{record.DateYYMMDD}_{record.TimeHHMM}.PDF";
// Create the PDF document
Document doc = new Document();
string pdfFilePath = Path.Combine("path/to/pdf/folder", filename);
using (FileStream fs = new FileStream(pdfFilePath, FileMode.Create))
{
PdfWriter writer = PdfWriter.GetInstance(doc, fs);
doc.Open();
// Add content to the PDF here
doc.Close();
}
// Upload the PDF to FTP server
using (var ftp = new FtpClient("ftp.example.com", "username", "password"))
{
ftp.Connect();
using (FileStream fs = new FileStream(pdfFilePath, FileMode.Open))
{
ftp.Upload(fs, $"/remote/folder/{filename}");
}
ftp.Disconnect();
}
}
Please note that this is a simplified example and you might need to handle exceptions, add actual content to the PDF, and manage error handling more robustly in a real-world scenario. Also, make sure to replace placeholders like
"path/to/pdf/folder","ftp.example.com","username", and"password"with actual values.Abhishek YadavRank #217 · 11.3K reputationPosted Aug 17, 2023, 5:48 AM EDT
you can use novacode or itext.pdf
Cr BhargaviRank #420 · 5.9K reputationPosted Aug 17, 2023, 7:12 AM EDT
Please use novacode to generate the PDF file in python