Exception with PDFDraw Export (Error is only present in Production Environment)

490 views
Skip to first unread message

xanders2615

unread,
Apr 13, 2012, 10:03:57 AM4/13/12
to pdfne...@googlegroups.com
I'm having a problem with the PDFNet Library. I have this process in our application to append and remove pages from PDF files. The Code Works Fine in all the other Environments but in production we get this Exception.

Thanks for the Help.

Sample Code Start:
pdftron.PDFNet.Initialize(_PDFTronLicenseKey);

try {
byte[] documentBytes = ReadBytes(sDocumentPath);
using (pdftron.PDF.PDFDraw draw = new pdftron.PDF.PDFDraw())
{
pdftron.SDF.ObjSet hint_set = new pdftron.SDF.ObjSet();
using (doc = new pdftron.PDF.PDFDoc(documentBytes, documentBytes.Length))
{
doc.InitSecurityHandler();
draw.SetDPI(95);

pdftron.SDF.Obj encoder_param = hint_set.CreateDict();
encoder_param.PutNumber("Quality", 52);
//Loop For pages
pdftron.PDF.PageIterator pageItr = dReaderDoc.GetPageIterator(startPage)
draw.Export(pageItr.Current(), "FilePath", "JPEG", encoder_param);
//
}
}
} catch(Exception ex) {
//Something Here...
}
pdftron.PDFNet.Terminate();
Sample Code End:


Exception Error Message:Unable to open the file Conditional expression: m_stream != NULL Filename : StdFile.cpp Function : trn::Filters::StdFile::InitW Linenumber : 195

Target: Void Export(pdftron.PDF.Page, System.String, System.String, pdftron.SDF.Obj)

Source: PDFNet

Stack Trace: at pdftron.PDF.PDFDraw.Export(Page page, String filename, String format, Obj encoder_hints) at PDFModifyPagesPDF.RenderDocumentPages(Int32 iStartPage, Int32 iMaxPagesAllow, String sDocumentPath)

Support

unread,
Apr 13, 2012, 2:21:47 PM4/13/12
to PDFTron PDFNet SDK

The error says that the file (the second arg to draw.Export()) can't
be created, which makes sense.

You are passing in "FilePath", but you should probably use variable
FilePath? or a correct path (e.g. @"c:/my.jpg")




xanders2615

unread,
Apr 13, 2012, 3:20:52 PM4/13/12
to pdfne...@googlegroups.com

This file is created from the Web Server to a NAS.

The FilePath looks like this @"\\ServerName\ShareDirectory\FileName.jpg".

Support

unread,
Apr 13, 2012, 3:32:59 PM4/13/12
to PDFTron PDFNet SDK

The problem is that the all PDFNet methods dealing file-paths work
pnly with a local file system.

If you want to save to NAS you would need to save file localy then
move it to a shared network folder. Altenratively you could try saving
via GDI+ Bitmap:

System.Drawing.Bitmap bmp = pdfdraw.GetBitmap();
bmp.Save(...)

xanders2615

unread,
Apr 17, 2012, 12:51:25 PM4/17/12
to pdfne...@googlegroups.com
Yes, your suggestion works.

I did not know about the file-path restrictions in PDFNet.

Thank you.
Reply all
Reply to author
Forward
0 new messages