We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Merged PDF sent with 0 KB even though data is there

Hi,

I am merging the PDF using ASPOSE.PDF kit. While sending the mail i am getting the merged PDF file as MemoryStream. Mail is sent successfully but the attached PDF showing as 0 KB.

Its working fine when sending the merged PDF file without setting any security (PDFPriveleges). If I set the owner password mail sent with 0 KB attachment.

public static MemoryStream GetMergedFile(FileStream[] files)
{
MemoryStream ms = new MemoryStream();
MemoryStream msOut = new MemoryStream();
try
{
PdfFileEditor editor = new PdfFileEditor();
editor.Concatenate(files, ms);
PdfFileSecurity pfs = new PdfFileSecurity(ms, msOut);
DocumentPrivilege dp = DocumentPrivilege.ForbidAll;
dp.AllowFillIn = true;
dp.AllowPrint = true;
dp.AllowCopy = true;
dp.PrintAllowLevel = 2;
pfs.EncryptFile("", Constants.OWNER_PASSWORD, dp, true);
if (ms != null)
ms.Close();
}
catch (Exception ex)
{
foreach (FileStream fs in files)
fs.Close();
log.Error(ex);
throw;
}
foreach (FileStream fs in files)
fs.Close();
return msOut;
}

Email Portion
-------------

MemoryStream ms = new MemoryStream();
ms = PDFHelper.GetMergedFile(files);
try
{
SmtpClient smtpClient = new SmtpClient(ConfigurationSettings.AppSettings["MailServer"]);
MailMessage message = new MailMessage(txtFrom.Text, txtTo.Text);
if(txtCC.Text.Trim() != "")
message.CC.Add(txtCC.Text);

if(txtBCC.Text.Trim() != "")
message.Bcc.Add(txtBCC.Text);
message.Subject = txtSubject.Text;
message.IsBodyHtml = true;
message.Body = txtMessage.Text;
if (ms != null)
message.Attachments.Add(new Attachment(ms, "MergedPDF.pdf", "application/pdf"));
smtpClient.Send(message);
.....................................

Anybody know the solution please let me know

Regards,

Hi Prakash,

Please share the input PDF files causing this problem, so we could test the issue at our end using your particular scenario. You’ll be updated with the results accordingly.

We’re sorry for the inconvenience.
Regards,

Hi,

I have enclosed the pdfs used at my end. Please check the issue at your end and let me know your feedback about it ASAP.

Regards,

Hi Prakash,

I have tested this issue at my end using the latest version of the Aspose.Pdf.Kit and the sample files you shared. However, I couldn’t notice any such problem. Could you please download the latest version and try at your end? If you still find the same problem then please do let us know.

We’re sorry for the inconvenience and looking forward to help you out.
Regards,