c# - How can I export text and image to PDF using iTextSharp? -
i having problems itextsharp , exporting .pdf
i'm using itextsharp 5.1.2.0. issue is, however, when try export 1 rtf snippet referring image, image not display.
also, if insert formatting document, rich formatting code appears instead of displaying interpreted text formatting. because image doesn't export, , document doesn't keep formatting, assume there's wrong code isn't allowing saved rich text document.
my code exporting document pdf follows:
savefiledialog dlg = new savefiledialog(); dlg.filter = "portable document format (.pdf)|*.pdf"; dlg.filterindex = 0; itextsharp.text.document mydocument = new itextsharp.text.document(pagesize.a4); dialogresult dialog = dlg.showdialog(); if (dialog == dialogresult.ok) try { filename = dlg.filename; pdfwriter.getinstance(mydocument, new filestream(dlg.filename, filemode.create)); mydocument.open(); mydocument.add(new itextsharp.text.paragraph(richtextboxprintctrl1.rtf)); } catch (exception exc) { messagebox.show("error exporting pdf. please try again. \n \n" + exc.message, "error", messageboxbuttons.ok, messageboxicon.error); } mydocument.close(); }
please see attached images examples.
thanks.
Comments
Post a Comment