I can insert the Attachments (pdf, doc, xls, ppt…)
into a word doc then I can open these attachments.
If I save it as pdf format then I CAN’T open these attachments any more.
Can Aspose pdf provide me this capability?
Hi there,
Here’s my output
Hi there,
TECHS:Can Aspose pdf provide me this capability?
Please confirm that the attachments can’t be opened in pdf format?
Hi,
I got the example codes from your link but nothing happened. Did I miss anything?
Dim MyDir As String = “C:\VS2012”
'Dim pdfDocument As New Document(dataDir & Convert.ToString(“AddAttachment.pdf”))
Dim pdfDocument As New Aspose.Pdf.Document(MyDir + “inFilePDF.pdf”)
Dim fileSpecification As New FileSpecification(MyDir & Convert.ToString(“MyTextFile.txt”), “Sample text file”)
’ Specify Encoding proparty setting it to FileEncoding.None
fileSpecification.Encoding = FileEncoding.None
'If Encoding is set to FileEncoding.None, then attachment is not compressed. The default encoding is FileEncoding.Zip.
pdfDocument.EmbeddedFiles.Add(fileSpecification)
Dim dataDir As String = “C:\VS2012\outFilePDF.pdf”
’ Save the document to disk.
pdfDocument.Save(dataDir)
Hi,
Thanks for sharing the details.
I have tested the scenario using following code snippet and I am unable to notice any issue. As per my observations, the attachment is properly being added to PDF file.
VB.NET Code:
Dim MyDir As String = "C:\pdftest"
'Dim pdfDocument As New Document(dataDir & Convert.ToString("AddAttachment.pdf"))
Dim pdfDocument As New Aspose.Pdf.Document(MyDir + "Table_in_pdf.pdf")
Dim fileSpecification As New FileSpecification(MyDir & Convert.ToString("AsposeTestThreadOld.txt"), "Sample text file")
' Specify Encoding proparty setting it to FileEncoding.None
fileSpecification.Encoding = FileEncoding.None
'If Encoding is set to FileEncoding.None, then attachment is not compressed. The default encoding is FileEncoding.Zip.
pdfDocument.EmbeddedFiles.Add(fileSpecification)
Dim dataDir As String = "C:\pdftest\outFilePDF.pdf"
' Save the document to disk.
pdfDocument.Save(dataDir)
Dim pdfDocument As New Aspose.Pdf.Document(“C:\VS2012\BlankPDF.pdf”)
Dim fileSpecification As New FileSpecification(Convert.ToString(“C:\VS2012\inFileTXT.txt”), “Sample text file”)
fileSpecification.Encoding = FileEncoding.None
pdfDocument.EmbeddedFiles.Add(fileSpecification)
Dim dataDir As String = “C:\VS2012\outFilePDF.pdf”
pdfDocument.Save(dataDir)
Attached are the input files and output file used in this test. Nothing happened.
Hi Dzung,
Thanks for letting me know I’m supposed to click on the paper clip.
I was looking for the icon in the pdf body.
I had this dilemma: in the old Aspose word version, I need to create word doc then convert to XML them pdf.
I already had extensive word process to create a form using Aspose word. but I now must use Aspose pdf to insert attachments pdf,doc,xls…) into pdf. I can’t attach attachments Aspose.pdf.document to Aspose.word.document.
It’ll require me to rewrite entire process to format a form using Aspose pdf.
Any way I can convert the word doc to pdf and still open attachments from pdf?
Any help how to solve this problem?
Hi Dzung,
Thanks for sharing the details.
In order to accomplish this requirement, you need to try using FileAttachmentAnnotation object. Please take a look over following code snippet to accomplish this requirement.
C# Code
// Open the PDF document
Document doc = new Document();
doc.Pages.Add();
// Get reference of the page to which you need to add the annotation
Page page = doc.Pages[1];
// Create ScreenAnnotation object with .swf multimedia file as an argument
Aspose.Pdf.Annotations.FileAttachmentAnnotation annotation = new Aspose.Pdf.Annotations.FileAttachmentAnnotation(page, new Aspose.Pdf.Rectangle(100, 100, 120, 120), new FileSpecification("c:/pdftest/Sample.pdf"));
annotation.Icon = Aspose.Pdf.Annotations.FileIcon.Paperclip;
// Add the annotation to annotations collection of page
page.Annotations.Add(annotation);
doc.Save(“c:/pdftest/FileAttachmentAnnotation.pdf”);
TECHS:in the old Aspose word version, I need to create word doc then convert to XML them pdf. I already had extensive word process to create a form using Aspose word.
Please provide me the example for VB codes.
Thanks
Hi Dzung,
Please try using following code snippet.
VB.NET code
' Open the PDF document
Dim doc As Aspose.Pdf.Document = New Aspose.Pdf.Document()
doc.Pages.Add()
' Get reference of the page to which you need to add the annotation
Dim Page As Page = doc.Pages(1)
' Create ScreenAnnotation object with .swf multimedia file as an argument
Dim annotation As Aspose.Pdf.Annotations.FileAttachmentAnnotation = New Aspose.Pdf.Annotations.FileAttachmentAnnotation(Page, New Aspose.Pdf.Rectangle(100, 100, 120, 120), New FileSpecification("c:/pdftest/Sample.pdf"))
annotation.Icon = Aspose.Pdf.Annotations.FileIcon.Paperclip
' Add the annotation to annotations collection of page
Page.Annotations.Add(annotation)
doc.Save("c:/pdftest/FileAttachmentAnnotation.pdf")
I create a word doc including multiple sections. Each section has bookmarks. If users want to save as pdf then it’ll save doc to pdf format.
if I insert attachments into this word doc then convert it to psf later, I can no longer open these attachments in pdf.
I want to read this pdf file, look up the bookmark then insert attachments at these bookmarks. the attachments can be different types such as doc, docx, xls, xlsx, ppt, ppt, pptx, rtf, msg, mpg…
Please advise if aspose pdf can do this.
thanks
In order to accomplish above stated requirement, please open PDF document, try Getting a Bookmark’s Page Number and then try using following code snippet to add FileAttachment on specific page of PDF file.
[C#]
// Instantiate PDF document
Document doc = new Document();
// add page to pages collection of PDF file
doc.Pages.Add();
// Get reference of the page to which you need to add the annotation
Page page = doc.Pages[1];
// Create ScreenAnnotation object with .swf multimedia file as an argument
Aspose.Pdf.Annotations.FileAttachmentAnnotation annotation = new Aspose.Pdf.Annotations.FileAttachmentAnnotation(page, new Aspose.Pdf.Rectangle(0, 400, 600, 700), new FileSpecification("c:/pdftest/C8_1FormProcessPDF.pdf"));
// Add the annotation to annotations collection of page
page.Annotations.Add(annotation);
// Save the update PDF document with annotation
doc.Save("c:/pdftest/WithAttachment.pdf");
I got this error ‘This is not a structured file’ while inserting PPT attachment using Aspose words :
If fileExtension = “PPT” Then
progid = “PowerPoint.Show.8”
Else
progid = “PowerPoint.Show.12”
End If
Using stream As New MemoryStream(File.ReadAllBytes(filePathName))
docBuilder.InsertOleObject(stream, progid, True, Nothing)
End Using