As told in an other post about the saving of word documents with data-bindings, I'm creating a tool which can have as input a folder which contains different kinds of files and converts all those files into one pdf file.
I'm trying to use spire in c# for this but at the moment I'm having an issue with pdf files who contain input field.
When I try to convert a pdf which contains input fields the system throws a nullpointer exception.
This is my code:
- Code: Select all
class SpirePdfMerger
{
private List<Stream> pdfStreams;
public SpirePdfMerger(List<Stream> pdfStreams)
{
this.pdfStreams = pdfStreams;
}
public void MergePdfStreamsAndSave(string savePath)
{
PdfDocument mergedPdf = MergePdfStreams();
SaveMergedPdf(mergedPdf, savePath);
}
public PdfDocument MergePdfStreams()
{
PdfDocument mergedPdf = new PdfDocument();
foreach(Stream pdfStream in pdfStreams)
{
PdfDocument pdfToMerge = new PdfDocument(pdfStream);
mergedPdf.AppendPage(pdfToMerge);
pdfStream.Close();
}
return mergedPdf;
}
public void SaveMergedPdf(PdfDocument mergedPdf, string savePath)
{
mergedPdf.SaveToFile(savePath);
mergedPdf.Close();
}
}
In attachement you can find a sample of a pdf file with input I'd like to convert.