Hi,
Is there a way to add hyperlinks and images to a DocxDocuments?
For hyperlinks:
I am populating a DocxDocument form a string which is a string from a email body.
The string may have hyplinks in the string. I am using a regex to find the hypelink text and want to replace it with a hyperlink.
For images
I am trying to do something similar with in line images. The string will have a token signifying the image name. I would like to be able to replace the Token with image.
After this I am converting the DocxDocument to a pdf file.
Thanks
Adding HyperLink and images to DocxDocument
Moderator: Alex
-
- Posts: 85
- Joined: Fri Jan 24, 2020 3:37 am
-
- Site Admin
- Posts: 2397
- Joined: Thu Jul 10, 2008 2:21 pm
Re: Adding HyperLink and images to DocxDocument
Hi Harlan,
Current version does not allow to add hyperlink to an existing DOCX document and we will add ability to do this in next minor release. I think functionality will be available in 2 weeks.
Current version allows to add/change/delete image in existing DOCX document. Please see how to set image in DOCX document in the last example here: https://www.vintasoft.com/docs/vsimagin ... ntent.html. Let me know if you will have any question or problem.
Best regards, Alexander
Current version does not allow to add hyperlink to an existing DOCX document and we will add ability to do this in next minor release. I think functionality will be available in 2 weeks.
Current version allows to add/change/delete image in existing DOCX document. Please see how to set image in DOCX document in the last example here: https://www.vintasoft.com/docs/vsimagin ... ntent.html. Let me know if you will have any question or problem.
Best regards, Alexander
-
- Posts: 85
- Joined: Fri Jan 24, 2020 3:37 am
Re: Adding HyperLink and images to DocxDocument
I tried the method of adding images to DocxDocuments according to the example you pointed me to.
The issue I have is that There already has to be an existing image in the DocxDocument to replace with the image I am trying to add.
I could not find a way of actually adding an image to the docxdocument.
The issue I have is that There already has to be an existing image in the DocxDocument to replace with the image I am trying to add.
I could not find a way of actually adding an image to the docxdocument.
-
- Site Admin
- Posts: 2397
- Joined: Thu Jul 10, 2008 2:21 pm
Re: Adding HyperLink and images to DocxDocument
The DocxDocumentEditor class uses document template and creates new document from template.IntegraHarlan wrote: Wed Jun 30, 2021 7:29 pm I tried the method of adding images to DocxDocuments according to the example you pointed me to.
The issue I have is that There already has to be an existing image in the DocxDocument to replace with the image I am trying to add.
I could not find a way of actually adding an image to the docxdocument.
If you want to add image to DOCX document, you need to do the following steps:
- Using MS Word:
- Add image object to the document template - this image object must have all necessary formatting (inline, anchor, size, etc) and will be used as a template for image in result document. You can add this object and the end of template document and delete object in the result document.
- In the code:
- Get template image object (instance of OpenXmlDocumentImage class) using DocxDocumentEditor.Images[X] property.
- Create clone of template image object using OpenXmlDocumentImage.Clone method.
- Set image (bitmap) in image object using OpenXmlDocumentImage.SetImage method.
- Insert clone of template image object (instance of OpenXmlDocumentImage class) to the desired position in result document.
- Delete template image object from result document if template image object is not necessary in result document.
-
- Site Admin
- Posts: 2397
- Joined: Thu Jul 10, 2008 2:21 pm
Re: Adding HyperLink and images to DocxDocument
Hi Harlan,
Best regards, Alexander
In VintaSoft Imaging .NET SDK 10.1.2.1 we have added the DocxDocumentEditor.SetHyperlink method, which allows to set the hyperlink for specified text content. Please use this method and let me know if you will have any question or problem.Is there a way to add hyperlinks and images to a DocxDocuments?
Best regards, Alexander