document.Save(string) Object reference not set to an instance of an object


#1

I am trying to use Apose.PDF in a destination script task in an SSIS package (VS2017).
I’ve got it working (building pdf with HtmlFragments from database) in a basic class library.

The exact same code is giving me a strange stack trace exception when used within an SSIS Script Task.

See below:

Error:
at #=zE8Zm62kV3nNvMfMMNBzsnds3xi4PaJd725o914w=.#=zjDwCNtis015F(#=z6bXrW$153C7M2BkJSN_Yv6cvKiyDYXRWxQ== #=zhGSoW9A=, Char #=zAl_FPn8=)
at #=zE8Zm62kV3nNvMfMMNBzsnds3xi4PaJd725o914w=.#=zjDwCNtis015F(#=z6bXrW$153C7M2BkJSN_Yv6cvKiyDYXRWxQ== #=zhGSoW9A=)
at #=z0n1DwUoNC7eOk0j2UqkYh6bY7ijEQVRsDuVc_y_Z$hx1.#=zW9POpwA=()
at #=zixj_ZgUNi7jfCdooAZDZ5fYSV9bVaoodQg1q7iaURme4.#=zviM5VXOBo8xB()
at #=zS$U94qsR5tEUESI324aFUDcsLP4VtNtXyyCz_DzmM1DBWqp0gHD2MZM=.#=zu1umDXnmTmUf()
at #=zS$U94qsR5tEUESI324aFUDcsLP4VtNtXyyCz_DzmM1DBWqp0gHD2MZM=.#=ziY4TEl8nPFfg1IvgRAem714=(List1 #=z8jCSCYQ=, #=z71bkPl25s1vdKcTEsA7Qb6nY92lz_xjRBRs80oA= #=zhN05heo=) at #=zS$U94qsR5tEUESI324aFUDcsLP4VtNtXyyCz_DzmM1DBWqp0gHD2MZM=.#=zOFjVzalXU48IFM_JZw==(#=z71bkPl25s1vdKcTEsA7Qb6nY92lz_xjRBRs80oA= #=zhN05heo=, List1 #=zZWxUf8Y=)
at #=z16W5E6tm9S9OUQ2zcpAnJY1NZd3V3cjzA54BLDxhTxzI.#=zyhHRq_UBEuzanVDFPQ==(#=z71bkPl25s1vdKcTEsA7Qb6nY92lz_xjRBRs80oA= #=zhN05heo=, Int32 #=z5xOnU7g=, Stack1 #=zWCSNSto5_w8m, #=zz9IdPXcSlExjKOEPcp9wZGy4n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sny0= #=zQXr8mF8=, TimeSpan #=zqPrg6wI=)
at #=zf$h7tWicjT6GoJQLlwKLUykagfJi.Render(#=zZvefzeXoECNki8Ss6qvBHtr3mwEA #=zaELPG80=, #=z9Epsny0= #=zQXr8mF8=)
at #=zKVh7M06i7vpzucJOFh7ZaAulPTlh.#=zNA6ZOWmkWBQ$(Stream #=zltbci04BSGl2, Document #=zPe_GbBVMi61l, HtmlLoadOptions #=zH2bVRPgwGFmB, IList1 #=z$epaNDVvfQFw, String #=zgEmgpqeCexh_, Matrix #=zO460J8k=) at Aspose.Pdf.HtmlFragment.#=zf9oshxrMsXcv(Page #=zB4DTUak=, Double #=zcinjQ2c=, Double #=z0eaJU3a1$5O4, Double #=zzhLyZrMgrguF, IList1 #=z$epaNDVvfQFw, Matrix #=zO460J8k=)
at Aspose.Pdf.FormattedFragment.#=ztFDpuUo=(Double& #=zGJzk1ao=, Double& #=zI7_QJ98=, Boolean #=zgvL$wXvutKs3, Double #=zcinjQ2c=, Double #=z8PtJrw4=, List`1 #=zquj74W0=, Page #=zB4DTUak=, MarginInfo #=zBJTeHYE=, Table #=z_0vqRHA=, Double #=zHc0jq7lP7Gs9, Boolean #=zCI$S9cOBq1yy)
at #=z0fkFRK7v8HIPVxXIJEUd0hg=.#=ztFDpuUo=()
at Aspose.Pdf.Page.#=z0XC_rx4=(Page #=zB4DTUak=)
at Aspose.Pdf.Page.#=zyFabkRkU$_PoYslOYg==()
at Aspose.Pdf.Document.ProcessParagraphs()
at Aspose.Pdf.Document.#=z34wha_tMYW5e(Stream #=z$$huN9A=, SaveOptions #=zn9OMIRURwZxW)
at Aspose.Pdf.Document.#=zB0WnsfwY8HBL(String #=zrby31jBhLHWP)
at Aspose.Pdf.Document.Save(String outputFileName)
at ScriptMain.PostExecute() in c:\Users\JHurst2\AppData\Local\Temp\vsta\cb65e68ea9ef417dbaf67c84fb3cd5b6\main.cs:line 109
at Microsoft.SqlServer.Dts.Pipeline.ScriptComponentHost.PostExecute()

