Document SaveOptions PdfExportImageSaving

HI,
I am trying to save a word document into a stream as an AsposePdf. The document contains images. The save is failing. I can set the export folder to the temp folder and it works fine but I’d rather not have the disk filling up with images. I’d like to do it with streams but I can’t seem to get it to work. Using the code below the event fires and the ImageStream is set but none of the image appear in the final pdf

MemoryStream docStream = new MemoryStream();
MemoryStream openStream = new MemoryStream(Encoding.UTF8.GetBytes(finalOutput));
Document wordDocument = new Document(openStream, null, loadFormat, null);
wordDocument.SaveOptions.PdfExportImageSaving += new ExportImageSavingEventHandler(SaveOptions_PdfExportImageSaving);
wordDocument.Save(docStream, saveFormat);
void SaveOptions_PdfExportImageSaving(object sender, ExportImageSavingEventArgs e)
{
    // WHAT SHOULD GO IN HERE????
    e.ImageStream = new MemoryStream();
}

Does anyone have any idea what goes in the event handler to get the image to appear in the document?
Any help is appreciated.
Best regards
David

Hi

Thanks for your request. Currently Aspose.Words supported two ways of PDF conversion: direct conversion (without using Aspose.Pdf) and legacy conversion Aspose.Words+Aspose.Pdf. See the following link for more information:
https://docs.aspose.com/words/net/convert-a-document-to-pdf/
So, you can try using new method to convert your document to PDF. Here is the code:

Document doc = new Document("in.doc");
doc.SaveToPdf("out.pdf");

Best regards.

Hi,
unfortunately this isn’t answered for me because I have the same problem as David. Could you please provide a source code example?
The reason I need to use this instead of SaveToPdf is that SaveToPdf doesn’t allow me to find out which fonts were missing and got thus substituted (or is there any way to do this?). And if the document is encrpyted (by applying security settings) the PDF properties show an unknown glyph in front of each text property.
Thanks for your help.
Br, Martin

Hi

Thanks for your inquiry. Unfortunately, there is no way to convert to PDF via Aspose.Pdf without saving images on disk. So you should specify SaveOptions.PdfExportImagesFolder.
https://reference.aspose.com/words/net/aspose.words.saving/pdfsaveoptions/
Could you please attach your Word document for testing? I would like to reproduce the problem with PDF properties.
Also, please explain what you mean when say “find out which fonts were missing”. Do you mean Pdf. DefaultFontName?
Best regards.

Hi Alexey,
thanks for your response.
What’s the purpose of providing a custom stream to PdfExportImageSaving then?
I’d like to provide a feedback to the user about Fonts that got replaced during the conversion using a substitute Font (it is a server application).
The doc is attached.
Br, Martin

Hi

Thank you for additional information. I cannot reproduce the problem with text properties. Could you please show me what the problem is, maybe screenshot?
Regarding PdfExportImageSaving, using this event you can save images in custom location, rename images. This event was designed for future use, when Aspose.Pdf supports loading images from stream.
And how can you detect missed fonts using Aspose.Pdf?
Best regards.

Hi Alexey,
> Could you please show me what the problem is, maybe screenshot?
I attached the screenshot.
> This event was designed for future use, when Aspose.Pdf supports loading images from stream.
Would be a nice hint in the documentation, wouldn’t it?
> And how can you detect missed fonts using Aspose.Pdf?
Ah, that’s tricky (and slow). Using Aspose.Pdf there’s a property called “IsFontNotFoundExceptionThrown”. Using this property makes “Save” throw an exception as soon as an unknown font is found. Then the exception can be analyzed for these fonts. Of course we have to save the document again with setting this property to “false” to get the converted document.
This is ugly, slow and IMO not very intuitive. Therefore I hoped that the new rendering mechanism provides something like a “conversion report”.
Br, Martin

Hi

Thanks for your inquiry. I cannot reproduce the problem with text properties on my side. Attached is my screenshot.
I think we should consider the ability to provide the event that is fired when Aspos.Words cannot find the font. I created the issue #8155 in our defect database. We will further investigate the problem and provide you more information.
Best regards.

Anyway, thanks for your help so far.
I also attached my result pdf, maybe you can analyze the pdf itself.
Thanks for creating the issue #8155, this would be really helpful.
Br and have a nice weekend, Martin

Hi Martin,

I investigated the problem a bit. It seems the problem occurs only if open your document using Adobe Professional. The problem does not occur when I open your document using Adobe Acrobat Reader.
Anyway, I cannot create the PDF that has the same problem on my side. Unfortunately, I have no idea why this might occur on your side.
Best regards.

The issues you have found earlier (filed as WORDSNET-2217) have been fixed in this .NET update and this Java update.

This message was posted using Notification2Forum from Downloads module by aspose.notifier.
(25)