PDFsharp & MigraDoc Foundation https://forum.pdfsharp.net/ |
|
pdfsharp bookmarks in text https://forum.pdfsharp.net/viewtopic.php?f=2&t=1375 |
Page 1 of 1 |
Author: | webdvlp [ Mon Oct 18, 2010 9:36 am ] |
Post subject: | pdfsharp bookmarks in text |
how can i create something like bookmark but in the text of pdf? |
Author: | Thomas Hoevel [ Mon Oct 18, 2010 11:29 am ] |
Post subject: | Re: pdfsharp bookmarks in text |
You can create a Table of Contents (see HelloMigraDoc sample) or work with Hyperlinks (viewtopic.php?p=1976#p1976). |
Author: | webdvlp [ Mon Oct 18, 2010 11:51 am ] |
Post subject: | Re: pdfsharp bookmarks in text |
the main problem- i'm confused of idea using pdfsharp and MigraDoc together. pdfsharp is so easy, but MigraDoc in my see not easy, or may be i wrong. i using pdfsharp because it simply can add new pdf document to main pdf, but i can't see how to add existing pdf to migradoc |
Author: | Thomas Hoevel [ Mon Oct 18, 2010 2:09 pm ] |
Post subject: | Re: pdfsharp bookmarks in text |
webdvlp wrote: the main problem- i'm confused of idea using pdfsharp and MigraDoc together. I couldn't tell from your first post that you'd prefer to use PDFsharp. AddHyperlink is PDFsharp - and a Table of Contents from MigraDoc finally leads to AddHyperlink. So AddHyperlink is a solution for you. |
Author: | webdvlp [ Mon Oct 18, 2010 2:30 pm ] |
Post subject: | Re: pdfsharp bookmarks in text |
AddHyperlink is from migradoc, not from pdfsharp |
Author: | Thomas Hoevel [ Mon Oct 18, 2010 2:47 pm ] |
Post subject: | Re: pdfsharp bookmarks in text |
Shame on me, you're right. The PdfPage class offers:
And AddDocumentLink is what you need to create links within a document. |
Author: | webdvlp [ Tue Oct 19, 2010 6:12 am ] |
Post subject: | Re: pdfsharp bookmarks in text |
thx for AddDocumentLink, but last adobe reader don't display this area |
Author: | Thomas Hoevel [ Tue Oct 19, 2010 8:24 am ] |
Post subject: | Re: pdfsharp bookmarks in text |
webdvlp wrote: thx for AddDocumentLink, but last adobe reader don't display this area Adobe Reader only changes the mouse cursor when it's over this area. It's up to you to draw a frame or underlined text or whatever you want. |
Author: | webdvlp [ Tue Oct 19, 2010 9:34 am ] |
Post subject: | Re: pdfsharp bookmarks in text |
yes, it change cursor but when i click on area, it not redirecting to need page |
Author: | Thomas Hoevel [ Tue Oct 19, 2010 9:49 am ] |
Post subject: | Re: pdfsharp bookmarks in text |
webdvlp wrote: when i click on area, it not redirecting to need page We use it to create our Table of Contents - and it works. Destination page is one-based so you must specify 2 to go to the second page. |
Author: | webdvlp [ Tue Oct 19, 2010 12:24 pm ] |
Post subject: | Re: pdfsharp bookmarks in text |
thanks for you supporting here is my test code Code: PdfDocument document = new PdfDocument(); XFont font = new XFont("Verdana", 10); // Create first page PdfPage page = document.AddPage(); XGraphics gfx = XGraphics.FromPdfPage(page); //XRect link = new XRect(new PdfSharp.Drawing.XPoint(20, 50), new PdfSharp.Drawing.XPoint(200, 200)); //PdfRectangle lin = new PdfRectangle(link); page.AddDocumentLink(new PdfRectangle(new PointF(10, 10), new PointF(50, 30)), 1); gfx.DrawString("first page", font, XBrushes.Black, 20, 50, XStringFormats.Default); page = document.AddPage(); gfx = XGraphics.FromPdfPage(page); gfx.DrawString("second page", font, XBrushes.Black, 20, 50, XStringFormats.Default); page = document.AddPage(); gfx = XGraphics.FromPdfPage(page); gfx.DrawString("third page", font, XBrushes.Black, 20, 50, XStringFormats.Default); string filename = "Bookmarks.pdf"; document.Save(filename); here is result pdf file http://rapidshare.com/files/425963196/Bookmarks.pdf (can't attach it) but there no redirects through document, also it create link zone in bottom of document, not in top. how can it be solved? |
Author: | Thomas Hoevel [ Tue Oct 19, 2010 2:12 pm ] |
Post subject: | Re: pdfsharp bookmarks in text |
webdvlp wrote: Code: page.AddDocumentLink(new PdfRectangle(new PointF(10, 10), new PointF(50, 30)), [color=#FF0000][i][b]1[/b][/i][/color]); but there no redirects through document, also it create link zone in bottom of document, not in top. how can it be solved? First page creates a link to first page. Nothing happens coz first page is already on the screen when you click the link on the first page. Sorry, I didn't know that links use untransformed co-ordinates. Here's the line that MigraDoc calls before adding the link: Code: XRect rect = this.gfx.Transformer.WorldToDefaultPage(this.hyperlinkRect);
|
Author: | webdvlp [ Tue Oct 19, 2010 2:42 pm ] |
Post subject: | Re: pdfsharp bookmarks in text |
great! thx a lot for helping! |
Author: | webdvlp [ Wed Oct 20, 2010 7:12 am ] |
Post subject: | Re: pdfsharp bookmarks in text |
ok all works fine, but i found i strange bug or something. here is sample pdf http://rapidshare.com/files/426108539/Bookmarks.pdf second page (with cat), so if you scroll the cat top Attachment: Untitled.jpg [ 43.51 KiB | Viewed 19992 times ] and then click to link, it redirecting to middle of page, not top can it be solved? i want to redirect to top |
Author: | Thomas Hoevel [ Wed Oct 20, 2010 7:51 am ] |
Post subject: | Re: pdfsharp bookmarks in text |
webdvlp wrote: can it be solved? i want to redirect to top In file PdfSharp\PdfSharp.Pdf.Annotations\PdfLinkAnnotation.cs locate the line Code: Elements[Keys.Dest] = new PdfLiteral("[{0} 0 R/XYZ null null 0]", dest.ObjectNumber); "null null" tells Adobe Reader not to change the display of the current page. You can try "null 0" or "null 841" (for DIN A 4) instead of "null null". Or replace "/XYZ null null 0" with "/FitB" to have Reader display the complete page. Disclaimer: I haven't tried that myself. |
Author: | webdvlp [ Wed Oct 20, 2010 9:00 am ] |
Post subject: | Re: pdfsharp bookmarks in text |
thanks works perfectly! |
Author: | Thomas Hoevel [ Wed Oct 20, 2010 9:02 am ] |
Post subject: | Re: pdfsharp bookmarks in text |
webdvlp wrote: works perfectly! What do you use? "null 0" or "null 841"? |
Author: | webdvlp [ Wed Oct 20, 2010 4:35 pm ] |
Post subject: | Re: pdfsharp bookmarks in text |
Thomas Hoevel wrote: webdvlp wrote: works perfectly! What do you use? "null 0" or "null 841"? i used "null 0" |
Author: | webdvlp [ Fri Oct 22, 2010 8:09 am ] |
Post subject: | Re: pdfsharp bookmarks in text |
Thomas Hoevel wrote: webdvlp wrote: can it be solved? i want to redirect to top In file PdfSharp\PdfSharp.Pdf.Annotations\PdfLinkAnnotation.cs locate the line Code: Elements[Keys.Dest] = new PdfLiteral("[{0} 0 R/XYZ null null 0]", dest.ObjectNumber); "null null" tells Adobe Reader not to change the display of the current page. You can try "null 0" or "null 841" (for DIN A 4) instead of "null null". Or replace "/XYZ null null 0" with "/FitB" to have Reader display the complete page. Disclaimer: I haven't tried that myself. hi how fix the same problem, but in bookmarks? also not redirect at top of page? when click on bookmark |
Author: | nagarjunaa [ Sat Mar 05, 2011 7:31 am ] |
Post subject: | Re: pdfsharp bookmarks in text |
webdvlp wrote: Thomas Hoevel wrote: webdvlp wrote: can it be solved? i want to redirect to top In file PdfSharp\PdfSharp.Pdf.Annotations\PdfLinkAnnotation.cs locate the line Code: Elements[Keys.Dest] = new PdfLiteral("[{0} 0 R/XYZ null null 0]", dest.ObjectNumber); "null null" tells Adobe Reader not to change the display of the current page. You can try "null 0" or "null 841" (for DIN A 4) instead of "null null". Or replace "/XYZ null null 0" with "/FitB" to have Reader display the complete page. Disclaimer: I haven't tried that myself. hi how fix the same problem, but in bookmarks? also not redirect at top of page? when click on bookmark I tried the same way placing null 0 in place of "null null" it is not working for. i had a pdf file of 200 page. when create the link and click on the link of page 1 referenced to 7th page it is focusing on other pages ie( 26th page) but when i set the mode of view to fit, it is working perfect. but i need it to work on normal mode of view. the problem is at Elements[Keys.Dest] = new PdfLiteral("[{0} 0 R/A null null 0]", dest.ObjectNumber); what sould i keep to work both fit and normal mode for indexing and bookmark. Thanks nagarjuna |
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |