Re: Converting Word Doc with Embedded files to a PDF

HI Rashid,

I want word,ppt,excel with embedded files needs to be converted to PDF.Is that possible?

Thanks much!

Anand

Hi Anand,


Thanks for your interest in our products.

Please note that the approach of using Aspose.Pdf with other products for conversion into PDF format is a legacy approach. So now in order to convert

  • Word file into PDF format, please try using Aspose.Words for .NET
  • Excel worksheet into PDF format, please try using Aspose.Cells for .NET
  • PowerPoint presentation into PDF format, please try using Aspose.Slides for .NET

For further assistance, I am moving this thread to respective forum where I believe my fellow workers taking care of these products would be in better position to answer the query related to embedded files in Word/PPT/Excel files.

Hi,

Thanks for your consideration of Aspose.Total

Aspose.Cells for .NET, which is a part of Aspose.Total, can convert your Ms-Excel files into pdf.

Please see this documentation article for your more help.

Hi,

I tried Excel to PDF in Aspose total.java and working fine.But I have excel sheet with embedded objects like word and ppt inside the excel sheet.Is it possible to convert that as well using Aspose?or even if it possible to read those word/ppt inside the excel and store it in some location is enough.Is that possible.

Note:I tried reading embedded file inside the word document and I could store in some location.But I dont find any sample codes for excel and ppt.If you share the sample codes that will be very helpful.

Thanks

Anand

Hi Anand,


Regarding extracting OLE Object in Excel files, please see the document for your reference:
Java:
http://www.aspose.com/docs/display/cellsjava/Managing+OLE+Objects

.NET:
http://www.aspose.com/docs/display/cellsnet/Managing+OLE+Objects
(Please see the contents/example under "Extracting OLE Objects in the Workbook" sub-heading).

Thank you.

Thank you very much.

We may need to decide today that which tool we need to use.Aspose is really great.

I am wondering whether below two as well is possible using Aspose?

1.Conversion of Excel to PDF having Macros.

2.Is it possible to convert DXL file(Lotus note mail file) to PDF using Aspose?

Hi,


Regarding:
"1.Conversion of Excel to PDF having Macros."

I am afraid this is not supported. The reason is we do not actually run the macros, the macros/vba codes are run inside by MS Excel when opening the Excel file into it. So, if the macros will change the content of the workbook, we are afraid we cannot make the same result as by macros’ execution.

We only support macros / vba codes in the way that Aspose.Cells will preserve the macros/vba codes in the template Excel file and re-save the Excel file with them.

Thanks for your understanding!

Hi Anand,


Thanks for your inquiry. I am representative of Aspose.Words team.

Yes, Aspose.Words supports preserving OLE objects in documents. That is if you open an MS Word document and then save it (possibly in another MS Word format or PDF) then OLE objects are preserved. You can also access objects programmatically, extract their data and preview images.

If we can help you with anything else, please feel free to ask.

Best Regards,

Hi,

I could be able to extract the embedded files in the doucment.But I dont find any methods to get the actual name of the embedded files in a word document .Please help to get the actaul name of the embedded files in a document.Here is the code I am using.

shape.getOleFormat().save(String.format("C:\\Temp\\Aspose\\Embedded\\Filename_", i, extension));I am just using Filename_i for the extracted embedded object.It would be great if i get the orginal file name.

Document doc = new Document("C:\\Temp\\Aspose\\Photo of business.DOCX");

// Get all shapes.

NodeCollection shapes = doc.getChildNodes(NodeType.SHAPE, true);

// Loop through all shapes.

