I am trying to test for PDF/A compliance. With the following code:
Code: Select all
If InputPDF.LoadFromFile(pdfPath, False) = GdPicture.GdPictureStatus.OK Then
pgCnt = InputPDF.GetPageCount()
InputPDF.SetTitle("testTitle")
titleString = InputPDF.GetTitle()
conformCode = InputPDF.GetPDFAConformance()
Length cannot be less than zero.
Parameter name: length at System.String.InternalSubStringWithChecks(Int32 startIndex, Int32 length, Boolean fAlwaysCopy)
at ឋ.() at DDD_ClassLib.PDF_A.OnProcess(IContext context, IDataRecord data) in C:\Users\lbleicher\Documents\Visual Studio 2010\Projects\DDD_ClassLib\DDD_ClassLib\Class1.vb:line 588 at ComponentProxy.OnProcessProxy(Int64 contextRaw, Int64 dataRecordRaw)
Anyone know what is causing this?
The PDF being used is created by GdPicture in an earlier step:
Code: Select all
executedGdPCmd = OutputPDF.NewPDF(True)
'get some info about the document
If InputPDF.LoadFromFile(pdfPath, False) = GdPicture.GdPictureStatus.OK Then
For i As Integer = 1 To InputPDF.GetPageCount()
InputPDF.SelectPage(i)
pageImages = InputPDF.GetPageImageCount()
If pageImages = 1 Then
curPageName = InputPDF.GetPageImageResName(1)
curPageImage = InputPDF.ExtractPageImage(1)
inPgPD = myPage.GetBitDepth(curPageImage)
inPgHP = myPage.GetHeight(curPageImage)
inPgHI = myPage.GetHeightInches(curPageImage)
inPgWP = myPage.GetWidth(curPageImage)
inPgWI = myPage.GetWidthInches(curPageImage)
myPage.ReleaseGdPictureImage(curPageImage)
hDPI = inPgHP / inPgHI
wDPI = inPgWP / inPgWI
curDPI = System.Math.Max(hDPI, wDPI)
newDPI = System.Math.Min(curDPI, 150)
Else
newDPI = 150
End If
rastPage = InputPDF.RenderPageToGdPictureImage(newDPI, False)
executedGdPCmd = myPage.ConvertTo1Bpp(rastPage)
Dim image_res_name As String = OutputPDF.AddImageFromGdPictureImage(rastPage, False, False)
myPage.ReleaseGdPictureImage(rastPage)
'InputPDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
OutputPDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitInch)
OutputPDF.NewPage(inPgWI, inPgHI)
OutputPDF.SelectPage(i)
OutputPDF.DrawImage(image_res_name, 0, 0, inPgWI, inPgHI)
Next i
OutputPDF.SaveToFile(OutputFilePath)
Else
'report out reason for problem.
Dim errCode As Integer = InputPDF.GetStat()
End If
InputPDF.CloseDocument()
OutputPDF.CloseDocument()
Help?
Thanks,
Leo