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=, List
1 #=zZWxUf8Y=)
at #=z16W5E6tm9S9OUQ2zcpAnJY1NZd3V3cjzA54BLDxhTxzI.#=zyhHRq_UBEuzanVDFPQ==(#=z71bkPl25s1vdKcTEsA7Qb6nY92lz_xjRBRs80oA= #=zhN05heo=, Int32 #=z5xOnU7g=, Stack1 #=zWCSNSto5_w8m, #=zz9IdPXcSlExjKOEPcp9wZGy4nsgLZ4KjfG0h5oQ= #=zgdi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nNzT3gpmJMy0oiX3cwNCW #=z$cDUb3k=, #=zgLJS96FcE5yDDU7vi3tZOezvIBwaVr5P0Q== #=z967iwXLFWMmGXlFneQ==, #=zBa1na6Ntij9$AcsU9Jp9nvQ= #=zQXr8mF8=)
at #=zwlFjQDlEfOUV6b1G$QZPFQiAH8bPgi7j7w==.#=zjZKEn_jvUqCq(#=zBa1na6Ntij9$AcsU9Jp9nvQ= #=zQXr8mF8=, #=z1y5PGz3nNzT3gpmJMy0oiX3cwNCW #=z0H55woYuUsV4WFNkPA==)
at #=zQKDql__75mzuEjDvI$YaIZK_UMw0hnq9gg==.#=zy_J1CsE=(#=zZvefzeXoECNki8Ss6qvBHtr3mwEA #=zaELPG80=, #=zpEERXWVx3oLFKl0DMWCt0hycTnUv #=z0DoT0kU=)
at #=zpEERXWVx3oLFKl0DMWCt0hycTnUv.#=zy_J1CsE=(#=zZvefzeXoECNki8Ss6qvBHtr3mwEA #=zaELPG80=)
at #=zLT_UGMWSIwkivQxrbfvFXiIRr$Ow.#=z4w_dZyg=()
at #=zLT_UGMWSIwkivQxrbfvFXiIRr$Ow.MoveNext()
at #=zwlFjQDlEfOUV6b1G$QZPFQiAH8bPgi7j7w==.#=zVh4T0KkQ7pYY(#=zrCWslkTNOhBqCfJr2KrnQXU= #=zUpMywSFKTUvEoWOoxg==, #=zpEERXWVx3oLFKl0DMWCt0hycTnUv[] #=zk6RPm_p3ePj1, #=zZvefzeXoECNki8Ss6qvBHtr3mwEA #=zaELPG80=, TimeSpan #=zqPrg6wI=)
at #=zEbWHoJ8S57$FOo77vXQd3yrIhLRT.Render(#=zZvefzeXoECNki8Ss6qvBHtr3mwEA #=zaELPG80=, TimeSpan #=zqPrg6wI=, #=zBa1na6Ntij9$AcsU9Jp9nvQ=[] #=zOGtl6Yw=)
at #=zf$h7tWicjT6GoJQLlwKLUykagfJi.Render(#=zZvefzeXoECNki8Ss6qvBHtr3mwEA #=zaELPG80=, #=z9Epsny0= #=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, IList
1 #=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;
}