Free Support Forum - aspose.com

Classic ASP InsertImage doesn't work?

I load up a template doc and everything works fine, I can write text,
create tables…everything except for Builder.InsertImage. The exact
code I have
is:



Builder.InsertImage “C:\Inetpub\wwwroot\image001.jpg”



The path and filename are all correct so why am I getting an error?

Solved. Change to:



Builder.InsertImage_2 “C:\Inetpub\wwwroot\image001.jpg”



Now another question, why is it that when I insert an image, the image doesn’t start from where I left off?



Example 1 (This is what I want it to look like):

########################################################################

This is a sample document…This is a sample document…This is a sample document…This is a sample document…This is a sample document…This is a sample document…This is a sample document…

|----------------------------------------------------------------------------------------------|

|

|

|
{IMAGE}

   |<br>

|

|

|

|

|----------------------------------------------------------------------------------------------|



This is a sample document…This is a sample document…This is a sample document…This is a sample document…This is a sample document…This is a sample document…This is a sample document…This is a sample document…



########################################################################

Example 2 (This is what actually happens):



|----------------------------------------------------------------------------------------------|

This is a sample document…This is a sample document…This is a sample document…This is a sample document…This is a sample document…This is a sample document…This
is a sample
document…

|
|
{IMAGE}

|

|----------------------------------------------------------------------------------------------|



This is a sample document…This is a sample document…This is a sample document…This is a sample document…This is a sample document…This is a sample document…This is a sample document…This is a sample document…



#########################################################################


In example 2, the
{IMAGE} looks like it is behind the text, so to fix it, I
have to do FORMAT PICTURE > LAYOUT > SQUARE OR TIGHT and then
drag the picture AFTER the last line of “This is a sample document…”
to make it look like example 1.



Is there something I can configure in the design word template doc? Or
some parameters I can send to builder.insertimage_2 to achieve what I
want?

To achieve what you want you need first to position DocumentBuilder exactly before the corresponding Run or Paragraph using DocumentBuilder.MoveTo method.

Then you need to use the DocumentBuilder.InsertImage(Image, RelativeHorizontalPosition, Double, RelativeVerticalPosition, Double, Double, Double, WrapType, WrapSide, Boolean, PictureFormat) overload method. Set WrapType and WrapSide to control image alignment and text wrapping.

So this doesn’t work?



#1 Builder.Writeln " " '<---- First line of word doc

#2 Builder.Writeln " "

#3 Builder.Writeln " "

#4 Builder.Writeln " "

#5 Builder.Writeln " "

#6 Builder.InsertImage_2 “image.jpg” '<-- Do I need to use
Builder.MoveTo method if I’m

            already at the line where I want to

insert the image?



From my own observation of InsertImage_2, it seems to place the END of
the image at the 6th line (see Figure 1). Then it extends from the 6th
line towards the 1st line which is kind of awkward. It should be the
other way
around since most people would be Writln’ing text until they
InsertImage_2. It should
extend from the starting point and extend downwards, not upwards.
Figure 2 is the
solution to how it should work from my perspective. If it’s all a
matter of writing the correct parameters for
DocumentBuilder.InsertImage(Image, RelativeHorizontalPosition, Double,
RelativeVerticalPosition, Double, Double, Double, WrapType, WrapSide,
Boolean, PictureFormat), then please tell me what are the correct
parameters to do as Figure 2. Thank you.



(Figure 1) Given that the height of the image is exactly 3 lines tall.



#1 Dear Joe Doe,

#2 I am including a picture in this letter an image of the construction site

#3 for you to approve whether the cleaning company did it’s job of cleaning up the site.

#4 |----BEGIN----| '<— What if I have text here?

#5 |----image----| '<— What if I have text here?

#6 |----END-----|





(Figure 2) Given that the height of the image is exactly 3 lines tall.


#1 Dear Joe Doe,

#2 I am including a picture in this letter an image of the construction site

#3 for you to approve whether the cleaning company did it’s job of cleaning up the site.

#4 We are working on a new program to speed up the construction site workflow

#5 by using automated document generators. I hope you will find our effeciency increase.

#6 |----BEGIN----|

#7 |----image----|

#8 |----END-----|

|

| '<-- Anything below is automatically pushed down (Since the document is always generated from

| ’ scratch from top to bottom this doesn’t really matter)
V