How do I move a PDF file through multiple objects in the PDF.Kit without writing it out to an actually file between everyone?
Want to extract a page from a larger PDF
Then fill out the fields on it
Then drop a barcode or two on it
but I don’t want to have to create a bunch of tempory files. Been trying to get a memory stream to work but just haven’t been able to.
Allen
Hi,
Thank you for considering Aspose.
“Want to extract a page from a larger PDF”. Please refer to:
http://www.aspose.com/wiki/default.aspx/Aspose.Pdf.Kit/ExtractPagesfromPDFDocument.html
“Then fill out the fields on it”. Please check:
http://www.aspose.com/wiki/default.aspx/Aspose.Pdf.Kit/HowToFillFieldWithAPI.html
“Then drop a barcode or two on it”. You can add an image. Just convert Barcode to an image and use the following:
Please check the following code:
//Initialize the string variables storing paths of PDF files
string inFile = "c:\\form1.pdf";
string outFile = "c:\\ExtractStream.pdf";
//Creating stream objects holding the PDF files in Open Mode
FileStream inStream = new FileStream(inFile, FileMode.Open);
//Creating output stream object that will store the extracted pages as a PDF file
FileStream outputStream = new FileStream(outFile, FileMode.Create);
//Instantiating PdfFileEditor object
PdfFileEditor editor = new PdfFileEditor();
//Creating an array of integers having numbers of the pages to be extracted from PDF file
int[] pages = new int[] { 1 };
//Calling Extract method
editor.Extract(inStream, pages, outputStream);
//Closing output stream
Aspose.Pdf.Kit.Form f = new Aspose.Pdf.Kit.Form(outputStream, outputStream);
f.FillField("Name", "Adeel Taseer");
f.Save();
BarCodeBuilder bb = new BarCodeBuilder();
bb.CodeText = f.GetField("Name");
bb.SymbologyType = Symbology.UPCA;
bb.CodeLocation = CodeLocation.Below;
FileStream imgStream = new FileStream("c:\\imj.jpg", FileMode.Create);
bb.Save (imgStream, System.Drawing.Imaging.ImageFormat.Jpeg);
///Convert imgstream to outputstream
// Add Code here ....
outputStream.Close();
Hope it helps.
Thanks.