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

Free Support Forum - aspose.com

Document.Print not printing INCLUDEPICTURE graphics

We have documents that have an INCLUDEPICTURE field. The image filename is provided by another field so that it looks something like this: {INCLUDEPICTURE {MERGEFIELD }}. Basically the filename for INCLUDEPICTURE is provided by another mergefield. These documents are created outside of Aspose.Words, but we use Aspose to print. The MERGEFIELD that provides the filename has been resolved and contains the correct result at the time of printing. The code looks something like this:

        Aspose.Words.Document doc;
        var documentBytes = Encoding.UTF8.GetBytes(rtfDocument);
        using (var docStream = new MemoryStream(documentBytes))
        {
            doc = new Aspose.Words.Document(docStream, new LoadOptions { PreserveIncludePictureField = true });
        }

        var printSettings = new PrinterSettings();
        printSettings.PrinterName = printerName;
        printSettings.Copies = (short)copies;

        doc.Print(printSettings);

The document, if viewed in Word will show the image in the IncludePicture field. If printed, the image does not show. I have tried this with and without the PreserveIncludePictureField option.

I can provide sample documents, but the setup is pretty straightforward as I have described.

Thanks.

@BlakeMChristensen,

Thanks for your inquriy. Please share your source documents here. It will help us to investigate your issue exactly and address it accordingly.

Best Regards,

ImageField.zip (8.2 KB)
The attached zip has two files: ImgWithField.rtf and logo.jpg. Extract both into the same folder. Opening the ImgWithField.rtf in Word you can see the logo that is a result of the IncludePicture field as described above. When printed using the ‘Print’ command, the logo does not print.

Thanks.

@BlakeMChristensen

Thanks for sharing the source documents. We have tested the scenario and noticed the reported issue. We have logged a ticket WORDSNET-15560 in our issue tracking system for further investigation and rectification. We will notify you as soon as it is resolved.

We are sorry for the inconvenience.

Best Regards,

@BlakeMChristensen

Thanks for your patience. Our product team has investigated WORDSNET-15560 issue and found that it is not a bug. The sample RTF document contains the INCLUDEPICTURE field with non embedded result and relative path “logo.jpg”. You should specify the LoadOptions.BaseUri property with path where the referenced image is located and use the Document(Stream, LoadOptions) constructor. It will help you to accomplish the task.

Please feel free to contact us for any further assistance.

Best Regards.

Thanks for the reply. Based on your comment you seem to be saying this should work if the complete logo path were specified. I tried that first by adding the complete path. Attached is a sample. Extract that into c:\temp and try. As before, you can see the image in Word, but when printed in Aspose it does not work.ImageField2.zip (8.2 KB)

I also tried your suggestion of adding the BaseUri option and setting it to the folder which contained the image (c:\temp in this case). The image still does not print. The changed code looks like this:

            var uri = new System.Uri("c:\\temp");
            var converted = uri.AbsoluteUri;
            result = new Aspose.Words.Document(docStream,
                new LoadOptions {PreserveIncludePictureField = true, BaseUri = converted});

If you could provide a code snippet that correctly prints the attached document I would appreciate it.

Thanks.

@BlakeMChristensen

Thanks for your feedback. We are coordinating with our product team and will update you as soon as we get a feedback.

Best Regards,

@BlakeMChristensen

Thanks for your patience. We have tested the scenario using following code using Aspose.Words for .NET 17.7 and unable to notice any issue. However, if the issue persists at your end then please create a sample console project, ZIP and share here. We will further investigate it and will guide you accordingly.IncludePictureField_print.zip (59.8 KB)

MemoryStream stream = new MemoryStream(File.ReadAllBytes("D:\\Downloads\\ImageField\\ImgWithField.rtf"));
Aspose.Words.LoadOptions option = new Aspose.Words.LoadOptions();
option.BaseUri = "D:\\Downloads\\ImageField\\";
Document doc = new Document(stream,option);


int copies = 1;
var printSettings = new PrinterSettings();
printSettings.PrinterName = "Microsoft XPS Document Writer";
printSettings.Copies = (short)copies;

doc.Print(printSettings);

Best Regards,

I am unable to download the attached zip. Can you repost it?

Thanks.

@BlakeMChristensen

Thanks for your feedback. Please double check whether your are properly signed in Aspose site. However, for your reference, I have uploaded the file to google drive as well.

Best Regards,

The issues you have found earlier (filed as ) have been fixed in this update. This message was posted using BugNotificationTool from Downloads module by MuzammilKhan