Join
Sign in
Search Options
Search Everything
Search Formats
Home
Blog
Resources
Forums
About Open XML
More ...
Home
»
Forums
»
Formats
»
DrawingML
»
problem when inserting image, the image does not appear
Re: problem when inserting image, the image does not appear
Formats
Discussions about working with different Open XML Formats
Get this RSS feed
Details
1
Reply
0
Subscribers
Posted
over 2 years ago
Options
Subscribe via RSS
Share this
DrawingML
problem when inserting image, the image does not appear
rated by 0 users
This post has
1 Reply |
0
Followers
HBA
20
Posted by
HBA
on
Wed, Jan 27 2010 4:35 AM
rated by 0 users
Post Points: 20
problem when inserting image, the image does not appear
After the generation when I open the word document the image is blank if I click on restore image it appears .thank you for your help
Public Sub InitDocXML()
AddImagePart("C:\Documents and Settings\haithem\Mes documents\Mes images\Icone_CheckBox_VB.jpg")
SetMainDocumentContent(_MainPart)
End Sub
Public Sub GenererFeuille()
Using (_Doc)
Addimages(_MainPart.GetIdOfPart(_ImagePart))
End Using
End Sub
Public Sub AddImagePart(ByVal fileName As String)
_ImagePart = _MainPart.AddImagePart(ImagePartType.Jpeg)
Dim stream As FileStream = New FileStream(fileName, FileMode.Open)
_ImagePart.FeedData(stream)
End Sub
Public Sub Addimages(ByVal id As String)
Dim nomfich As String = "Icone_CheckBox_VB.jpg"
Dim bitmap As Bitmap = New Bitmap("C:\Documents and Settings\haithem\Mes documents\Mes images\Icone_CheckBox_VB.jpg")
Dim bitmapHeight As Integer = bitmap.Height
Dim bitmapWidth As Integer = bitmap.Width
Dim drawing As Drawing = New Drawing()
Dim inline As wp.Inline = New wp.Inline() With {.DistanceFromTop = 0, .DistanceFromBottom = 0, .DistanceFromLeft = 0, .DistanceFromRight = 0}
Dim extent As wp.Extent = New wp.Extent() With {.Cx = Convert.ToInt64(bitmapWidth) * 10000, .Cy = Convert.ToInt64(bitmapHeight) * 10000}
Dim effectExtent As wp.EffectExtent = New wp.EffectExtent() With {.LeftEdge = 19050L, .TopEdge = 0L, .RightEdge = 9525L, .BottomEdge = 0L}
Dim docProperties As wp.DocProperties = New wp.DocProperties() With {.Id = 1, .Name = Path.GetFileNameWithoutExtension(_ImagePart.Uri.ToString()), .Description = "45vlsdh4.jpg"}
Dim nonVisualGraphicFrameDrawingProperties As wp.NonVisualGraphicFrameDrawingProperties = New wp.NonVisualGraphicFrameDrawingProperties()
Dim graphicFrameLocks As a.GraphicFrameLocks = New a.GraphicFrameLocks() With {.NoChangeAspect = True}
nonVisualGraphicFrameDrawingProperties.Append(graphicFrameLocks)
Dim graphic As a.Graphic = New a.Graphic()
Dim graphicData As a.GraphicData = New a.GraphicData() With {.Uri = "http://schemas.openxmlformats.org/drawingml/2006/picture"}
Dim picture As pic.Picture = New pic.Picture()
Dim nonVisualPictureProperties As pic.NonVisualPictureProperties = New pic.NonVisualPictureProperties()
Dim nonVisualDrawingProperties As pic.NonVisualDrawingProperties = New pic.NonVisualDrawingProperties() With {.Id = 0, .Name = "45vlsdh4.jpg"}
Dim nonVisualPictureDrawingProperties As pic.NonVisualPictureDrawingProperties = New pic.NonVisualPictureDrawingProperties()
nonVisualPictureProperties.Append(nonVisualDrawingProperties)
nonVisualPictureProperties.Append(nonVisualPictureDrawingProperties)
Dim blipFill As pic.BlipFill = New pic.BlipFill()
Dim blip As a.Blip = New a.Blip() With {.Embed = id, .CompressionState = a.BlipCompressionValues.Print}
Dim stretch As a.Stretch = New a.Stretch()
Dim fillRectangle As a.FillRectangle = New a.FillRectangle()
stretch.Append(fillRectangle)
blipFill.Append(blip)
blipFill.Append(stretch)
Dim shapeProperties As pic.ShapeProperties = New pic.ShapeProperties()
Dim transform2D As a.Transform2D = New a.Transform2D()
Dim offset As a.Offset = New a.Offset() With {.X = 0L, .Y = 0L}
Dim extents As a.Extents = New a.Extents() With {.Cx = Convert.ToInt64(bitmapWidth) * 10000, .Cy = Convert.ToInt64(bitmapHeight) * 10000}
transform2D.Append(offset)
transform2D.Append(extents)
Dim presetGeometry As a.PresetGeometry = New a.PresetGeometry() With {.Preset = a.ShapeTypeValues.Rectangle}
Dim adjustValueList As a.AdjustValueList = New a.AdjustValueList()
presetGeometry.Append(adjustValueList)
shapeProperties.Append(transform2D)
picture.Append(nonVisualPictureProperties)
picture.Append(blipFill)
picture.Append(shapeProperties)
graphicData.Append(picture)
graphic.Append(graphicData)
inline.Append(extent)
inline.Append(effectExtent)
inline.Append(docProperties)
inline.Append(nonVisualGraphicFrameDrawingProperties)
inline.Append(graphic)
drawing.Append(inline)
Dim paragraph As Paragraph = New Paragraph()
Dim run As Run = New Run()
Dim runProperties As RunProperties = New RunProperties()
Dim noProof As NoProof = New NoProof()
Dim languages As Languages = New Languages() With {.EastAsia = "fr-FR"}
runProperties.Append(noProof)
runProperties.Append(languages)
run.Append(runProperties)
run.Append(drawing)
paragraph.Append(run)
_Doc.MainDocumentPart.Document.Body.Append(paragraph)
_Doc.MainDocumentPart.Document.Save()
End Sub
Macilquham
185
Posted by
Macilquham
on
Tue, Feb 2 2010 5:22 PM
rated by 0 users
Post Points: 5
Re: problem when inserting image, the image does not appear
Hi HBA,
I would take a copy of the document open the original click restore and save. Then use a file compare tool comparing the original file before fixing and the fixed file to see what markup has been added to your file to get it going. This should help in debugging. You could also use the reflector tool to see how it was generated.
Cheers,
Macilquham
Page 1 of 1 (2 items)