for (int i = 0; i < shapes.getCount(); i++) {

Shape shape = (Shape)shapes.get(i);

System.out.println(i+"---"+shape.getOleFormat().getProgId());

// Check if the current shape has OLE object

if (shape.getOleFormat() == null)

continue;

// Determine extenfion of the object.

// Let's use bin extension by default.

String extension = "bin";

// String extension = "bin";

if (shape.getOleFormat().getProgId().equals("Word.Document.8"))

extension = "doc";

if (shape.getOleFormat().getProgId().equals("Word.Document.12"))

extension = "docx";

if (shape.getOleFormat().getProgId().equals("Excel.Sheet.8"))

extension = "xls";

if (shape.getOleFormat().getProgId().equals("Excel.Sheet.12"))

extension = "xlsx";

if (shape.getOleFormat().getProgId().equals("PowerPoint.Show.8"))

extension = "ppt";

if (shape.getOleFormat().getProgId().equals("PowerPoint.Show.12"))

extension = "pptx";

// try {

// shape.getOleFormat().save(String.format("C:\\Temp\\Aspose\\EmbedTest", shape.getOleFormat().getSourceFullName(), extension));

// }

// Save OLE object.

shape.getOleFormat().save(String.format("C:\\Temp\\Aspose\\Embedded\\Filename_", i, extension));

}

Hi ,

Could any one please update on the above question?

Thank you.

Hi Anand,

Thanks for your inquiry.

Sure, you can get the source file name if the OLE object is linked by using OleFormat.SourceFullName property; otherwise, I am afraid, if the object is embedded, you cannot get the source file name.

If we can help you with anything else, please feel free to ask.

Best Regards,

Thanks for the reply.
I am facing another issue while executing the below code.code is working fine for documents without embedded objects.But getting access denied error to the destination path while saving the embedded objects.Please help.I am pasting the code here.

public void convertWordToPdf(String destintaion,String fileNamewithExtn,List convertedFileNames,DocumentToPDFConverter docconverter){
String fileName=AppHelper.getFileName(destintaion+fileNamewithExtn);
try {
String inputFile=destintaion+fileNamewithExtn;
String outputFile=destintaion+fileName+ApplicationConstants.pdf;
Document doc = new Document(inputFile);
doc.save(outputFile);
convertedFileNames.add(fileName+ApplicationConstants.pdf);
extractEmbeddedObjects(doc,fileName,destintaion,convertedFileNames,docconverter);
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* Extracts Embedded attachment in a document
* @param document object
*/
public void extractEmbeddedObjects(Document doc,String fileName,String destination,List convertedFileNames,DocumentToPDFConverter docconverter){
boolean flag=true;
NodeCollection shapes = doc.getChildNodes(NodeType.SHAPE, true);
for (int i = 0; i < shapes.getCount(); i++) {
Shape shape = (Shape)shapes.get(i);
if (shape.getOleFormat() == null)
continue;
String extension=null;
if (shape.getOleFormat().getProgId().equals(“Word.Document.8”))
extension = “doc”;
else if (shape.getOleFormat().getProgId().equals(“Word.Document.12”))
extension = “docx”;
else if (shape.getOleFormat().getProgId().equals(“Excel.Sheet.8”))
extension = “xls”;
else if (shape.getOleFormat().getProgId().equals(“Excel.Sheet.12”))
extension = “xlsx”;
else if (shape.getOleFormat().getProgId().equals(“PowerPoint.Show.8”))
extension = “ppt”;
else if (shape.getOleFormat().getProgId().equals(“PowerPoint.Show.12”))
extension = “pptx”;
else
flag=false;
try {
shape.getOleFormat().save(String.format(destination, i+"", extension));//Here i am getting exception
if(flag==true){
convertWordToPdf(destination,fileName+""+i+"."+extension,convertedFileNames,docconverter);
}
}

catch(Exception e){
e.printStackTrace();
}

}
}

Below is the excpetion message:
C:\Temp\SinglePDF\Standalone\Output\2012-07-06 17-52-36-163 (Access is denied.)
Note the the file without embedded objects are saved to same extenstion mentioned above without any issues.

Hi Anand,

Thanks for your inquiry. Could you please attach your input Word document, containing your embedded objects, here for testing? I will investigate the issue on my side and provide you more information.

Best Regards,