We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Value of type 'Byte' cannot be converted to 'Aspose.Slides.Pptx.NullableBool'

I’m converting from .ppt file format to .pptx (Aspose7) and have run into the following issue with the Portion format.

For Each port As PortionEx In parash1.Portions
	port.PortionFormat.FontItalic = NullableBool.True
	port.Text = BioTitle
Next port
Visual Studio 2003 is complaining that the Byte format of the FontItalic Property cannot be converted to the NullableBool Enum type. I've tried various casting schemes:

CType(SByte.Parse(1), NullableBool)
CType(CType(1, SByte), NullableBool)
CType(Byte.Parse(1), NullableBool)
CType(NullableBool.True, SByte)
I'm 1000% sure that NullableBool is coming from the Pptx namespace as well.

Thanks.

Hi
Zachary,


I have tried to understand the issue shared by you but it will be really appreciable if you may share the sample code project with us. I have used Aspose.Slides for .NET 6.1.0 and have tested the property in Visual Studio 2005. I am able to set it. I have used the code snippet shared over this document link. I am sorry there is no version 7 currently rolled out for Aspose.Slides for .NET. Can you please share some more details about the issue. For further assurance please try using Aspose.Slides.Pptx.NullableBool statement completely in your application.

Many Thanks,

Well, as I mentioned in my previous post, I am using Visual Studio 2003 which may have a different approach to types than you are using in your .NET 1.1 .dll. I have put your code in my project and the result are the following errors:


'Public Overrides Property LatinFont() As Aspose.Slides.Pptx.FontDataEx' is obsolete: 'Use PortionFormat to set properties or CreateParagraphFormatData() to obtain them.'
'Public Overrides Property LatinFont() As Aspose.Slides.Pptx.FontDataEx' is obsolete: 'Use PortionFormat to set properties or CreateParagraphFormatData() to obtain them.'
'Public Overrides Property FontBold() As Aspose.Slides.Pptx.NullableBool' is obsolete: 'Use PortionFormat to set properties or CreateParagraphFormatData() to obtain them.'
Value of type 'Byte' cannot be converted to 'Aspose.Slides.Pptx.NullableBool'.
'Public Overrides Property FontBold() As Aspose.Slides.Pptx.NullableBool' is obsolete: 'Use PortionFormat to set properties or CreateParagraphFormatData() to obtain them.'
Value of type 'Byte' cannot be converted to 'Aspose.Slides.Pptx.NullableBool'.
'Public Overrides Property FontItalic() As Aspose.Slides.Pptx.NullableBool' is obsolete: 'Use PortionFormat to set properties or CreateParagraphFormatData() to obtain them.'
Value of type 'Byte' cannot be converted to 'Aspose.Slides.Pptx.NullableBool'.
'Public Overrides Property FontItalic() As Aspose.Slides.Pptx.NullableBool' is obsolete: 'Use PortionFormat to set properties or CreateParagraphFormatData() to obtain them.'
Value of type 'Byte' cannot be converted to 'Aspose.Slides.Pptx.NullableBool'.
Value of type 'Byte' cannot be converted to 'Aspose.Slides.Pptx.FillTypeEx'.
Value of type 'Byte' cannot be converted to 'Aspose.Slides.Pptx.FillTypeEx'.
Also mentioned in my previous post, I am certain that the NullableBool being referenced is from the Pptx namespace.

Also, the date modified on my Slides .dll file is 3/24/2012.

Hi Zachary,


I have modified the code snippet in the document link shared before. I am sorry that I don’t have Visual Studio 2003 environment to verify the dll and I may need some to set up the environment for this. I recommend you to please try setting the value as (Byte)0 or (Byte)1 in your application for FontItalic. Meanwhile, I will also work over your requirement. But, I will appreciate a working project code from your end to verify things on my end.

Many Thanks,

As I mentioned in my original post, casting an integer to a byte does not solve the issue.


Dim i As Int32
For i = 0 To newPPT.Slides.Count
	Dim slide As SlideEx = newPPT.Slides(i)
	If Not slide Is Nothing Then
		Dim j
		' Set text for text frames
		Dim shapes As ShapeExCollection = slide.Shapes
		For j = 0 To shapes.Count - 1
			Dim ashape As AutoShapeEx = CType(shapes(j), AutoShapeEx)
			Dim tf As TextFrameEx
			tf = ashape.TextFrame
			If Not tf Is Nothing Then
				If tf.Text = "" Then
					tf.Paragraphs(0).Portions(0).Text = fullName
				ElseIf tf.Text = "" Then
					tf.Paragraphs(0).Portions(0).Text = "Biography text (Arial 12pt)"
				ElseIf tf.Text = "" Then
					Dim paragraphNumber = 0

					If Not tf Is Nothing Then
						Dim tfsh1 As TextFrameEx = tf
						If Not libTools.IsEmptyText(BioTitle) Then
							Dim parash1 As ParagraphEx = tfsh1.Paragraphs(paragraphNumber)
							For Each port As PortionEx In parash1.Portions
								'TODO: figure out how to set italics
