none
Error: Value can not Be Null - PDF Reader RRS feed

  • Question

  • Nit sure why this is saying my value is null

    code:

    Die_rdr = New iTextSharp.text.pdf.PdfReader(CType(My.Resources.ResourceManager.GetObject(String.Format("Die_{0}_{1}_pdf", cardSize.CardType, oOrder.Item.PaperTrim)), Byte()))

    cardSize.CardType = Card_4x5_5

    oOrder.Item.PaperTrim = SQUARE_CORNER

    Ideas? 

    Exception:

    {"Value cannot be null."}

    Details:

       at iTextSharp.text.io.ArrayRandomAccessSource..ctor(Byte[] array)
       at iTextSharp.text.pdf.PdfReader..ctor(Byte[] pdfIn)
       at Collage.Business.PDFBuilder.CreateCardHeaderCardTemplate(CardSize cardSize, PdfWriter& PDF_wtr, OrderInformation oOrder, Boolean Test) in \\awardgraphics.com\data\users\mholmes\Desktop\Collage\Collage\Collage\Business\PDFBuilder.vb:line 1869

    Snippet:

    Public Function CreateCardHeaderCardTemplate(ByVal cardSize As Models.CardSize, ByRef PDF_wtr As pdf.PdfWriter, ByVal oOrder As Structures.OrderInformation, Test As Boolean) As iTextSharp.text.pdf.PdfTemplate
                Dim Shape_rdr, Die_rdr As iTextSharp.text.pdf.PdfReader
                Dim JPEG_img, BC_img, EnvMulti_img, EnvSng_img, Logo_img As iTextSharp.text.Image, Out_rct As iTextSharp.text.Rectangle
                Dim Shape_page, Die_page As iTextSharp.text.pdf.PdfImportedPage
                Dim Main_tmp, BC_tmp, Order_tmp, Due_tmp, Shape_tmp, Description_tmp, Envelope_tmp As iTextSharp.text.pdf.PdfTemplate
                Dim Day_CMYK, Envelope_cmyk As CMYK, CS As ColorShape, Brand_img As Drawing.Bitmap
                Dim iRes As Integer, nW, nH, nOffset, nCenterX, nCenterY, nThumbScale, nThumbY, nThumbHeight As Single, iLine As Integer, fRotate As Boolean
    
                DisplayMessage("Initiating pdf header card...")
    
                Out_rct = New iTextSharp.text.Rectangle(I2P(cardSize.Width), I2P(cardSize.Height))
                Main_tmp = iTextSharp.text.pdf.PdfTemplate.CreateTemplate(PDF_wtr, Out_rct.Width, Out_rct.Height)
    
                CS = GetColorShape(oOrder.RandomNumber)
    
                nThumbScale = 0.4F
    
                'Retrieve Shape
                Shape_rdr = New iTextSharp.text.pdf.PdfReader(CS.Shape)
                Shape_page = PDF_wtr.GetImportedPage(Shape_rdr, 1)
    
                If Not String.IsNullOrEmpty(oOrder.Item.PaperTrim) Then
                    'Retrieve Die
                    Try
                        Die_rdr = New iTextSharp.text.pdf.PdfReader(CType(My.Resources.ResourceManager.GetObject(String.Format("Die_{0}_{1}_pdf", cardSize.CardType, oOrder.Item.PaperTrim)), Byte()))
                        Die_page = PDF_wtr.GetImportedPage(Die_rdr, 1)
                    Catch ex As Exception
                        If oOrder.Item.PaperTrim <> "None" Then Utils.ErrorEmail("Die Shape Warning!", New Exception(String.Format("Die_{0}_{1}_pdf Resource not found.", cardSize.CardType, oOrder.Item.PaperTrim)))
                    End Try
                End If



    • Edited by old_School Monday, October 21, 2019 2:27 PM
    Monday, October 21, 2019 2:16 PM