Code:
Document document;
public override void PreExecute()
{
base.PreExecute();
document = new Document();
}

public override void PostExecute()
{
    base.PostExecute();
    document.Save(@"C:\Extracts\pdf\test.pdf");
}

public override void Input0_ProcessInputRow(Input0Buffer Row)
{
    //Add page
    Page page = document.Pages.Add();
    // Add html to new page
    page.Paragraphs.Add(new HtmlFragment(BlobColumnToString(Row.Body)));
}
string BlobColumnToString(BlobColumn blobColumn)
{
    if (blobColumn.IsNull)
        return string.Empty;

    var blobLength = Convert.ToInt32(blobColumn.Length);
    var blobData = blobColumn.GetBlobData(0, blobLength);
    var stringData = System.Text.Encoding.Unicode.GetString(blobData);

    return stringData;
}

#2

@jeremyhurst02

We are testing the scenario and will get back to you shortly.


#3

I am also getting the same error when deploying the .net core code (that is working on windows) to a linux-based cloud container.

I can’t really register the Aspose.Pdf.dll to the GAC on that machine, so I’m not sure what the issue is.


#4

@jeremyhurst02

We will also test the scenario from this perspective and as soon as we have some results, we will share with you.


#5

has this been tested, or is there an update to this issue?


#6

@jeremyhurst02

We have been trying to test the scenario and facing some technical difficulties. However, we will be able to share our feedback during this running week. Please spare us little time.


#7

I’m also interested in the resolution. I’m getting the same error when deployed to a docker container running Linux. I do not get the error when running on windows.

