Click here to Skip to main content
15,890,282 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
Hi,

In our .net application there is a requirement to convert pdf size to A4.
Following is the code we are using to convert pdf size to A4
PdfReader reader = new PdfReader(pdfData);
                logInfo.DebugFormat("Converting to a4 page size");
                Document document = null;
                if (isPortrait)
                {
                    document = new Document(PageSize.A4);
                }
                else
                {
                    //create a4 landscape
                    document = new Document(PageSize.A4.Rotate());
                }
                PdfWriter writer = PdfWriter.GetInstance(document, outputData);
                writer.CloseStream = false;
                document.Open();
                //copy the page from the source pdf
                PdfContentByte directcontent = writer.DirectContent;
                PdfImportedPage page = writer.GetImportedPage(reader, 1);
                iTextSharp.text.Image image = iTextSharp.text.Image.GetInstance(page);
                //center the certificate
                if (isPortrait)
                {
                    image.SetAbsolutePosition(-9, 25);
                }
                else
                {
                    image.SetAbsolutePosition(25, -9);
                }
                directcontent.AddImage(image);
                document.NewPage();
                document.Close();
                reader.Close();



But the problem here is my pdf document has some hyperlinks which are clickable.
Since we are writing the pdfbytes as image onto document we are not able to click on hyperlinks because content is converted to an image.

Can you please anyone of you help me by poviding any solution to this or any other alterntive way to convert pdf size to A4?

Please help me its urgent. No, it's not (for us).

Thanks in Advance
Basanthi
Posted
Updated 6-Jan-11 2:41am
v4
Comments
JF2015 6-Jan-11 1:41am    
Added code formatting.
Dalek Dave 6-Jan-11 3:45am    
Edited for Readability.
Richard MacCutchan 6-Jan-11 8:54am    
What is your problem i) the fact that your links become non-clickable or ii) making the page size A4?

Use something that actually alters the PDF file. You probably need to understand the format. See here for more material.
http://en.wikipedia.org/wiki/Portable_Document_Format[^]

There are some utilities out there that are able to convert pdf to other formats - like a word document.

Try searching google[^], You may find one that fits the bill...

Regards
Espen Harlinn
 
Share this answer
 
Comments
Dalek Dave 6-Jan-11 3:45am    
Good Answer.
Espen Harlinn 6-Jan-11 3:46am    
Thanks
You may need third party support for this.

There are several free apps that allow pdf conversion with hyperlink functionality.
Here[^]is one, and, woo hoo, it is free.

Alternatively you could use Open Office[^] that has a PDF converter built in that has this function for Word docs.
 
Share this answer
 
Comments
Espen Harlinn 6-Jan-11 3:57am    
5+ Open Office might do the trick ...
Richard MacCutchan 6-Jan-11 8:55am    
Judging by the code sample OP is already using iTextSharp.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900