Free Support Forum - aspose.com

Bullets are not displayed for ListFormat.List when use DocumentBuilder InsertHtmll

Hello,

We have Aspose.Words 5.1.0.0 .

When trying to display a bulleted list using DocumentBuilder's InsertHtml method - bullets are not displayed (see Geographic Regions section at the left menu of the attached pdf).

I laso attached a Word template, a full page samle code, and a piece of code for Geographic Regions part only.

Please advise. Thank you.

Hi

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your inquiry. Documentbuilder.InsertHtml method does not insert paragraph break, so in output you have only one paragraph. To resolve the problem you can use code like the following:

Document doc = new Document();

DocumentBuilder builder = new DocumentBuilder(doc);

builder.ListFormat.List = doc.Lists.Add(ListTemplate.BulletDefault);

builder.ListFormat.ListLevelNumber = 0;

builder.ListFormat.ListLevel.TabPosition = 2;

builder.ListFormat.ListLevel.TextPosition = 12;

builder.ParagraphFormat.LeftIndent = 0;

string[] split1 = { "(Impact in additional regions has not been identified or ruled out at the time of this posting)", " Europe", " U.K." };

foreach (string s in split1)

{

if (s.Length != 0)

{

builder.InsertHtml(s.Trim());

builder.Writeln();

}

}

// This is how to stop list formatting.

builder.ListFormat.List = null;

doc.Save(@"Test001\out.doc");

doc.SaveToPdf(@"Test001\out.pdf");

I attached output documents generated using the latest version of Aspose.Words.

You can download the latest version of Aspose.Words (7.0.0) from here:

http://www.aspose.com/community/files/51/file-format-components/aspose.words-for-.net-and-java/category1188.aspx

Hope this helps.

Best regards,

OK, we upgraded to the latest Aspose.Words and Aspose.Pdf, and now the old piece of code, which worked before, has stopped working:

MemoryStream stream = new MemoryStream();

doc.Save(stream, SaveFormat.AsposePdf);

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />and throwing an exception

"Image file cannot be written to disk. When saving the document to a stream either PdfExportImagesFolder should be specified or custom streams should be provided via PdfExportImageSaving event handler. Please see documentation for details."

I am attaching a full version of the problematic file, please let me know if I need to provide more info.

Hi

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your inquiry. You should just specify folder where images should be saved (You can use SaveOption.PdfExportImagesFolder). Please see the following link for more information:

http://www.aspose.com/documentation/.net-components/aspose.words-for-.net-and-java/aspose.words.saveoptions.pdfexportimagesfolder.html

Also, the latest version of Aspose.Words supports direct conversion to PDF (without saving into intermediate format and using Aspose.Pdf). Please see the following link for more information:

http://www.aspose.com/documentation/.net-components/aspose.words-for-.net-and-java/howto-convert-a-document-to-pdf.html

Best regards,

Thank you for your suggestions. I tried a code below, and it doesn't produce a corrupt pdf anymore, but image is still not displayed in the pdf converted from Aspose.Words.Document doc, containing an image, when trying to save image into stream. When use a commented line of code to save an image to disk - it shows up nicely in the pdf.

Can you suggeest how to to store image in a steam when converting a doc with image to pdf without writing image to a disk?

MemoryStream stream = new MemoryStream();
//doc.SaveOptions.PdfExportImagesFolder = "C:\\Temp";
doc.SaveOptions.PdfExportImageSaving += new ExportImageSavingEventHandler(SaveOptions_PdfExportImageSaving);
doc.Save(stream, SaveFormat.AsposePdf);
stream.Seek(0, SeekOrigin.Begin);

XmlDocument xmlDoc = new XmlDocument();

xmlDoc.Load(stream);

pdf.BindXML(xmlDoc, null);
// do something with pdf
.................

void SaveOptions_PdfExportImageSaving(object sender, ExportImageSavingEventArgs e)
{
e.ImageStream = new MemoryStream();
}

Hi

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your inquiry. The only way to convert Word document to PDF without saving images on disk is using new method of PDF conversion (SaveToPdf method):

http://www.aspose.com/documentation/.net-components/aspose.words-for-.net-and-java/howto-convert-a-document-to-pdf.html

There is no way to convert document to PDF using legacy method (Aspose.Words+Aspose.Pdf) without saving image on disk. So please try using new method.

Best regards,

We have the following process:

1. Load a Word doc with a text and image in the page footer into Aspose.Words document

2. Do some manipulations with Aspose.Words

3. Save Aspose.Words doc to Aspose.Pdf.Pdf (in memory, without saving image or doc to disk)

4. Do something with pdf (also in memory, without saving anything to file system)

5. Display the resulting pdf in browser.

This way worked with Aspose.Words 5.1, and Aspose.Pdf 3.6.
Now we upgraded to Aspose.Words 7, and Aspose.Pdf 4.1, and the same all-in-memory way (including a word doc footer image) doesn't seem to work. Here is a piece of code I'm using, and getting an error
"You are in direct-to-file mode,please use Close() instead of Save()."

Can you, please, let me know, if the way I described above (everything,including images, is in memory, nothing is saved to disk as an intemediate step) is availble for the latest Aspose.Words/Pdf versions?
If it is - how to change the code below to make it work?


// Doc template has text and image in the footer
Document doc = new Aspose.Words.Document("C:\\Temp\\AlertPrintTemplate.doc");
// .... Do something with Aspose.Words doc
MemoryStream stream = new MemoryStream();
int pagecount = doc.PageCount;
doc.SaveToPdf(0, pagecount, stream, null);
stream.Seek(0, SeekOrigin.Begin);
pdf = new Aspose.Pdf.Pdf(stream);
// ... Do something more with pdf
// show pdf in browser
pdf.Save("Alert.pdf", Aspose.Pdf.SaveType.OpenInBrowser, Response);

Hi <?xml:namespace prefix = st1 ns = "urn:schemas:contacts" />Irina,

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your request. This occurs because you use Aspose.Pdf in direct-to-file or direct-to-stream mode. In this mode Aspose.Pdf does not provide some features. Please refer the following link to learn more:

http://www.aspose.com/documentation/.net-components/aspose.pdf-for-.net/aspose.pdf.pdfconstructor2.html

You should discuss this with Aspose.Pdf team.

Best regards.