[Error] ProcessPdfDocument:Object reference not set to an instance of an object.
at #=zbcNZrqYsqV0xB75o_htRduS31S47.#=z6jnc$1k=(#=zL7$cu8NDyzD$_BcIDMWqN27Bdyqx #=zQZkYvoGxj19I)
at #=zymTjhRurWmk$CHAOQY5vorI=.#=z0$DLZYM=(#=zL7$cu8NDyzD$_BcIDMWqN27Bdyqx #=zQZkYvoGxj19I)
at #=qjPK8N0BenBUYGxJcFiD7icMfuVh16X_er4Or8iY$7H0=.#=zzn7krZSD6h8Ttf4Q3w==(Object #=zRtTBZNQ=)
at #=qjPK8N0BenBUYGxJcFiD7icMfuVh16X_er4Or8iY$7H0=.#=zDj9CnFQFjWhKuN50xg==(MethodBase #=zRtTBZNQ=, Boolean #=zrb$csX4=)
at #=qjPK8N0BenBUYGxJcFiD7icMfuVh16X_er4Or8iY$7H0=.#=zQQnBITmHxY25IHSch35cnHVaidyyYXLoGdZygIfcVzUG(#=qjPK8N0BenBUYGxJcFiD7icMfuVh16X_er4Or8iY$7H0= #=zRtTBZNQ=, #=qxfRroPYkt4WdkW4c21LPLUBKwUxCQweFdfXIf0x8HQo= #=zrb$csX4=)
at #=qjPK8N0BenBUYGxJcFiD7icMfuVh16X_er4Or8iY$7H0=.#=zPXH0_F11LpyLFXgW_SSczOs=()
at #=qjPK8N0BenBUYGxJcFiD7icMfuVh16X_er4Or8iY$7H0=.#=zZp0c6siqExNQpyUT83XZVc4N818nti5pPrLIMJ71vLni(Boolean #=zRtTBZNQ=)
at #=qjPK8N0BenBUYGxJcFiD7icMfuVh16X_er4Or8iY$7H0=.#=zzn7krZSD6h8Ttf4Q3w==(Object #=zRtTBZNQ=)
at #=qjPK8N0BenBUYGxJcFiD7icMfuVh16X_er4Or8iY$7H0=.#=zJ4DlEF1xfWjv4knxCw==()
at #=qjPK8N0BenBUYGxJcFiD7icMfuVh16X_er4Or8iY$7H0=.#=zDLIpilk2jVAGhQdKADAZk6Kfj$fJyINDzCiuzz0=(#=qjPK8N0BenBUYGxJcFiD7icMfuVh16X_er4Or8iY$7H0= #=zRtTBZNQ=, #=qxfRroPYkt4WdkW4c21LPLUBKwUxCQweFdfXIf0x8HQo= #=zrb$csX4=)
at #=qjPK8N0BenBUYGxJcFiD7icMfuVh16X_er4Or8iY$7H0=.#=zPXH0_F11LpyLFXgW_SSczOs=()
at #=qjPK8N0BenBUYGxJcFiD7icMfuVh16X_er4Or8iY$7H0=.#=zZp0c6siqExNQpyUT83XZVc4N818nti5pPrLIMJ71vLni(Boolean #=zRtTBZNQ=)
at #=qjPK8N0BenBUYGxJcFiD7icMfuVh16X_er4Or8iY$7H0=.#=zzn7krZSD6h8Ttf4Q3w==(Object #=zRtTBZNQ=)
at #=qjPK8N0BenBUYGxJcFiD7icMfuVh16X_er4Or8iY$7H0=.#=zJ4DlEF1xfWjv4knxCw==()
at #=qjPK8N0BenBUYGxJcFiD7icMfuVh16X_er4Or8iY$7H0=.#=zI0T5f01BvpGejHLBVnmFrls=(Object #=zRtTBZNQ=, UInt32 #=zrb$csX4=)
at #=qjPK8N0BenBUYGxJcFiD7icMfuVh16X_er4Or8iY$7H0=.#=zZp0c6siqExNQpyUT83XZVc4N818nti5pPrLIMJ71vLni(Boolean #=zRtTBZNQ=)
at #=qjPK8N0BenBUYGxJcFiD7icMfuVh16X_er4Or8iY$7H0=.#=zZp0c6siqExNQpyUT83XZVc4N818nti5pPrLIMJ71vLni(Boolean #=zRtTBZNQ=)
at #=qjPK8N0BenBUYGxJcFiD7icMfuVh16X_er4Or8iY$7H0=.#=zKLMd7Ur$Y2KrT2TZ7uTBbusdf8IQ()
at #=qjPK8N0BenBUYGxJcFiD7icMfuVh16X_er4Or8iY$7H0=.#=zAJjZnHNAFUq_FVFlPpZyLPkwGpzm4gfoo6ehzks=(Object[] #=zRtTBZNQ=, Type[] #=zrb$csX4=, Type[] #=zAl_FPn8=, Object[] #=zZlirkcE=)
at #=qjPK8N0BenBUYGxJcFiD7icMfuVh16X_er4Or8iY$7H0=.#=zDmxaysj$oANjFhN5zDgj2AQ$scvnvVYryg==(Stream #=zRtTBZNQ=, String #=zrb$csX4=, Object[] #=zAl_FPn8=, Type[] #=zZlirkcE=, Type[] #=z0ajIK14=, Object[] #=zS2TweAE=)
at #=qjPK8N0BenBUYGxJcFiD7icMfuVh16X_er4Or8iY$7H0=.#=zr8xbGFB3C1sl88g8OJxBIcA1lRqTZzrgyg==(Stream #=zRtTBZNQ=, String #=zrb$csX4=, Object[] #=zAl_FPn8=)
at #=qjPK8N0BenBUYGxJcFiD7icMfuVh16X_er4Or8iY$7H0=.#=ziiMXcF3Y0FFaxbWw_EiGccE=(Stream #=zRtTBZNQ=, String #=zrb$csX4=, Object[] #=zAl_FPn8=)
at Aspose.Pdf.Document.#=z34wha_tMYW5e(Stream #=z$$huN9A=, SaveOptions #=zn9OMIRURwZxW)
at Aspose.Pdf.Document.Save(Stream output)


#8

@shernandez068

Sure, we will let you know as soon as some updates are available.


#9

I was able to resolve the error by copying all the windows fonts to the docker (Linux) container and adding the path to the Aspose PDF code:
Aspose.Pdf.Text.FontRepository.Sources.Add(new Aspose.Pdf.Text.FolderFontSource("/usr/share/fonts"));

It also resolved a similar issue I was having with Aspose.Slides.


#10

@shernandez068

Thanks for sharing the solution to the issue you were having.

It would definitely help others facing similar issue. Please keep using our API and in case you face any issue, please feel free to let us know.