Hi fbga81,
Try this... might be this helps you.
----------------------------------------------------
Document document = new Document();
PdfWriter.GetInstance(document, new
FileStream(Server.MapPath("~//TestPDFAmit//"
+DateTime.Now.ToString("ddMMMyyyyhhmmttss") + ")" + ".pdf"),
FileMode.Create));
BaseFont bf = BaseFont.CreateFont(@"C:\WINDOWS\Fonts\Arial.ttf",
BaseFont.WINANSI, true);
iTextSharp.text.Font font = new iTextSharp.text.Font(bf, 25f);
document.Open();
document.Add(new Phrase(16, "Rose india provides online java interview
question and answer.Rose india provides online java", font));
document.Add (new Phrase(5, "Amit india provides online java interview
question and answer.Rose india provides online java",font));
document.Close();
----------------------------------------------------
Regards,
Rahul Khadikar
fbga81 wrote:
>
> Hello,
>
> I'm triying to copy an existing PDF to make it a PDF/A and I must embed
> the
> fonts but I don't get it. I'm doing this:
>
> try {
> int pageOffset = 0;
> ArrayList master = new ArrayList();
> Document document = null;
> PdfCopy writer = null;
> String outFile = "D:\\tmp\\OUT_PDF.pdf";
> FileOutputStream("D:\\tmp\\hello_A1-b.pdf"));
> PdfReader reader = new PdfReader("D:\\tmp\\IN_PDF.pdf");
> reader.consolidateNamedDestinations();
>
> // we retrieve the total number of pages
> int n = reader.getNumberOfPages();
>
> List bookmarks = (List) SimpleBookmark.getBookmark(reader);
>
> if (bookmarks != null)
> {
> if (pageOffset != 0)
> SimpleBookmark.shiftPageNumbers(bookmarks, pageOffset, null);
>
> master.addAll(bookmarks);
> }
>
> pageOffset += n;
>
> // step 1: creation of a document-object
> document = new Document(reader.getPageSizeWithRotation(1));
> // step 2: we create a writer that listens to the document
> writer = new PdfCopy(document, new FileOutputStream(outFile));
> writer.setPDFXConformance(PdfCopy.PDFA1B);
>
> PdfDictionary outi = new PdfDictionary(PdfName.OUTPUTINTENT);
>
> outi.put(PdfName.OUTPUTCONDITIONIDENTIFIER,
> new PdfString("sRGB IEC61966-2.1"));
> outi.put(PdfName.INFO, new PdfString("sRGB IEC61966-2.1"));
> outi.put(PdfName.S, PdfName.GTS_PDFA1);
>
> com.itextpdf.text.pdf.ICC_Profile icc =
> com.itextpdf.text.pdf.ICC_Profile.getInstance(new
> FileInputStream("D:\\iText\\srgb.profile"));
> PdfICCBased ib = new PdfICCBased(icc);
>
> ib.remove(PdfName.ALTERNATE);
>
> // step 3: we open the document
> document.open();
> //document.add(new Paragraph("ss", f));
> BaseFont font = BaseFont.createFont("c:\\windows\\fonts\\arial.ttf",
> BaseFont.WINANSI, true);
> PdfContentByte content = writer.getDirectContent();
> content.setFontAndSize(font, 12);
>
> // step 4: we add content
> PdfImportedPage page = null;
> float numero = 12;
>
> //writer.getExtraCatalog().put(PdfName.OUTPUTINTENTS, new
> PdfArray(outi));
> //page.setFontAndSize(font2,numero);
>
> for (int i = 0; i < n; )
> {
> ++i;
> page = writer.getImportedPage(reader, i);
> writer.addPage(page);
> }
>
> PRAcroForm form = reader.getAcroForm();
>
> if (form != null)
> writer.copyAcroForm(reader);
>
> if (master.size() > 0)
> writer.setOutlines(master);
>
> // step 5: we close the document
> document.close();
>
> When I do this the filesize increments, but if I look into the properties
> of the
> resultant document, the fonts don't seem to be embedded. If anyone can
> help me I
> would thank him.
>
>
> ------------------------------------------------------------------------------
> Download Intel® Parallel Studio Eval
> Try the new software tools for yourself. Speed compiling, find bugs
> proactively, and fine-tune applications for parallel performance.
> See why Intel Parallel Studio got high marks during beta.
> http://p.sf.net/sfu/intel-sw-dev
> _______________________________________________
> iText-questions mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/itext-questions
>
> Buy the iText book: http://www.1t3xt.com/docs/book.php
> Check the site with examples before you ask questions:
> http://www.1t3xt.info/examples/
> You can also search the keywords list:
> http://1t3xt.info/tutorials/keywords/
>
>
--
View this message in context:
http://old.nabble.com/Embedding-fonts-when-copying-PDF-tp27848053p27848767.html
Sent from the iText - General mailing list archive at Nabble.com.
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://www.1t3xt.com/docs/book.php
Check the site with examples before you ask questions:
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/