Answers

  • Seems that ResourceManager.GetObject cannot find the resource. Make sure that the name is valid, and the resource is present.

    • Marked as answer by old_School Monday, October 21, 2019 3:07 PM
    Monday, October 21, 2019 2:46 PM
  • Seems that ResourceManager.GetObject cannot find the resource. Make sure that the name is valid, and the resource is present.

    I think your right. I'm not sure my self. I'm looking for a resource folder and I dont see one:

    If the resource is a string it will not appear in the resource folder of the project while if the resource is a file it will appear in the resource folder.

    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    • Marked as answer by old_School Monday, October 21, 2019 3:10 PM
    Monday, October 21, 2019 3:07 PM
    Moderator
  • Seems that ResourceManager.GetObject cannot find the resource. Make sure that the name is valid, and the resource is present.

    I think your right. I'm not sure my self. I'm looking for a resource folder and I dont see one:

    If the resource is a string it will not appear in the resource folder of the project while if the resource is a file it will appear in the resource folder.

    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    I think I fugred it out. Its grabbing these PDF's from another project in the solution. The issue is the "proof" or pdf does not exist for that die cut aka the pdf does not exist as Karen & Viorel_ stated. Thank you very much for helping me figure this out. 
    • Marked as answer by old_School Monday, October 21, 2019 3:18 PM
    Monday, October 21, 2019 3:18 PM

All replies

  • Seems that ResourceManager.GetObject cannot find the resource. Make sure that the name is valid, and the resource is present.

    • Marked as answer by old_School Monday, October 21, 2019 3:07 PM
    Monday, October 21, 2019 2:46 PM
  • If an issue with a misspelled resource name change that the resource exists and does not have leading or trailing spaces.

    At runtime you can see what is available and also determine if the resource exists.

    Imports System.Reflection
    
    Public Class ResourceHelper
        ''' <summary>
        ''' Get all string resources for current project
        ''' </summary>
        ''' <returns></returns>
        Public Function GetStringItems() As List(Of PropertyInfo)
    
            Dim propResult As PropertyInfo() = GetType(My.Resources.Resources).
                    GetProperties(
                        BindingFlags.NonPublic Or
                        BindingFlags.Instance Or
                        BindingFlags.Static)
    
            Dim stringResources As List(Of PropertyInfo) =
                    (
                        From propertyInfo In propResult
                        Where propertyInfo.PropertyType Is GetType(String)
                    ).ToList
    
            Return stringResources
    
        End Function
        ''' <summary>
        ''' Find a specific resource by name and get the value, in this
        ''' case a string.
        ''' </summary>
        ''' <param name="pItem"></param>
        ''' <returns></returns>
        Public Function FindStringItem(pItem As String) As String
            Dim result = GetStringItems().FirstOrDefault(Function(item) item.Name = pItem)
            If result IsNot Nothing Then
                Return result.GetValue(result).ToString()
            Else
                Return ""
            End If
        End Function
    End Class
    

    Usage to find a resource by name

    Dim ops = New ResourceHelper
    
    Dim foundItem = ops.FindStringItem("Card_4x5_5")
    If Not String.IsNullOrWhiteSpace(foundItem) Then
        Console.WriteLine(foundItem)
    Else
        Console.WriteLine($"{foundItem} not found")
    End If
    


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Monday, October 21, 2019 2:51 PM
    Moderator
  • Seems that ResourceManager.GetObject cannot find the resource. Make sure that the name is valid, and the resource is present.

    I think your right. I'm not sure my self. I'm looking for a resource folder and I dont see one:

    Monday, October 21, 2019 2:55 PM
  • Seems that ResourceManager.GetObject cannot find the resource. Make sure that the name is valid, and the resource is present.

    I think your right. I'm not sure my self. I'm looking for a resource folder and I dont see one:

    If the resource is a string it will not appear in the resource folder of the project while if the resource is a file it will appear in the resource folder.

    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    • Marked as answer by old_School Monday, October 21, 2019 3:10 PM
    Monday, October 21, 2019 3:07 PM
    Moderator
  • In order to check and add the resources, double-click ‘My Project”, go to “Resources” tab, select “Files” or other appropriate category from dropdown list.


    • Edited by Viorel_MVP Monday, October 21, 2019 3:09 PM
    Monday, October 21, 2019 3:07 PM
  • Seems that ResourceManager.GetObject cannot find the resource. Make sure that the name is valid, and the resource is present.

    I think your right. I'm not sure my self. I'm looking for a resource folder and I dont see one:

    If the resource is a string it will not appear in the resource folder of the project while if the resource is a file it will appear in the resource folder.

    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    I think I fugred it out. Its grabbing these PDF's from another project in the solution. The issue is the "proof" or pdf does not exist for that die cut aka the pdf does not exist as Karen & Viorel_ stated. Thank you very much for helping me figure this out. 
    • Marked as answer by old_School Monday, October 21, 2019 3:18 PM
    Monday, October 21, 2019 3:18 PM