layering PDFs together and have ability to set the position - c#

I'm being tasked to enhance the way we create custom brochures, the old way we had a legacy system create the needed pdfs and then I would download those and "glue" them into one big pdf.
the new one way we want to go about this is to skip the legacy system and build all of these things from our new system.
The biggest hurdle is the cover, which consists of the background layer, and then the logo layer which has the company logo, a shadowbox and an emblem. all of these objects are pdf documents.
my problem is after I build the logo portion, how will I be able to position the pdf exactly where I need it on the background layer?
this is all being done on the fly so I can't save anything to disk.
any help will be greatly appreciated.

There are several PDFsharp samples that show how to do it:
http://pdfsharp.net/wiki/XForms-sample.ashx
http://pdfsharp.net/wiki/Graphics-sample.ashx#Draw_a_form_XObject_a_page_from_an_external_PDF_file_27
http://pdfsharp.net/wiki/TwoPagesOnOne-sample.ashx
You can draw pages from other PDF files like images on a newly created PDF page. You can specify the exact positions and sizes, you can even transform them (skew them, rotate them).

Related

itext create pdf based on existing one with changed content

I got quite complicated ready pdf file. It has got barcode and fancy looking table.
I have to create based on it application which will generate pdfs that will look the same but contain different records in the table and different barcode.
Is it possible to copy existing pdf and just change content of barcode and table ?
What would be the best approach to create the same looking pdf but with different content ?
Whank You very much for help
If the barcode and table are static I would open it in photoshop or illustrator delete everything I dont want, Then save it as a pdf again. Then follow this guide iText - add content to existing PDF file and use it as a template to put my custom content in.
If the table and bar code are dynamically generated (each one is different) and you need to crop out content on the fly I would pull some hacky crap and draw white squares over all the content I want gone. then proceed to use it as a template.
Just my 2 cents given the information provided.

iTextSharp Read Text from Layer

I'm using iTextSharp to interact with multi-layered PDF files from C# (VS2012). the PDF file is kind of a map, with plots on one layer and text on another.
what I want to do is, give the PDF path and layer name (the layer which has text) to application, it will search for text on the layer and create external hyperlinks on text. (I have a Dictionary with words and links). I'm able to open the PDF, read how many pages it has, and also find the required layer. But I'm kind of stuck and unable to find how to do next things i.e. read text on found layer and create hyperlinks.
Please guide me.
Thanks.

PdfSharp: reusing image resources

I'm cycling though a bunch of PDFs, and merging them into a single PdfDocument. I load one PDF using XPdfForm.FromStream(stm), then add a new page using AddPage, and draw the XPdfForm to that page. This seems to be the typical way to do this.
Some of these incoming PDFs contain duplicate images. I'd like to eliminate these as they create a file much larger than required.
Given an input XPdfForm, and the desire to draw it onto a PdfPage using an XGraphics... how can I design code that would not add duplicate images, but instead refer to a reusable image?
In an ideal world, PDFsharp would remove all duplicate objects (images, fonts) while saving.
It's on our wishlist.
It seems there was already an implementation for this problem.
http://forum.pdfsharp.net/viewtopic.php?f=4&t=648
I don't know why it was removed, but the old source is still available at SourceForge.

Programmatically change PNG / PSD image colour in .Net

I have a number of web controls, which are made up of png images. The simplest is a button.
I need to be able to generate these controls with different colours depending on the colour selected by the client.
The images are .PSD files, layered before exporting to png.
My idea was to allow the client to pick one colour and use a layer filter in the psd to change the overall colour of the image and programmatically export the .PSD to PNG on the server. I looked into using the Photoshop CS Interface via COM, but haven't got my head around it, has anyone else used it for a similar task?
Alternatively I could read the png into memory and perform colour replacement, but this seems really complex for what reads like a simple(ish) task.
Many thanks in advance
.PSD is quite complicated and poor documented file format, that is constantly receiving new features from Adobe, so editing them is no way an easy task.
One way is to use Photoshop batch processing, which means photoshop installed on server, but as long you you wished to make that through COM, it should not be a problem.
One of the starting points may be: http://www.webdesignerdepot.com/2008/11/photoshop-droplets-and-imagemagick/
Another way would be to try composite layers using c#, that means you would have some layers ready (textures/borders/etc), some would be created at runtime and all those layers would be merged at runtime using c#.

Choosing a cross-platform library for PDF rendering and analysis app (preferably using C#)

I am planning to write an app that can open and display PDF documents, and perform OCR on vector graphic elements within the PDFs. The user must be able to select regions of the document and I need to draw real-time annotations on the document. I don't need to alter or save the document itself.
I have plenty of experience with C# and WPF; I have written a similar application already that does the above on XPS/XAML documents rather than PDF. However that app only runs on Windows and PDF documents must be converted to XPS first.
I have done quite a bit of research and there are many, many options available, none of which seem an obvious choice. There are many libraries that can open PDFs or create PDFs, but most don't seem to give you access to individual vector graphic elements in a format that lets you draw/manipulate them on the screen (similar to what I could do with WPF graphic elements extracted from XPS documents).
I am familiar with .Net and C# (including .Net 2 GDI+ graphics) and I am very keen to stick to what I know. I am also using EmguCV for image recognition which can be compiled in Mono or .Net. As such I am looking at Silverlight (running standalone) or Mono options, both of which should run on PC and Mac.
Performance (for both graphics and number crunching) is a strong consideration, though I am just as interested in getting this up and running quickly.
Does anyone have any experience with opening PDFs, extracting vector graphic elements (perhaps as SVG) and rendering them in a Mono app? Can individual elements be rendered to bitmap?
Alternatively, does anyone have experience with opening PDFs in Silverlight and converting them to XPS or XAML at runtime? I know that WPF and Silverlight graphics libraries are not 1:1, but I'm not sure how this affects XPS contents (generally composed of Canvas, Glyphs and StreamGeometry objects).
Thank you for any advice, tips or links you have to share.
look at this
http://silverpdf.codeplex.com/
it's client side pdf reading library. actually right now it can only read files, but you could play with it and make your own "display" functionality.
You might want to examine the internals of your PDFs so you understand what they actually contain better - you might be very surprised! For example, text can often be scanned pages or images and vecotr graphics do not exist as neat little packages. We wrote a whole load of general articles about what is inside a PDF and analysis tools at http://www.jpedal.org/PDFblog which are not specific to any tool or language.

Categories

Resources