Code Monkey home page Code Monkey logo

Comments (5)

VahidN avatar VahidN commented on July 2, 2024 1

Added it via#e8e5637

from itextsharp.lgplv2.core.

anatoly-kryzhanovsky avatar anatoly-kryzhanovsky commented on July 2, 2024

thanks for fast reaction and update
in 1.6.6 no exception was throwed, but link inside document not working...

from itextsharp.lgplv2.core.

VahidN avatar VahidN commented on July 2, 2024

Sorry I can't help you. Because I don't know how to reproduce your problem, even I couldn't test it.

from itextsharp.lgplv2.core.

anatoly-kryzhanovsky avatar anatoly-kryzhanovsky commented on July 2, 2024
using (var sourceStream = File.Open("input.pdf", FileMode.Open))
{
	using (var documentStream = File.Create("output.pdf"))
	{
		var document = new Document();
		var writer = PdfWriter.GetInstance(document, documentStream);
		writer.PageEmpty = false;

		var reader = new PdfReader(sourceStream);
		reader.ConsolidateNamedDestinations();
		PdfContentByte contentByte = null;

		writer.Outlines = SimpleBookmark.GetBookmark(reader);

		for (int page = 0; page < reader.NumberOfPages; page++)
		{
			document.SetPageSize(reader.GetPageSizeWithRotation(page + 1));

			if (page > 0)
				document.NewPage();
			else
			{
				document.Open();
				contentByte = writer.DirectContent;
			}
					
			var pageData = writer.GetImportedPage(reader, page + 1);
			contentByte.AddTemplate(pageData, 1, 0, 0, 1, 0, 0);

			var links = reader.GetLinks(page + 1);
			foreach (PdfAnnotation.PdfImportedLink link in links)
			{
				var annotation = link.CreateAnnotation(writer);
				writer.AddAnnotation(annotation);
			}
		}

		document.Close();
		documentStream.Seek(0, SeekOrigin.Begin);
	}
}

put attached pdf in same folder and execute this code. it will produce output.pdf wich contains copy of input.pdf, but all links not works (it still hoverable, but not redirect will performed then user click on it). in input.pdf all links works fine

input.pdf

from itextsharp.lgplv2.core.

anatoly-kryzhanovsky avatar anatoly-kryzhanovsky commented on July 2, 2024

ok... i think that you could ignore my question -i rewrite my code with pdfstamper and all work fine

from itextsharp.lgplv2.core.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.