Unable to merge PDF files. Invalid PDF file error
oleg
11/28/2007 12:35 AM
|
---|
After I create PDF file using PdfExporter, I'm unable to merge it with another PDF files (I'm using Cete Software's DynamicPDF/PDFMerger). Every time I'm trying to load PDF file I'm getting 'Invalid PDF File. Cross-Reference not found'. There is no problem with Acrobat Reader, but if you open it in Acrobat Professional you will notice a 'Rebuild' screen pop up and it will prompt you to save the file when it is closed. After that, saved file can be used with PDFMerger.
|
Wout
11/28/2007 12:43 PM
|
---|
Hi,
That was a bug indeed in older versions of CadLib, can you please try the latest version?
Thank you,
Wout
|
oleg
11/28/2007 8:02 PM
|
---|
Hi Wout,
I didn't go so far to validate PDF file. Actually there was nothing to validate ;-). Whole drawing disappeared except dimensions. I see you removed mapWhiteToBlack from PdfExporter constructor.
Thanks Oleg.
|
Wout
11/28/2007 8:05 PM
|
---|
Hi Oleg,
Yes, it changed: the GraphicsConfig.CorrectColorForBackgroundColor replaces the old setting. It was better design having it all consistently controlled by GraphicsConfig, since there are a bunch of other settings as well, that setting was just one of them.
Let me know if that helped!
Wout
|
oleg
11/28/2007 8:21 PM
|
---|
Hi Wout,
Yes it helped !!! And there is no problem with PDF merger anymore !
Thanks for your help !
Oleg
|
oleg
1/24/2008 2:23 AM
|
---|
Hi Wout,
I've got into the same problem (with Dynamic PDF) right after I start using memory strem instead of the file stream. Following code is working without any problem:
Dim _filestream As Stream = File.Create('testpdfx.pdf')
Dim pdfGraphics As PdfExporter = New PdfExporter(_filestream)
pdfGraphics.DrawPage(_dxfmodel, GraphicsConfig.WhiteBackgroundCorrectForBackColor, to2DTransform, paperSize)
pdfGraphics.EndDocument()
Dim MyDocument As MergeDocument = New MergeDocument(New PdfDocument('testpdfx.pdf'))
Here is snipset with memory stream:
Dim _filestream As MemoryStream = New MemoryStream()
Dim pdfGraphics As PdfExporter = New PdfExporter(_filestream)
pdfGraphics.DrawPage(_dxfmodel, GraphicsConfig.WhiteBackgroundCorrectForBackColor, to2DTransform, paperSize)
pdfGraphics.EndDocument()
Dim MyDocument As MergeDocument = New MergeDocument(New PdfDocument(_filestream.GetBuffer()))
_filestream.Close()
Right after I initialize MyDocument I'm getting error:
Invalid PDF File. Cross-Reference not found.
Thanks
Oleg
|
Wout
1/24/2008 11:04 AM
|
---|
Hi Oleg,
Use MemoryStream.ToArray() in stead of GetBuffer(). GetBuffer returns the complete buffer, which is typically a bit more than the actually used part of the buffer.
Also try calling MemoryStream.Flush() before getting its contents with ToArray().
Let me know if that helped.
Wout
|
oleg
1/25/2008 1:50 AM
|
---|
It worked !
Thanks Wout.
|