--------------------------------------------------------------->port.PortionFormat.FontItalic = CType(1, Byte)
								port.Text = BioTitle
							Next port
							paragraphNumber = paragraphNumber + 1
						End If

						' spacer
						If True Then
							tfsh1.Paragraphs.Add(New ParagraphEx(tfsh1.Paragraphs(0)))
							Dim para3sh1 As ParagraphEx = tfsh1.Paragraphs(paragraphNumber)
							For Each port As PortionEx In para3sh1.Portions
								port.Text = " "
							Next port
							paragraphNumber = paragraphNumber + 1
						End If

						If Not libTools.IsEmptyText(ContactInfo1) Then
							' Add second paragraph to the shape
							tfsh1.Paragraphs.Add(New ParagraphEx(tfsh1.Paragraphs(0)))
							Dim para2sh1 As ParagraphEx = tfsh1.Paragraphs(paragraphNumber)
							For Each port As PortionEx In para2sh1.Portions
								port.Text = ContactInfo1
							Next port
							paragraphNumber = paragraphNumber + 1
						End If

						If Not libTools.IsEmptyText(ContactInfo2) Then
							' Add second paragraph to the shape
							tfsh1.Paragraphs.Add(New ParagraphEx(tfsh1.Paragraphs(0)))
							Dim para2sh1 As ParagraphEx = tfsh1.Paragraphs(paragraphNumber)
							For Each port As PortionEx In para2sh1.Portions
								port.Text = ContactInfo2
							Next port
							paragraphNumber = paragraphNumber + 1
						End If

						If Not libTools.IsEmptyText(ContactInfo3) Then
							' Add third paragraph to the shape
							tfsh1.Paragraphs.Add(New ParagraphEx(tfsh1.Paragraphs(0)))
							Dim para3sh1 As ParagraphEx = tfsh1.Paragraphs(paragraphNumber)
							For Each port As PortionEx In para3sh1.Portions
								port.Text = ContactInfo3
							Next port
							paragraphNumber = paragraphNumber + 1
						End If

						If Not libTools.IsEmptyText(ContactInfo4) Then
							' Add third paragraph to the shape
							tfsh1.Paragraphs.Add(New ParagraphEx(tfsh1.Paragraphs(0)))
							Dim para3sh1 As ParagraphEx = tfsh1.Paragraphs(paragraphNumber)
							For Each port As PortionEx In para3sh1.Portions
								port.Text = ContactInfo4
							Next port
							paragraphNumber = paragraphNumber + 1
						End If

						If Not libTools.IsEmptyText(ContactInfo5) Then
							' Add third paragraph to the shape
							tfsh1.Paragraphs.Add(New ParagraphEx(tfsh1.Paragraphs(0)))
							Dim para3sh1 As ParagraphEx = tfsh1.Paragraphs(paragraphNumber)
							For Each port As PortionEx In para3sh1.Portions
								port.Text = ContactInfo5
							Next port
							paragraphNumber = paragraphNumber + 1
						End If

						' spacer
						If True Then
							tfsh1.Paragraphs.Add(New ParagraphEx(tfsh1.Paragraphs(0)))
							Dim para3sh1 As ParagraphEx = tfsh1.Paragraphs(paragraphNumber)
							For Each port As PortionEx In para3sh1.Portions
								port.Text = " "
							Next port
							paragraphNumber = paragraphNumber + 1
						End If

						If Not libTools.IsEmptyText(ContactInfo6) Then
							' Add third paragraph to the shape
							tfsh1.Paragraphs.Add(New ParagraphEx(tfsh1.Paragraphs(0)))
							Dim para3sh1 As ParagraphEx = tfsh1.Paragraphs(paragraphNumber)
							For Each port As PortionEx In para3sh1.Portions
								port.Text = ContactInfo6
							Next port
							paragraphNumber = paragraphNumber + 1
						End If


						If Not libTools.IsEmptyText(ContactInfo7) Then
							' Add third paragraph to the shape
							tfsh1.Paragraphs.Add(New ParagraphEx(tfsh1.Paragraphs(0)))
							Dim para3sh1 As ParagraphEx = tfsh1.Paragraphs(paragraphNumber)
							For Each port As PortionEx In para3sh1.Portions
								port.Text = ContactInfo7
							Next port
							paragraphNumber = paragraphNumber + 1
						End If


						If Not libTools.IsEmptyText(ContactInfo8) Then
							' Add third paragraph to the shape
							tfsh1.Paragraphs.Add(New ParagraphEx(tfsh1.Paragraphs(0)))
							Dim para3sh1 As ParagraphEx = tfsh1.Paragraphs(paragraphNumber)
							For Each port As PortionEx In para3sh1.Portions
								port.Text = ContactInfo8
							Next port
							paragraphNumber = paragraphNumber + 1
						End If

					End If

					Trace.Write("finished adding contact lines")

				End If
			End If
		Next

		If Not libTools.IsEmptyText(BioImage) Then
			ReplaceImage(newPPT, slide, BioImage)
		End If
		Trace.Write("added images")

		outputPPT.Slides.AddClone(slide)
		HasPPTPages = True
	End If
Next
The above code results in the following error:

Value of type 'Byte' cannot be converted to 'Aspose.Slides.Pptx.NullableBool'.

On the line identified with the arrow.

Hi Zachary,


I have set up the environment shared by you. I have used the Aspose.Slides.Pptx.NullableBool property in both C# and VB application. In C# application it seems to work fine. However, I have been able to obtain the same error in case of VB application. An issue with ID SLIDESNET-33360 has been created in our issue tracking system to further investigate and resolve the issue. This thread has been linked with the same issue so that you may be automatically notified once the issue will be resolved. For your reference, I have shared the sample projects of both languages.

We are sorry for your inconvenience,