Current filter:
                                You should refresh the page.
                                • Mariya (DevExpress Support) 07.24.2019

                                  Hello Christian,
                                  Yes, it's possible. Please refer to the How to use images when implementing the mail-merge functionality example describing how embed images stored in a database into a document.
                                  Should you have any questions or need further assistance, please do not hesitate to contact me.

                                • Customer90938 07.24.2019

                                  Ok, thank you so far.

                                  The example i posted Shows, how to save a picture to a Folder.

                                  your example loads a Picture from the database.

                                  But i dont know how to achive, that, the Picture i added to the richtexteditor can be stored in the database.

                                  Does it Need an uri? The example you showed me has a GetStream function. But to save Pictures to the database, i Need a setstream, do i?

                                • Mariya (DevExpress Support) 07.24.2019

                                  Do I correctly understand it that you want to retrieve all images from a specific document and save them to the database? If so, you can iterate through the RichEditDocument.Document.Images collection and call the DocumentImage.Image.GetImageBytes method to obtain image bytes and save this data to the database.
                                  If this is not what you are looking for, please describe your scenario in greater detail.

                                • Customer90938 07.24.2019

                                  Like in this example:

                                  https://www.devexpress.com/Support/Center/Question/Details/T451309/external-image-reference-in-documents

                                  if you add a Picture to the document, the Picture should not be included in the text itself when it is stored in the database

                                  but instead of saving the Picture in a windows Folder, the Image should be stored in a database

                                  when you open the document again, the Image should be loaded from the database (in the example (T451309) the Image is loaded from the file.

                                  as far as i can see, in the Event richEditControl_CalculateDocumentVariable, the variable "code" Needs to be a path to an Image file in a Windows Folder

                                  [C#]
                                  string code = String.Format("INCLUDEPICTURE \"{0}\" \\d", richEditControl.Document.CustomProperties[e.VariableName]); Field field = document.Fields.Create(document.Range.Start, code); //update the IncludePicture field to replace the field result with an actual image document.Fields.Update();

                                  can it be a datasource, too?

                                • Customer90938 07.25.2019

                                  So what i want to do is:

                                  insert a picture (e.g. from C:).

                                  After closing the document, the rtftext will be saved into the database

                                  but the picture should be saved in an other database

                                  so, while closing the document, the picture should be converted having these "includepicture" "dbimg" tags and so on

                                  when you open the document again, the Pictures should be loaded from the database and displayed correctly

                                  i know that i have to use the includepicture, mergefield mechanism

                                  but i find no way how to do that.

                                  would you be so kind and provide a small example please

                                1 Solution

                                Creation Date Importance Sort by

                                Thank you for the clarification. Your task is now clear.
                                You are right. You need to obtain all document images before exporting a document to RTF, save these images to the database table, remove document images, and insert IncludePicture fields instead. The only thing is that it isn't necessary to create nesting MergeFields if your document isn't a mail-merge template, and you do not have plans to perform mail-merge. You can write the IncludePicture field's code with a custom image URI (referring to a database image) as follows:
                                "IncludePicture "dbimg://PictureID" "
                                The "PictureID" part here is an identifier that allows you to associate a field with the database image. It may be a database record index or GUID written in a different column of the same data record.
                                Later, when you load your document to RichEditControl, the IUriStreamService.GetStream method will be called to obtain the image stream. You need to create a class implementing the IUriStreamProvider interface and define the IUriStreamProvider.GetStream method as required to provide image data for a custom URI.
                                Please check how IUriStreamProvider is implemented in the example I mentioned in one of my previous comments - ImageStreamProvider. As you can see, the custom image URI is parsed in the GetStream method, the data row ID is retrieved from the URI and the corresponding image is found in the data source by the ID. You need to do almost the same in your project.
                                Let me know if I can be of more help.

                                [Updated]
                                Note that the IncludePicture field doesn't preserve the custom image size. If you want to preserve this option, I recommend you avoid using the IncludePicture field and insert images into document bookmarks or use the DocVariable field.
                                When you export a document to RTF, you can collect required information about images (the DocumentImage.Size property or the DocumentImage.ScaleX and DocumentImage.ScaleY properties) and save this data to the database with your images. If your document contains floating pictures, iterate through the SubDocument.Shapes collection and retrieve the shape-related information (text wrapping, alignment, the relative position, etc.) using the Shape class properties and also save this information to the database. Then, remove the original image and insert a bookmark or DocVariable field instead. When you later open this document in RichEditControl, you will need to insert all database images into the corresponding bookmarks and restore image options in the DocumentLoaded event handler. If you decide to use DocVariables instead of bookmarks, you can insert images with required options using the CalculateDocumentVariable event.

                                Show all comments
                                • Customer90938 07.25.2019

                                  I have an example project attached.

                                  There i remove the image and add an includepicture field.

                                  the picture should be loaded from the folder not the databse.

                                  but the getstream method does not get called (i think the includepicture Code is wrong)

                                  also: how can i save the size of the removed Image, that it gets the same size after loading again.

                                • Mariya (DevExpress Support) 07.25.2019

                                  The GetStream method isn't executed because you locked the IncludePicture field in the FormClosing event handler:

                                  [C#]
                                  field.Locked = true;

                                  Note that you can set the RichEditControl.Options.Fields.UpdateLockedFields property to UpdateLockedFields.Always. In this case, locked fields will be updated after loading a document to RichEditControl. However, it isn't clear why you lock these fields. Since you wrote the \d switch in the field code, the image will not be saved in a document. Moreover, if you specified the custom Uri, other tools (for example, Microsoft Word) will not be able to update this field.

                                  As for the picture size, the IncludePicture field doesn't provide the capability to specify the size that should be applied to the image after retrieving it. The image will be displayed with its original size. The only option here is to change the size of the image saved to the database.

                                  You may also consider using the DocVariable fields. Please check my last comments in the External image reference in documents ticket describing how to use DocVariables in such a scenario.

                                • Customer90938 07.30.2019

                                  Hi Mariya,

                                  thank you very much, that helped.

                                  Can i Change the Picture size programmatically after the Picture is loaded?

                                  I tried to do a loop of all Pictures and Change the size, but it didn't work.

                                  [C#]
                                  Document document = richEditControl.Document; int imageCount = document.Images.Count; for (int i = 0; i < imageCount; i++) { DocumentImage image = document.Images[i]; image.ScaleX = (float)imgsp.imgDataList[i].scaleX; image.ScaleY = (float)imgsp.imgDataList[i].scaleY; }

                                  an other Question:

                                  if i have floating  text or an other layout on the includepicture, this does not get restored, too. E.g. before i close the document, the text is Right to the Picture. after load, the text is below the Picture.

                                • Mariya (DevExpress Support) 07.31.2019

                                  If you call the Update method for the document fields collection after resizing document images, the IncludePicture fields will restore pictures with their original sizes. As I mentioned in my previous comment, the IncludePicture field inserts the picture as is and doesn't allow you to preserve source image's layout options (scaling or text wrapping).

                                  If you want to preserve these options, I recommend you avoid using the IncludePicture field and insert images into document bookmarks or use the DocVariable field.
                                  When you export a document to RTF, you can collect required information about images (the DocumentImage.Size property or the DocumentImage.ScaleX and DocumentImage.ScaleY properties) and save this data to the database with your images. If your document contains floating pictures, iterate through the SubDocument.Shapes collection and retrieve the shape-related information (text wrapping, alignment, the relative position, etc.) using the Shape class properties and also save this information to the database. Then, remove the original image and insert a bookmark or DocVariable field instead. When you later open this document in RichEditControl, you will need to insert all database images into the corresponding bookmarks and restore image options in the DocumentLoaded event handler. If you decide to use DocVariables instead of bookmarks, you can insert images with required options using the CalculateDocumentVariable event.

                                • Customer90938 08.01.2019

                                  Alright. I will try that. Thank you.

                                • Mariya (DevExpress Support) 08.01.2019

                                  You are welcome.

                                • Customer90938 08.05.2019

                                  Hey Mariya,

                                  one more Question: after i replaced the bookmarks with the Images, the documentloaded Event is called.

                                  But how excatly can i set the shapes for the Pictures there.

                                  the shapes in Document.Shapes are readonly.

                                  Best regards,
                                  Christian

                                • Ingvar (DevExpress Support) 08.05.2019

                                  Hi Christian,

                                  SubDocument.Shapes is a collection containing Shape objects. You need to iterate through this collection and set properties for each Shape separately. For example:

                                  [C#]
                                  foreach (Shape shape in document.Shapes) { shape.ScaleX = ... ... }
                                • Customer90938 08.05.2019

                                  If there is a shape for the Picture, i get it this way in the Closing event:

                                  [C#]
                                  foreach (Shape shape in document.Shapes.Get(dr))

                                  but in the document loaded event, the layout / shape for the picture is not set yet. i need to set it.

                                  so the count of shapes in document.shapes is 0

                                  i need to create a shape for the picture programmatically.

                                  but how?

                                • Ingvar (DevExpress Support) 08.06.2019

                                  Hi,

                                  Please review the Create a shape topic that describes how to create floating pictures in code.