What's wrong with this code?

F

Fritz Switzer

In the code snippet below, I'm getting an exception "Outlines do not have
explicit heights" using the OneNote ImporterAPI. I'd like to assign the
"test.jpg" object a size of 6 inches by 6 inches when importing to OneNote
the Position settings work ok.

Can anyone provide the syntax for using the Size for Height and Width
properties in C# ?

OutlineObject outline2 = new OutlineObject();

//Size mySize = new System.Drawing.Size(6,6);

//outline2.Height.InInches(mySize);

outline2.Height= new Microsoft.Office.OneNote.Size(6);

outline2.Width= new Microsoft.Office.OneNote.Size(6);

// Exception thrown "Outlines do not have explicit heights"


outline2.Position.X=10;

outline2.Position.Y=100;


outline2.AddContent(new ImageContent(new FileInfo("test.jpg")));

p.AddObject(outline2);


Thanks in advance,

Fritz
 
F

Fritz Switzer

Thanks,

Do you have a short C# snippet that demonstrates how this would be done?


Fritz
 
D

Daniel Danilin

Page page = new Page("Test.one", "Testing");
OutlineObject outline = new OutlineObject();
outline.Position = new Position(10, 10);
ImageContent ímage= new ImageContent(new FileInfo("image.jpg");
image.Size = new Size(6, 6);
outline.AddContent(image);
page.Add(outline);
page.Commit();
page.NavigateTo();
 
F

Fritz Switzer

Daniel,

Thanks for your help, but I'm getting the following compile error.

'Microsoft.Office.OneNote.ImageContent' does not contain a definition for
'Size'

If I comment out the "image.Size = new Size(6,6); everything runs okay. So
I think my assembly is okay. Any ideas?

Danke,

Fritz
 
F

Fritz Switzer

Daniel,

Here's my code. I'm not seeing any Height or Width members for
ImageContent. I tried switching to an ImageObject, but couldn't get the
page.Add to accept that.

Does your code compile and change the size of the graphic image (the "i" in
image is accented, btw) when imported to OneNote?

Page page = new Page("Test.one", "Test");

OutlineObject outline = new OutlineObject();

outline.Position = new Position(10,10);

ImageContent image = new ImageContent(new FileInfo("test.jpg"));

//image.Height = new Microsoft.Office.OneNote.Size(6.00);

//image.Width = new Microsoft.Office.OneNote.Size(6.00);


outline.AddContent(image);

page.AddObject(outline);


page.Commit();

page.NavigateTo();


Sorry to be a pest, Danke.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top