Ho trovato e convertito nel codice qui di seguito un modo di generare un file pdf da una immagine ...
pero' mi da come errore <.
A) nella dichiarazione della funzione "string"
e la riga :
B) throw new Exception
io non ho capio il perche' se mi volete dare una mano vi metto il codice qui..
private string ImageToPDF(string FilePath, string DestinationFolder)
{
const int PDSaveCollectGarbage = 32;
const int PDSaveLinearized = 4;
const int PDSaveFull = 1;
object PDFAVDoc = null;
object PDFDoc = null;
try
{
// Check destination requirements
if (!DestinationFolder.EndsWith(@"\"))
DestinationFolder += @"\";
if (!System.IO.Directory.Exists(DestinationFolder))
throw new Exception("Destination directory does not exist: " + DestinationFolder);
string CreatedFile = DestinationFolder + System.IO.Path.GetFileNameWithoutExtension(FilePath) + ".pdf";
// Avoid conflicts, therefore previous file there will be deleted
if (File.Exists(CreatedFile))
File.Delete(CreatedFile);
// Get PDF document
PDFAVDoc = GetPDFAVDoc(FilePath);
PDFDoc = PDFAVDoc.GetPDDoc;
if (!PDFDoc.Save(PDSaveCollectGarbage | PDSaveLinearized | PDSaveFull, CreatedFile))
throw new Exception("PDF file cannot be saved: " + PDFDoc.GetFileName());
if (!PDFDoc.Close())
throw new Exception("PDF file could not be closed: " + PDFDoc.GetFileName());
PDFAVDoc.Close(1);
return CreatedFile;
}
catch (Exception Ex)
{
throw Ex;
}
finally
{
System.Runtime.InteropServices.Marshal.ReleaseComObject(PDFDoc);
System.Runtime.InteropServices.Marshal.FinalReleaseComObject(PDFDoc);
PDFDoc = null;
System.Runtime.InteropServices.Marshal.ReleaseComObject(PDFAVDoc);
System.Runtime.InteropServices.Marshal.FinalReleaseComObject(PDFAVDoc);
PDFAVDoc = null;
GC.Collect();
GC.WaitForPendingFinalizers();
GC.Collect();
}
}
Grazie.